OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | |
15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
16 | 13 |
17 class Profile; | |
18 | |
19 namespace net { | |
20 class CertTrustAnchorProvider; | |
21 } | |
22 | |
23 namespace chromeos { | 14 namespace chromeos { |
24 class User; | 15 class User; |
25 } | 16 } |
26 | 17 |
27 namespace policy { | 18 namespace policy { |
28 | 19 |
29 class CloudPolicyManager; | 20 class CloudPolicyManager; |
30 class ConfigurationPolicyProvider; | 21 class ConfigurationPolicyProvider; |
31 class PolicyService; | 22 class PolicyService; |
| 23 class SchemaRegistry; |
32 | 24 |
33 // A BrowserContextKeyedService that creates and manages the per-Profile policy | 25 // A BrowserContextKeyedService that creates and manages the per-Profile policy |
34 // components. | 26 // components. |
35 class ProfilePolicyConnector : public BrowserContextKeyedService { | 27 class ProfilePolicyConnector : public BrowserContextKeyedService { |
36 public: | 28 public: |
37 explicit ProfilePolicyConnector(Profile* profile); | 29 ProfilePolicyConnector(); |
38 virtual ~ProfilePolicyConnector(); | 30 virtual ~ProfilePolicyConnector(); |
39 | 31 |
40 // If |force_immediate_load| then disk caches will be loaded synchronously. | 32 // If |force_immediate_load| then disk caches will be loaded synchronously. |
41 void Init(bool force_immediate_load, | 33 void Init(bool force_immediate_load, |
42 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
43 const chromeos::User* user, | 35 const chromeos::User* user, |
| 36 SchemaRegistry* schema_registry, |
44 #endif | 37 #endif |
45 CloudPolicyManager* user_cloud_policy_manager); | 38 CloudPolicyManager* user_cloud_policy_manager); |
46 | 39 |
47 void InitForTesting(scoped_ptr<PolicyService> service); | 40 void InitForTesting(scoped_ptr<PolicyService> service); |
48 | 41 |
49 // BrowserContextKeyedService: | 42 // BrowserContextKeyedService: |
50 virtual void Shutdown() OVERRIDE; | 43 virtual void Shutdown() OVERRIDE; |
51 | 44 |
52 // This is never NULL. | 45 // This is never NULL. |
53 PolicyService* policy_service() const { return policy_service_.get(); } | 46 PolicyService* policy_service() const { return policy_service_.get(); } |
54 | 47 |
55 #if defined(OS_CHROMEOS) | 48 private: |
56 // Returns a callback that should be called if a policy installed certificate | 49 #if defined(ENABLE_CONFIGURATION_POLICY) && defined(OS_CHROMEOS) |
57 // was trusted for the associated profile. The closure can be safely used (on | 50 void InitializeDeviceLocalAccountPolicyProvider( |
58 // the UI thread) even after this Connector is destructed. | 51 const std::string& username, |
59 base::Closure GetPolicyCertTrustedCallback(); | 52 SchemaRegistry* schema_registry); |
60 #endif | |
61 | 53 |
62 // Returns true if |profile()| has used certificates installed via policy | |
63 // to establish a secure connection before. This means that it may have | |
64 // cached content from an untrusted source. | |
65 bool UsedPolicyCertificates(); | |
66 | |
67 private: | |
68 #if defined(ENABLE_CONFIGURATION_POLICY) | |
69 | |
70 #if defined(OS_CHROMEOS) | |
71 void SetUsedPolicyCertificatesOnce(); | |
72 void InitializeDeviceLocalAccountPolicyProvider(const std::string& username); | |
73 #endif | |
74 | |
75 #if defined(OS_CHROMEOS) | |
76 // Some of the user policy configuration affects browser global state, and | 54 // Some of the user policy configuration affects browser global state, and |
77 // can only come from one Profile. |is_primary_user_| is true if this | 55 // can only come from one Profile. |is_primary_user_| is true if this |
78 // connector belongs to the first signed-in Profile, and in that case that | 56 // connector belongs to the first signed-in Profile, and in that case that |
79 // Profile's policy is the one that affects global policy settings in | 57 // Profile's policy is the one that affects global policy settings in |
80 // local state. | 58 // local state. |
81 bool is_primary_user_; | 59 bool is_primary_user_; |
82 | 60 |
83 scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; | 61 scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; |
84 | |
85 base::WeakPtrFactory<ProfilePolicyConnector> weak_ptr_factory_; | |
86 #endif | 62 #endif |
87 | 63 |
88 Profile* profile_; | |
89 | |
90 #endif // ENABLE_CONFIGURATION_POLICY | |
91 | |
92 scoped_ptr<PolicyService> policy_service_; | 64 scoped_ptr<PolicyService> policy_service_; |
93 | 65 |
94 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | 66 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); |
95 }; | 67 }; |
96 | 68 |
97 } // namespace policy | 69 } // namespace policy |
98 | 70 |
99 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 71 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
OLD | NEW |