OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" | 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
29 | 29 |
30 #if defined(ENABLE_CONFIGURATION_POLICY) | 30 #if defined(ENABLE_CONFIGURATION_POLICY) |
31 #include "chrome/browser/policy/schema_registry_service.h" | 31 #include "chrome/browser/policy/schema_registry_service.h" |
32 #include "chrome/browser/policy/schema_registry_service_factory.h" | 32 #include "chrome/browser/policy/schema_registry_service_factory.h" |
33 #include "components/policy/core/browser/browser_policy_connector.h" | 33 #include "components/policy/core/browser/browser_policy_connector.h" |
34 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 34 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
35 #include "components/policy/core/common/policy_bundle.h" | 35 #include "components/policy/core/common/policy_bundle.h" |
36 #include "components/policy/core/common/policy_map.h" | 36 #include "components/policy/core/common/policy_map.h" |
37 #include "components/policy/core/common/policy_namespace.h" | 37 #include "components/policy/core/common/policy_namespace.h" |
| 38 #include "components/policy/core/common/policy_types.h" |
38 #include "components/policy/core/common/schema.h" | 39 #include "components/policy/core/common/schema.h" |
39 #include "components/policy/core/common/schema_map.h" | 40 #include "components/policy/core/common/schema_map.h" |
40 #include "components/policy/core/common/schema_registry.h" | 41 #include "components/policy/core/common/schema_registry.h" |
41 #endif | 42 #endif |
42 | 43 |
43 namespace extensions { | 44 namespace extensions { |
44 | 45 |
45 using settings_namespace::LOCAL; | 46 using settings_namespace::LOCAL; |
46 using settings_namespace::MANAGED; | 47 using settings_namespace::MANAGED; |
47 using settings_namespace::Namespace; | 48 using settings_namespace::Namespace; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void SendChanges(const syncer::SyncChangeList& change_list) { | 128 void SendChanges(const syncer::SyncChangeList& change_list) { |
128 base::MessageLoop::current()->RunUntilIdle(); | 129 base::MessageLoop::current()->RunUntilIdle(); |
129 SendChangesToSyncableService(change_list, GetSyncableService()); | 130 SendChangesToSyncableService(change_list, GetSyncableService()); |
130 } | 131 } |
131 | 132 |
132 #if defined(ENABLE_CONFIGURATION_POLICY) | 133 #if defined(ENABLE_CONFIGURATION_POLICY) |
133 void SetPolicies(const base::DictionaryValue& policies) { | 134 void SetPolicies(const base::DictionaryValue& policies) { |
134 scoped_ptr<policy::PolicyBundle> bundle(new policy::PolicyBundle()); | 135 scoped_ptr<policy::PolicyBundle> bundle(new policy::PolicyBundle()); |
135 policy::PolicyMap& policy_map = bundle->Get(policy::PolicyNamespace( | 136 policy::PolicyMap& policy_map = bundle->Get(policy::PolicyNamespace( |
136 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)); | 137 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)); |
137 policy_map.LoadFrom( | 138 policy_map.LoadFrom(&policies, policy::POLICY_LEVEL_MANDATORY, |
138 &policies, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER); | 139 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD); |
139 policy_provider_.UpdatePolicy(bundle.Pass()); | 140 policy_provider_.UpdatePolicy(bundle.Pass()); |
140 } | 141 } |
141 #endif | 142 #endif |
142 | 143 |
143 private: | 144 private: |
144 const Extension* MaybeLoadAndReplyWhenSatisfied( | 145 const Extension* MaybeLoadAndReplyWhenSatisfied( |
145 Namespace settings_namespace, | 146 Namespace settings_namespace, |
146 const std::string& normal_action, | 147 const std::string& normal_action, |
147 const std::string& incognito_action, | 148 const std::string& incognito_action, |
148 // May be NULL to imply not loading the extension. | 149 // May be NULL to imply not loading the extension. |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // ENABLE_CONFIGURATION_POLICY is not defined. | 573 // ENABLE_CONFIGURATION_POLICY is not defined. |
573 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile()); | 574 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile()); |
574 frontend->DisableStorageForTesting(MANAGED); | 575 frontend->DisableStorageForTesting(MANAGED); |
575 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); | 576 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); |
576 // Now run the extension. | 577 // Now run the extension. |
577 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) | 578 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) |
578 << message_; | 579 << message_; |
579 } | 580 } |
580 | 581 |
581 } // namespace extensions | 582 } // namespace extensions |
OLD | NEW |