Home | History | Annotate | Download | only in policy
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_
      6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
     13 
     14 namespace chromeos {
     15 class User;
     16 }
     17 
     18 namespace policy {
     19 
     20 class CloudPolicyManager;
     21 class ConfigurationPolicyProvider;
     22 class PolicyService;
     23 class SchemaRegistry;
     24 
     25 // A BrowserContextKeyedService that creates and manages the per-Profile policy
     26 // components.
     27 class ProfilePolicyConnector : public BrowserContextKeyedService {
     28  public:
     29   ProfilePolicyConnector();
     30   virtual ~ProfilePolicyConnector();
     31 
     32   // If |force_immediate_load| then disk caches will be loaded synchronously.
     33   void Init(bool force_immediate_load,
     34 #if defined(OS_CHROMEOS)
     35             const chromeos::User* user,
     36 #endif
     37             SchemaRegistry* schema_registry,
     38             CloudPolicyManager* user_cloud_policy_manager);
     39 
     40   void InitForTesting(scoped_ptr<PolicyService> service);
     41 
     42   // BrowserContextKeyedService:
     43   virtual void Shutdown() OVERRIDE;
     44 
     45   // This is never NULL.
     46   PolicyService* policy_service() const { return policy_service_.get(); }
     47 
     48  private:
     49 #if defined(ENABLE_CONFIGURATION_POLICY)
     50 #if defined(OS_CHROMEOS)
     51   void InitializeDeviceLocalAccountPolicyProvider(
     52       const std::string& username,
     53       SchemaRegistry* schema_registry);
     54 
     55   // Some of the user policy configuration affects browser global state, and
     56   // can only come from one Profile. |is_primary_user_| is true if this
     57   // connector belongs to the first signed-in Profile, and in that case that
     58   // Profile's policy is the one that affects global policy settings in
     59   // local state.
     60   bool is_primary_user_;
     61 
     62   scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_;
     63 #endif  // defined(OS_CHROMEOS)
     64 
     65   scoped_ptr<ConfigurationPolicyProvider> forwarding_policy_provider_;
     66 #endif  // defined(ENABLE_CONFIGURATION_POLICY)
     67 
     68   scoped_ptr<PolicyService> policy_service_;
     69 
     70   DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector);
     71 };
     72 
     73 }  // namespace policy
     74 
     75 #endif  // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_
     76