| Index: chrome/browser/extensions/extension_management_test_util.h
|
| diff --git a/chrome/browser/extensions/extension_management_test_util.h b/chrome/browser/extensions/extension_management_test_util.h
|
| index 5347f426a82ddd44f8f1aba6a81b273a576eac99..ded3ea492e3df76ea8bcf6a8d49809a1fd2e1d02 100644
|
| --- a/chrome/browser/extensions/extension_management_test_util.h
|
| +++ b/chrome/browser/extensions/extension_management_test_util.h
|
| @@ -14,6 +14,11 @@
|
| #include "extensions/browser/pref_names.h"
|
| #include "extensions/common/extension.h"
|
|
|
| +namespace policy {
|
| +class MockConfigurationPolicyProvider;
|
| +class PolicyBundle;
|
| +} // namespace policy
|
| +
|
| namespace extensions {
|
|
|
| // Base class for essential routines on preference manipulation.
|
| @@ -45,7 +50,25 @@ class ExtensionManagementPrefUpdaterBase {
|
| void UnsetAllowedTypes();
|
| void ClearAllowedTypes();
|
| void AddAllowedType(const std::string& allowed_type);
|
| - void RemoveAllowedType(const std::string& allowd_type);
|
| + void RemoveAllowedType(const std::string& allowed_type);
|
| +
|
| + // Helper functions for 'blocked_permissions' manipulation. |prefix| can be
|
| + // kWildCard or a valid extension ID.
|
| + void UnsetBlockedPermissions(const std::string& prefix);
|
| + void ClearBlockedPermissions(const std::string& prefix);
|
| + void AddBlockedPermission(const std::string& prefix,
|
| + const std::string& permission);
|
| + void RemoveBlockedPermission(const std::string& prefix,
|
| + const std::string& permission);
|
| +
|
| + // Helper functions for 'allowed_permissions' manipulation. |id| must be a
|
| + // valid extension id.
|
| + void UnsetAllowedPermissions(const std::string& id);
|
| + void ClearAllowedPermissions(const std::string& id);
|
| + void AddAllowedPermission(const std::string& id,
|
| + const std::string& permission);
|
| + void RemoveAllowedPermission(const std::string& id,
|
| + const std::string& permission);
|
|
|
| // Expose a read-only preference to user.
|
| const base::DictionaryValue* GetPref();
|
| @@ -82,13 +105,11 @@ class ExtensionManagementPrefUpdater
|
| : service_(service) {
|
| const base::Value* pref_value =
|
| service_->GetManagedPref(pref_names::kExtensionManagement);
|
| - if (pref_value) {
|
| - const base::DictionaryValue* dict_value = NULL;
|
| - pref_value->GetAsDictionary(&dict_value);
|
| + const base::DictionaryValue* dict_value = nullptr;
|
| + if (pref_value && pref_value->GetAsDictionary(&dict_value))
|
| SetPref(dict_value->DeepCopy());
|
| - } else {
|
| + else
|
| SetPref(new base::DictionaryValue);
|
| - }
|
| }
|
|
|
| virtual ~ExtensionManagementPrefUpdater() {
|
| @@ -102,6 +123,22 @@ class ExtensionManagementPrefUpdater
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPrefUpdater);
|
| };
|
|
|
| +// A helper class to manipulate the extension management policy in browser
|
| +// tests.
|
| +class ExtensionManagementPolicyUpdater
|
| + : public ExtensionManagementPrefUpdaterBase {
|
| + public:
|
| + explicit ExtensionManagementPolicyUpdater(
|
| + policy::MockConfigurationPolicyProvider* provider);
|
| + ~ExtensionManagementPolicyUpdater() override;
|
| +
|
| + private:
|
| + policy::MockConfigurationPolicyProvider* provider_;
|
| + scoped_ptr<policy::PolicyBundle> policies_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ExtensionManagementPolicyUpdater);
|
| +};
|
| +
|
| } // namespace extensions
|
|
|
| #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_TEST_UTIL_H_
|
|
|