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

Unified Diff: components/policy/core/common/policy_provider_android.cc

Issue 155923002: Add a platform policy provider for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 10 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: components/policy/core/common/policy_provider_android.cc
diff --git a/components/policy/core/common/policy_provider_android.cc b/components/policy/core/common/policy_provider_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d70fbe6904bdb6194646117cb348c6b181788495
--- /dev/null
+++ b/components/policy/core/common/policy_provider_android.cc
@@ -0,0 +1,61 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/policy/core/common/policy_provider_android.h"
+#include "components/policy/core/common/policy_provider_android_delegate.h"
+
+namespace policy {
+
+namespace {
+
+bool g_wait_for_policies = false;
+
+} // namespace
+
+PolicyProviderAndroid::PolicyProviderAndroid()
+ : delegate_(NULL),
+ initialized_(!g_wait_for_policies) {}
+
+PolicyProviderAndroid::~PolicyProviderAndroid() {}
+
+// static
+void PolicyProviderAndroid::SetShouldWaitForPolicy(
+ bool should_wait_for_policy) {
+ g_wait_for_policies = should_wait_for_policy;
+}
+
+void PolicyProviderAndroid::SetDelegate(
+ PolicyProviderAndroidDelegate* delegate) {
+ delegate_ = delegate;
+}
+
+void PolicyProviderAndroid::SetPolicies(scoped_ptr<PolicyBundle> policy) {
+ initialized_ = true;
+ UpdatePolicy(policy.Pass());
+}
+
+void PolicyProviderAndroid::Shutdown() {
+ if (delegate_)
+ delegate_->PolicyProviderShutdown();
+
+ ConfigurationPolicyProvider::Shutdown();
+}
+
+bool PolicyProviderAndroid::IsInitializationComplete(
+ PolicyDomain domain) const {
+ return initialized_;
+}
+
+void PolicyProviderAndroid::RefreshPolicies() {
+ if (delegate_) {
+ delegate_->RefreshPolicies();
+ } else {
+ // If we don't have a delegate, pass a copy of the current policies.
+ scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
+ bundle->CopyFrom(policies());
+ UpdatePolicy(bundle.Pass());
+ }
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698