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 <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/extension_management_constants.h" | 13 #include "chrome/browser/extensions/extension_management_constants.h" |
14 #include "extensions/browser/pref_names.h" | 14 #include "extensions/browser/pref_names.h" |
15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 class MockConfigurationPolicyProvider; | 18 class MockConfigurationPolicyProvider; |
19 class PolicyBundle; | 19 class PolicyBundle; |
20 } // namespace policy | 20 } // namespace policy |
21 | 21 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 protected: | 82 protected: |
83 // Set the preference with |pref|, pass the ownership of it as well. | 83 // Set the preference with |pref|, pass the ownership of it as well. |
84 // This function must be called before accessing publicly exposed functions, | 84 // This function must be called before accessing publicly exposed functions, |
85 // for example in constructor of subclass. | 85 // for example in constructor of subclass. |
86 void SetPref(base::DictionaryValue* pref); | 86 void SetPref(base::DictionaryValue* pref); |
87 | 87 |
88 // Take the preference. Caller takes ownership of it as well. | 88 // Take the preference. Caller takes ownership of it as well. |
89 // This function must be called after accessing publicly exposed functions, | 89 // This function must be called after accessing publicly exposed functions, |
90 // for example in destructor of subclass. | 90 // for example in destructor of subclass. |
91 scoped_ptr<base::DictionaryValue> TakePref(); | 91 std::unique_ptr<base::DictionaryValue> TakePref(); |
92 | 92 |
93 private: | 93 private: |
94 // Helper functions for manipulating sub properties like list of strings. | 94 // Helper functions for manipulating sub properties like list of strings. |
95 void ClearList(const std::string& path); | 95 void ClearList(const std::string& path); |
96 void AddStringToList(const std::string& path, const std::string& str); | 96 void AddStringToList(const std::string& path, const std::string& str); |
97 void RemoveStringFromList(const std::string& path, const std::string& str); | 97 void RemoveStringFromList(const std::string& path, const std::string& str); |
98 | 98 |
99 scoped_ptr<base::DictionaryValue> pref_; | 99 std::unique_ptr<base::DictionaryValue> pref_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPrefUpdaterBase); | 101 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPrefUpdaterBase); |
102 }; | 102 }; |
103 | 103 |
104 // A helper class to manipulate the extension management preference in unit | 104 // A helper class to manipulate the extension management preference in unit |
105 // tests. | 105 // tests. |
106 template <class TestingPrefService> | 106 template <class TestingPrefService> |
107 class ExtensionManagementPrefUpdater | 107 class ExtensionManagementPrefUpdater |
108 : public ExtensionManagementPrefUpdaterBase { | 108 : public ExtensionManagementPrefUpdaterBase { |
109 public: | 109 public: |
(...skipping 23 matching lines...) Expand all Loading... |
133 // tests. | 133 // tests. |
134 class ExtensionManagementPolicyUpdater | 134 class ExtensionManagementPolicyUpdater |
135 : public ExtensionManagementPrefUpdaterBase { | 135 : public ExtensionManagementPrefUpdaterBase { |
136 public: | 136 public: |
137 explicit ExtensionManagementPolicyUpdater( | 137 explicit ExtensionManagementPolicyUpdater( |
138 policy::MockConfigurationPolicyProvider* provider); | 138 policy::MockConfigurationPolicyProvider* provider); |
139 ~ExtensionManagementPolicyUpdater() override; | 139 ~ExtensionManagementPolicyUpdater() override; |
140 | 140 |
141 private: | 141 private: |
142 policy::MockConfigurationPolicyProvider* provider_; | 142 policy::MockConfigurationPolicyProvider* provider_; |
143 scoped_ptr<policy::PolicyBundle> policies_; | 143 std::unique_ptr<policy::PolicyBundle> policies_; |
144 | 144 |
145 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPolicyUpdater); | 145 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPolicyUpdater); |
146 }; | 146 }; |
147 | 147 |
148 } // namespace extensions | 148 } // namespace extensions |
149 | 149 |
150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ | 150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_ |
OLD | NEW |