OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const base::Value* pref_value = | 112 const base::Value* pref_value = |
113 service_->GetManagedPref(pref_names::kExtensionManagement); | 113 service_->GetManagedPref(pref_names::kExtensionManagement); |
114 const base::DictionaryValue* dict_value = nullptr; | 114 const base::DictionaryValue* dict_value = nullptr; |
115 if (pref_value && pref_value->GetAsDictionary(&dict_value)) | 115 if (pref_value && pref_value->GetAsDictionary(&dict_value)) |
116 SetPref(dict_value->DeepCopy()); | 116 SetPref(dict_value->DeepCopy()); |
117 else | 117 else |
118 SetPref(new base::DictionaryValue); | 118 SetPref(new base::DictionaryValue); |
119 } | 119 } |
120 | 120 |
121 virtual ~ExtensionManagementPrefUpdater() { | 121 virtual ~ExtensionManagementPrefUpdater() { |
122 service_->SetManagedPref(pref_names::kExtensionManagement, | 122 service_->SetManagedPref(pref_names::kExtensionManagement, TakePref()); |
123 TakePref().release()); | |
124 } | 123 } |
125 | 124 |
126 private: | 125 private: |
127 TestingPrefService* service_; | 126 TestingPrefService* service_; |
128 | 127 |
129 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPrefUpdater); | 128 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPrefUpdater); |
130 }; | 129 }; |
131 | 130 |
132 // A helper class to manipulate the extension management policy in browser | 131 // A helper class to manipulate the extension management policy in browser |
133 // tests. | 132 // tests. |
134 class ExtensionManagementPolicyUpdater | 133 class ExtensionManagementPolicyUpdater |
135 : public ExtensionManagementPrefUpdaterBase { | 134 : public ExtensionManagementPrefUpdaterBase { |
136 public: | 135 public: |
137 explicit ExtensionManagementPolicyUpdater( | 136 explicit ExtensionManagementPolicyUpdater( |
138 policy::MockConfigurationPolicyProvider* provider); | 137 policy::MockConfigurationPolicyProvider* provider); |
139 ~ExtensionManagementPolicyUpdater() override; | 138 ~ExtensionManagementPolicyUpdater() override; |
140 | 139 |
141 private: | 140 private: |
142 policy::MockConfigurationPolicyProvider* provider_; | 141 policy::MockConfigurationPolicyProvider* provider_; |
143 std::unique_ptr<policy::PolicyBundle> policies_; | 142 std::unique_ptr<policy::PolicyBundle> policies_; |
144 | 143 |
145 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPolicyUpdater); | 144 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPolicyUpdater); |
146 }; | 145 }; |
147 | 146 |
148 } // namespace extensions | 147 } // namespace extensions |
149 | 148 |
150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ | 149 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ |
OLD | NEW |