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

Unified Diff: chrome/browser/policy/cloud/cloud_policy_manager.cc

Issue 79023002: Support cloud policy for extensions on the desktop platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/policy/cloud/cloud_policy_manager.cc
diff --git a/chrome/browser/policy/cloud/cloud_policy_manager.cc b/chrome/browser/policy/cloud/cloud_policy_manager.cc
index 9f17ea1cd9be9a602b78773c8fdcaf251f627710..c58809c05e111148a4241d836f42e8e703eb3f7f 100644
--- a/chrome/browser/policy/cloud/cloud_policy_manager.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_manager.cc
@@ -6,20 +6,32 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/policy/cloud/cloud_policy_service.h"
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_map.h"
+#include "components/policy/core/common/policy_switches.h"
+#include "net/url_request/url_request_context_getter.h"
+
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+#include "chrome/browser/policy/cloud/resource_cache.h"
+#endif
namespace policy {
CloudPolicyManager::CloudPolicyManager(
const PolicyNamespaceKey& policy_ns_key,
CloudPolicyStore* cloud_policy_store,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner)
+ const scoped_refptr<base::SequencedTaskRunner>& task_runner,
+ const scoped_refptr<base::SequencedTaskRunner>& file_task_runner,
+ const scoped_refptr<base::SequencedTaskRunner>& io_task_runner)
: core_(policy_ns_key, cloud_policy_store, task_runner),
- waiting_for_policy_refresh_(false) {
+ waiting_for_policy_refresh_(false),
+ file_task_runner_(file_task_runner),
+ io_task_runner_(io_task_runner) {
store()->AddObserver(this);
// If the underlying store is already initialized, publish the loaded
@@ -33,6 +45,7 @@ CloudPolicyManager::CloudPolicyManager(
CloudPolicyManager::~CloudPolicyManager() {}
void CloudPolicyManager::Shutdown() {
+ component_policy_service_.reset();
core_.Disconnect();
store()->RemoveObserver(this);
ConfigurationPolicyProvider::Shutdown();
@@ -41,6 +54,10 @@ void CloudPolicyManager::Shutdown() {
bool CloudPolicyManager::IsInitializationComplete(PolicyDomain domain) const {
if (domain == POLICY_DOMAIN_CHROME)
return store()->is_initialized();
+ if (ComponentCloudPolicyService::SupportsDomain(domain) &&
+ component_policy_service_) {
+ return component_policy_service_->is_initialized();
+ }
return true;
}
@@ -68,18 +85,51 @@ void CloudPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) {
CheckAndPublishPolicy();
}
+void CloudPolicyManager::OnComponentCloudPolicyUpdated() {
+ CheckAndPublishPolicy();
+}
+
void CloudPolicyManager::CheckAndPublishPolicy() {
if (IsInitializationComplete(POLICY_DOMAIN_CHROME) &&
!waiting_for_policy_refresh_) {
- UpdatePolicy(CreatePolicyBundle());
+ scoped_ptr<PolicyBundle> bundle(new PolicyBundle);
+ bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
+ .CopyFrom(store()->policy_map());
+ if (component_policy_service_)
+ bundle->MergeFrom(component_policy_service_->policy());
+ UpdatePolicy(bundle.Pass());
}
}
-scoped_ptr<PolicyBundle> CloudPolicyManager::CreatePolicyBundle() {
- scoped_ptr<PolicyBundle> bundle(new PolicyBundle);
- bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
- .CopyFrom(store()->policy_map());
- return bundle.Pass();
+void CloudPolicyManager::CreateComponentCloudPolicyService(
+ const base::FilePath& policy_cache_path,
+ const scoped_refptr<net::URLRequestContextGetter>& request_context) {
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+ // Init() must have been called.
+ DCHECK(schema_registry());
+ // Called at most once.
+ DCHECK(!component_policy_service_);
+
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableComponentCloudPolicy) ||
+ policy_cache_path.empty()) {
+ return;
+ }
+
+ // TODO(joaodasilva): Move the |file_task_runner_| to the blocking pool.
+ // Currently it's not possible because the ComponentCloudPolicyStore is
+ // NonThreadSafe and doesn't support getting calls from different threads.
+ scoped_ptr<ResourceCache> resource_cache(
+ new ResourceCache(policy_cache_path, file_task_runner_));
+ component_policy_service_.reset(new ComponentCloudPolicyService(
+ this,
+ schema_registry(),
+ core(),
+ resource_cache.Pass(),
+ request_context,
+ file_task_runner_,
+ io_task_runner_));
+#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
}
void CloudPolicyManager::OnRefreshComplete(bool success) {
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_manager.h ('k') | chrome/browser/policy/cloud/cloud_policy_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698