Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / components / policy / core / common / policy_provider_android.cc
blobd3076614992fdb60b5d9fd7bd51b7be52f2da45a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/policy/core/common/policy_provider_android.h"
6 #include "components/policy/core/common/policy_provider_android_delegate.h"
8 namespace policy {
10 namespace {
12 bool g_wait_for_policies = false;
14 } // namespace
16 PolicyProviderAndroid::PolicyProviderAndroid()
17 : delegate_(NULL),
18 initialized_(!g_wait_for_policies) {}
20 PolicyProviderAndroid::~PolicyProviderAndroid() {}
22 const Schema* PolicyProviderAndroid::GetChromeSchema() const {
23 PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string());
24 return schema_map()->GetSchema(ns);
27 // static
28 void PolicyProviderAndroid::SetShouldWaitForPolicy(
29 bool should_wait_for_policy) {
30 g_wait_for_policies = should_wait_for_policy;
33 void PolicyProviderAndroid::SetDelegate(
34 PolicyProviderAndroidDelegate* delegate) {
35 DCHECK(!delegate || !delegate_);
36 delegate_ = delegate;
39 void PolicyProviderAndroid::SetPolicies(scoped_ptr<PolicyBundle> policy) {
40 initialized_ = true;
41 UpdatePolicy(policy.Pass());
44 void PolicyProviderAndroid::Shutdown() {
45 if (delegate_)
46 delegate_->PolicyProviderShutdown();
48 ConfigurationPolicyProvider::Shutdown();
51 bool PolicyProviderAndroid::IsInitializationComplete(
52 PolicyDomain domain) const {
53 return initialized_;
56 void PolicyProviderAndroid::RefreshPolicies() {
57 if (delegate_) {
58 delegate_->RefreshPolicies();
59 } else {
60 // If we don't have a delegate, pass a copy of the current policies.
61 scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
62 bundle->CopyFrom(policies());
63 UpdatePolicy(bundle.Pass());
67 } // namespace policy