| 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 #include <vector> | |
| 10 | 9 |
| 11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 17 | 13 |
| 18 #if defined(OS_CHROMEOS) | 14 namespace chromeos { |
| 19 #include "chromeos/dbus/dbus_method_call_status.h" | 15 class User; |
| 20 #endif | |
| 21 | |
| 22 class Profile; | |
| 23 | |
| 24 namespace net { | |
| 25 class CertTrustAnchorProvider; | |
| 26 } | |
| 27 | |
| 28 namespace net { | |
| 29 class X509Certificate; | |
| 30 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | |
| 31 } | 16 } |
| 32 | 17 |
| 33 namespace policy { | 18 namespace policy { |
| 34 | 19 |
| 20 class CloudPolicyManager; |
| 35 class ConfigurationPolicyProvider; | 21 class ConfigurationPolicyProvider; |
| 36 class UserNetworkConfigurationUpdater; | |
| 37 class PolicyService; | 22 class PolicyService; |
| 38 class PolicyCertVerifier; | |
| 39 | 23 |
| 40 // A BrowserContextKeyedService that creates and manages the per-Profile policy | 24 // A BrowserContextKeyedService that creates and manages the per-Profile policy |
| 41 // components. | 25 // components. |
| 42 class ProfilePolicyConnector : public BrowserContextKeyedService { | 26 class ProfilePolicyConnector : public BrowserContextKeyedService { |
| 43 public: | 27 public: |
| 44 explicit ProfilePolicyConnector(Profile* profile); | 28 ProfilePolicyConnector(); |
| 45 virtual ~ProfilePolicyConnector(); | 29 virtual ~ProfilePolicyConnector(); |
| 46 | 30 |
| 47 // If |force_immediate_load| then disk caches will be loaded synchronously. | 31 // If |force_immediate_load| then disk caches will be loaded synchronously. |
| 48 void Init(bool force_immediate_load); | 32 void Init(bool force_immediate_load, |
| 33 #if defined(OS_CHROMEOS) |
| 34 const chromeos::User* user, |
| 35 #endif |
| 36 CloudPolicyManager* user_cloud_policy_manager); |
| 49 | 37 |
| 50 void InitForTesting(scoped_ptr<PolicyService> service); | 38 void InitForTesting(scoped_ptr<PolicyService> service); |
| 51 | 39 |
| 52 // BrowserContextKeyedService: | 40 // BrowserContextKeyedService: |
| 53 virtual void Shutdown() OVERRIDE; | 41 virtual void Shutdown() OVERRIDE; |
| 54 | 42 |
| 55 // This is never NULL. | 43 // This is never NULL. |
| 56 PolicyService* policy_service() const { return policy_service_.get(); } | 44 PolicyService* policy_service() const { return policy_service_.get(); } |
| 57 | 45 |
| 58 #if defined(OS_CHROMEOS) | 46 private: |
| 59 // Sets the CertVerifier on which the current list of Web trusted server and | 47 #if defined(ENABLE_CONFIGURATION_POLICY) && defined(OS_CHROMEOS) |
| 60 // CA certificates will be set. Policy updates will trigger further calls to | 48 void InitializeDeviceLocalAccountPolicyProvider(const std::string& username); |
| 61 // |cert_verifier| later. |cert_verifier| must be valid until | |
| 62 // SetPolicyCertVerifier is called again (with another CertVerifier or NULL) | |
| 63 // or until this Connector is destructed. |cert_verifier|'s methods are only | |
| 64 // called on the IO thread. This function must be called on the UI thread. | |
| 65 void SetPolicyCertVerifier(PolicyCertVerifier* cert_verifier); | |
| 66 | 49 |
| 67 // Returns a callback that should be called if a policy installed certificate | |
| 68 // was trusted for the associated profile. The closure can be safely used (on | |
| 69 // the UI thread) even after this Connector is destructed. | |
| 70 base::Closure GetPolicyCertTrustedCallback(); | |
| 71 | |
| 72 // Sets |certs| to the list of Web trusted server and CA certificates from the | |
| 73 // last received ONC user policy. | |
| 74 void GetWebTrustedCertificates(net::CertificateList* certs) const; | |
| 75 #endif | |
| 76 | |
| 77 // Returns true if |profile()| has used certificates installed via policy | |
| 78 // to establish a secure connection before. This means that it may have | |
| 79 // cached content from an untrusted source. | |
| 80 bool UsedPolicyCertificates(); | |
| 81 | |
| 82 private: | |
| 83 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 84 | |
| 85 #if defined(OS_CHROMEOS) | |
| 86 void SetUsedPolicyCertificatesOnce(); | |
| 87 void InitializeDeviceLocalAccountPolicyProvider(const std::string& username); | |
| 88 #endif | |
| 89 | |
| 90 #if defined(OS_CHROMEOS) | |
| 91 // Some of the user policy configuration affects browser global state, and | 50 // Some of the user policy configuration affects browser global state, and |
| 92 // can only come from one Profile. |is_primary_user_| is true if this | 51 // can only come from one Profile. |is_primary_user_| is true if this |
| 93 // connector belongs to the first signed-in Profile, and in that case that | 52 // connector belongs to the first signed-in Profile, and in that case that |
| 94 // Profile's policy is the one that affects global policy settings in | 53 // Profile's policy is the one that affects global policy settings in |
| 95 // local state. | 54 // local state. |
| 96 bool is_primary_user_; | 55 bool is_primary_user_; |
| 97 | 56 |
| 98 scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; | 57 scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; |
| 99 scoped_ptr<UserNetworkConfigurationUpdater> network_configuration_updater_; | |
| 100 | |
| 101 base::WeakPtrFactory<ProfilePolicyConnector> weak_ptr_factory_; | |
| 102 #endif | 58 #endif |
| 103 | 59 |
| 104 Profile* profile_; | |
| 105 | |
| 106 #endif // ENABLE_CONFIGURATION_POLICY | |
| 107 | |
| 108 scoped_ptr<PolicyService> policy_service_; | 60 scoped_ptr<PolicyService> policy_service_; |
| 109 | 61 |
| 110 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | 62 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); |
| 111 }; | 63 }; |
| 112 | 64 |
| 113 } // namespace policy | 65 } // namespace policy |
| 114 | 66 |
| 115 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 67 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
| OLD | NEW |