diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 10:24:13 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 10:24:13 +0000 |
commit | 0b8acae7ce77ed6db4e0a28c2faa7467fe6ac76b (patch) | |
tree | acc5cc003e35d6d8889b0a01354b8dc3d7639a26 /components | |
parent | 30bf0067b9409b9c4182796c5c032a9b297b59e7 (diff) | |
download | chromium_src-0b8acae7ce77ed6db4e0a28c2faa7467fe6ac76b.zip chromium_src-0b8acae7ce77ed6db4e0a28c2faa7467fe6ac76b.tar.gz chromium_src-0b8acae7ce77ed6db4e0a28c2faa7467fe6ac76b.tar.bz2 |
Add a ProxyPolicyProvider to BrowserPolicyConnectorIos.
This will allow user cloud policy to override preferences in Local State,
which is required to implement some policies such as MetricsReportingEnabled.
BUG=275292
R=dconnelly@chromium.org
Review URL: https://codereview.chromium.org/145263003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/policy/core/browser/browser_policy_connector_ios.h | 15 | ||||
-rw-r--r-- | components/policy/core/browser/browser_policy_connector_ios.mm | 14 | ||||
-rw-r--r-- | components/policy/policy_common.gypi | 6 |
3 files changed, 32 insertions, 3 deletions
diff --git a/components/policy/core/browser/browser_policy_connector_ios.h b/components/policy/core/browser/browser_policy_connector_ios.h index d1523a4..2388694 100644 --- a/components/policy/core/browser/browser_policy_connector_ios.h +++ b/components/policy/core/browser/browser_policy_connector_ios.h @@ -14,6 +14,8 @@ namespace policy { +class ProxyPolicyProvider; + // Extends BrowserPolicyConnector with the setup for iOS builds. class POLICY_EXPORT BrowserPolicyConnectorIOS : public BrowserPolicyConnector { public: @@ -27,9 +29,22 @@ class POLICY_EXPORT BrowserPolicyConnectorIOS : public BrowserPolicyConnector { PrefService* local_state, scoped_refptr<net::URLRequestContextGetter> request_context) OVERRIDE; + // The browser-global PolicyService is created before Profiles are ready, to + // provide managed values for the local state PrefService. It includes a + // policy provider that forwards policies from a delegate policy provider. + // This call can be used to set the user policy provider as that delegate + // once the Profile is ready, so that user policies can also affect local + // state preferences. + // Only one user policy provider can be set as a delegate at a time, and any + // previously set delegate is removed. Passing NULL removes the current + // delegate, if there is one. + void SetUserPolicyDelegate(ConfigurationPolicyProvider* user_policy_provider); + private: std::string user_agent_; + ProxyPolicyProvider* global_user_cloud_policy_provider_; + DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnectorIOS); }; diff --git a/components/policy/core/browser/browser_policy_connector_ios.mm b/components/policy/core/browser/browser_policy_connector_ios.mm index 60ec33e..f900b0b 100644 --- a/components/policy/core/browser/browser_policy_connector_ios.mm +++ b/components/policy/core/browser/browser_policy_connector_ios.mm @@ -7,6 +7,7 @@ #include "base/strings/stringprintf.h" #include "base/sys_info.h" #include "components/policy/core/common/cloud/device_management_service.h" +#include "components/policy/core/common/proxy_policy_provider.h" #include "net/url_request/url_request_context_getter.h" namespace policy { @@ -59,7 +60,11 @@ BrowserPolicyConnectorIOS::BrowserPolicyConnectorIOS( scoped_ptr<ConfigurationPolicyHandlerList> handler_list, const std::string& user_agent) : BrowserPolicyConnector(handler_list.Pass()), - user_agent_(user_agent) {} + user_agent_(user_agent), + global_user_cloud_policy_provider_(new ProxyPolicyProvider) { + AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider>( + global_user_cloud_policy_provider_)); +} BrowserPolicyConnectorIOS::~BrowserPolicyConnectorIOS() {} @@ -78,9 +83,12 @@ void BrowserPolicyConnectorIOS::Init( BrowserPolicyConnector::Init( local_state, request_context, device_management_service.Pass()); +} - // TODO(joaodasilva): add a ProxyPolicyProvider so that user cloud policy - // can override Local State prefs on iOS. http://crbug.com/275292 +void BrowserPolicyConnectorIOS::SetUserPolicyDelegate( + ConfigurationPolicyProvider* user_policy_provider) { + global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); } + } // namespace policy diff --git a/components/policy/policy_common.gypi b/components/policy/policy_common.gypi index c343a6a..0f2d020 100644 --- a/components/policy/policy_common.gypi +++ b/components/policy/policy_common.gypi @@ -172,6 +172,12 @@ 'core/common/cloud/user_cloud_policy_store.h', ], }], + ['OS=="ios"', { + 'sources': [ + 'core/common/proxy_policy_provider.cc', + 'core/common/proxy_policy_provider.h', + ], + }], ], }, { # configuration_policy==0 # Some of the policy code is always enabled, so that other parts of |