Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: chrome/browser/chromeos/policy/device_local_account_policy_provider.cc

Issue 341043005: Wire up component cloud policy to device local accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
index b6ed507a79977fdf3f5974d2b409557771c4edd9..837eb99e57bfea1b50bb9ab3486e29e2427d7b80 100644
--- a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/device_local_account_external_data_manager.h"
@@ -14,6 +15,9 @@
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_namespace.h"
+#include "components/policy/core/common/policy_switches.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/url_request/url_request_context_getter.h"
#include "policy/policy_constants.h"
namespace policy {
@@ -94,10 +98,19 @@ DeviceLocalAccountPolicyProvider::Create(
return provider.Pass();
}
+void DeviceLocalAccountPolicyProvider::Init(SchemaRegistry* schema_registry) {
+ ConfigurationPolicyProvider::Init(schema_registry);
+ MaybeCreateComponentPolicyService();
+}
+
bool DeviceLocalAccountPolicyProvider::IsInitializationComplete(
PolicyDomain domain) const {
if (domain == POLICY_DOMAIN_CHROME)
return store_initialized_;
+ if (ComponentCloudPolicyService::SupportsDomain(domain) &&
+ component_policy_service_) {
+ return component_policy_service_->is_initialized();
bartfab (slow) 2014/06/20 09:17:25 Is it correct for this method to return |true| if
Joao da Silva 2014/06/20 11:48:45 Good observation. In the next CL the component_pol
+ }
return true;
}
@@ -113,13 +126,34 @@ void DeviceLocalAccountPolicyProvider::RefreshPolicies() {
}
}
+void DeviceLocalAccountPolicyProvider::Shutdown() {
+ component_policy_service_.reset();
+ ConfigurationPolicyProvider::Shutdown();
+}
+
void DeviceLocalAccountPolicyProvider::OnPolicyUpdated(
const std::string& user_id) {
- if (user_id == user_id_)
+ if (user_id == user_id_) {
+ MaybeCreateComponentPolicyService();
UpdateFromBroker();
+ }
}
void DeviceLocalAccountPolicyProvider::OnDeviceLocalAccountsChanged() {
+ MaybeCreateComponentPolicyService();
+ UpdateFromBroker();
+}
+
+void DeviceLocalAccountPolicyProvider::OnBrokerShutdown(
+ DeviceLocalAccountPolicyBroker* broker) {
+ if (broker->user_id() == user_id_) {
+ // The |component_policy_service_| relies on the broker's CloudPolicyCore,
bartfab (slow) 2014/06/20 09:17:24 Nit: s/broker/|broker|/
Joao da Silva 2014/06/20 11:48:45 Obsolete in the next CL.
+ // so destroy it if the broker is going away.
bartfab (slow) 2014/06/20 09:17:25 Nit: s/broker/|broker|/
Joao da Silva 2014/06/20 11:48:45 Same
+ component_policy_service_.reset();
+ }
+}
+
+void DeviceLocalAccountPolicyProvider::OnComponentCloudPolicyUpdated() {
UpdateFromBroker();
}
@@ -153,6 +187,9 @@ void DeviceLocalAccountPolicyProvider::UpdateFromBroker() {
bundle->CopyFrom(policies());
}
+ if (component_policy_service_)
+ bundle->MergeFrom(component_policy_service_->policy());
+
// Apply overrides.
if (chrome_policy_overrides_) {
PolicyMap& chrome_policy =
@@ -169,4 +206,35 @@ void DeviceLocalAccountPolicyProvider::UpdateFromBroker() {
UpdatePolicy(bundle.Pass());
}
+void DeviceLocalAccountPolicyProvider::MaybeCreateComponentPolicyService() {
+ if (component_policy_service_)
+ return; // Already started.
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableComponentCloudPolicy)) {
+ // Disabled via the command line.
+ return;
+ }
+
+ DeviceLocalAccountPolicyBroker* broker = GetBroker();
+ if (!broker || !schema_registry())
+ return; // Missing broker or not initialized yet.
+
+ scoped_ptr<ResourceCache> resource_cache(
+ new ResourceCache(broker->GetComponentPolicyCachePath(),
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::FILE)));
+
+ component_policy_service_.reset(new ComponentCloudPolicyService(
+ this,
+ schema_registry(),
+ broker->core(),
+ resource_cache.Pass(),
+ service_->request_context(),
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::FILE),
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::IO)));
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698