| 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_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 19 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 20 #include "components/keyed_service/core/keyed_service.h" | 20 #include "components/keyed_service/core/keyed_service.h" |
| 21 #include "components/prefs/pref_change_registrar.h" | 21 #include "components/prefs/pref_change_registrar.h" |
| 22 #include "extensions/browser/management_policy.h" | 22 #include "extensions/browser/management_policy.h" |
| 23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| 24 #include "extensions/common/manifest.h" | 24 #include "extensions/common/manifest.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Checks if extensions are blacklisted by default, by policy. When true, | 86 // Checks if extensions are blacklisted by default, by policy. When true, |
| 87 // this means that even extensions without an ID should be blacklisted (e.g. | 87 // this means that even extensions without an ID should be blacklisted (e.g. |
| 88 // from the command line, or when loaded as an unpacked extension). | 88 // from the command line, or when loaded as an unpacked extension). |
| 89 bool BlacklistedByDefault() const; | 89 bool BlacklistedByDefault() const; |
| 90 | 90 |
| 91 // Returns installation mode for an extension. | 91 // Returns installation mode for an extension. |
| 92 InstallationMode GetInstallationMode(const Extension* extension) const; | 92 InstallationMode GetInstallationMode(const Extension* extension) const; |
| 93 | 93 |
| 94 // Returns the force install list, in format specified by | 94 // Returns the force install list, in format specified by |
| 95 // ExternalPolicyLoader::AddExtension(). | 95 // ExternalPolicyLoader::AddExtension(). |
| 96 scoped_ptr<base::DictionaryValue> GetForceInstallList() const; | 96 std::unique_ptr<base::DictionaryValue> GetForceInstallList() const; |
| 97 | 97 |
| 98 // Like GetForceInstallList(), but returns recommended install list instead. | 98 // Like GetForceInstallList(), but returns recommended install list instead. |
| 99 scoped_ptr<base::DictionaryValue> GetRecommendedInstallList() const; | 99 std::unique_ptr<base::DictionaryValue> GetRecommendedInstallList() const; |
| 100 | 100 |
| 101 // Returns if an extension with id |id| is explicitly allowed by enterprise | 101 // Returns if an extension with id |id| is explicitly allowed by enterprise |
| 102 // policy or not. | 102 // policy or not. |
| 103 bool IsInstallationExplicitlyAllowed(const ExtensionId& id) const; | 103 bool IsInstallationExplicitlyAllowed(const ExtensionId& id) const; |
| 104 | 104 |
| 105 // Returns true if an extension download should be allowed to proceed. | 105 // Returns true if an extension download should be allowed to proceed. |
| 106 bool IsOffstoreInstallAllowed(const GURL& url, | 106 bool IsOffstoreInstallAllowed(const GURL& url, |
| 107 const GURL& referrer_url) const; | 107 const GURL& referrer_url) const; |
| 108 | 108 |
| 109 // Returns true if an extension with manifest type |manifest_type| is | 109 // Returns true if an extension with manifest type |manifest_type| is |
| 110 // allowed to be installed. | 110 // allowed to be installed. |
| 111 bool IsAllowedManifestType(Manifest::Type manifest_type) const; | 111 bool IsAllowedManifestType(Manifest::Type manifest_type) const; |
| 112 | 112 |
| 113 // Returns the list of blocked API permissions for |extension|. | 113 // Returns the list of blocked API permissions for |extension|. |
| 114 APIPermissionSet GetBlockedAPIPermissions(const Extension* extension) const; | 114 APIPermissionSet GetBlockedAPIPermissions(const Extension* extension) const; |
| 115 | 115 |
| 116 // Returns blocked permission set for |extension|. | 116 // Returns blocked permission set for |extension|. |
| 117 scoped_ptr<const PermissionSet> GetBlockedPermissions( | 117 std::unique_ptr<const PermissionSet> GetBlockedPermissions( |
| 118 const Extension* extension) const; | 118 const Extension* extension) const; |
| 119 | 119 |
| 120 // Returns true if every permission in |perms| is allowed for |extension|. | 120 // Returns true if every permission in |perms| is allowed for |extension|. |
| 121 bool IsPermissionSetAllowed(const Extension* extension, | 121 bool IsPermissionSetAllowed(const Extension* extension, |
| 122 const PermissionSet& perms) const; | 122 const PermissionSet& perms) const; |
| 123 | 123 |
| 124 // Returns true if |extension| meets the minimum required version set for it. | 124 // Returns true if |extension| meets the minimum required version set for it. |
| 125 // If there is no such requirement set for it, returns true as well. | 125 // If there is no such requirement set for it, returns true as well. |
| 126 // If false is returned and |required_version| is not null, the minimum | 126 // If false is returned and |required_version| is not null, the minimum |
| 127 // required version is returned. | 127 // required version is returned. |
| 128 bool CheckMinimumVersion(const Extension* extension, | 128 bool CheckMinimumVersion(const Extension* extension, |
| 129 std::string* required_version) const; | 129 std::string* required_version) const; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 typedef base::ScopedPtrHashMap<ExtensionId, | 132 typedef base::ScopedPtrHashMap<ExtensionId, |
| 133 scoped_ptr<internal::IndividualSettings>> | 133 std::unique_ptr<internal::IndividualSettings>> |
| 134 SettingsIdMap; | 134 SettingsIdMap; |
| 135 typedef base::ScopedPtrHashMap<std::string, | 135 typedef base::ScopedPtrHashMap<std::string, |
| 136 scoped_ptr<internal::IndividualSettings>> | 136 std::unique_ptr<internal::IndividualSettings>> |
| 137 SettingsUpdateUrlMap; | 137 SettingsUpdateUrlMap; |
| 138 friend class ExtensionManagementServiceTest; | 138 friend class ExtensionManagementServiceTest; |
| 139 | 139 |
| 140 // Load all extension management preferences from |pref_service|, and | 140 // Load all extension management preferences from |pref_service|, and |
| 141 // refresh the settings. | 141 // refresh the settings. |
| 142 void Refresh(); | 142 void Refresh(); |
| 143 | 143 |
| 144 // Load preference with name |pref_name| and expected type |expected_type|. | 144 // Load preference with name |pref_name| and expected type |expected_type|. |
| 145 // If |force_managed| is true, only loading from the managed preference store | 145 // If |force_managed| is true, only loading from the managed preference store |
| 146 // is allowed. Returns NULL if the preference is not present, not allowed to | 146 // is allowed. Returns NULL if the preference is not present, not allowed to |
| (...skipping 23 matching lines...) Expand all Loading... |
| 170 // extensions with same update URL. The update url itself is used as index | 170 // extensions with same update URL. The update url itself is used as index |
| 171 // key for the map. | 171 // key for the map. |
| 172 SettingsUpdateUrlMap settings_by_update_url_; | 172 SettingsUpdateUrlMap settings_by_update_url_; |
| 173 | 173 |
| 174 // The default IndividualSettings. | 174 // The default IndividualSettings. |
| 175 // For extension settings applied to an individual extension (identified by | 175 // For extension settings applied to an individual extension (identified by |
| 176 // extension ID) or a group of extension (with specified extension update | 176 // extension ID) or a group of extension (with specified extension update |
| 177 // URL), all unspecified part will take value from |default_settings_|. | 177 // URL), all unspecified part will take value from |default_settings_|. |
| 178 // For all other extensions, all settings from |default_settings_| will be | 178 // For all other extensions, all settings from |default_settings_| will be |
| 179 // enforced. | 179 // enforced. |
| 180 scoped_ptr<internal::IndividualSettings> default_settings_; | 180 std::unique_ptr<internal::IndividualSettings> default_settings_; |
| 181 | 181 |
| 182 // Extension settings applicable to all extensions. | 182 // Extension settings applicable to all extensions. |
| 183 scoped_ptr<internal::GlobalSettings> global_settings_; | 183 std::unique_ptr<internal::GlobalSettings> global_settings_; |
| 184 | 184 |
| 185 PrefService* pref_service_; | 185 PrefService* pref_service_; |
| 186 | 186 |
| 187 base::ObserverList<Observer, true> observer_list_; | 187 base::ObserverList<Observer, true> observer_list_; |
| 188 PrefChangeRegistrar pref_change_registrar_; | 188 PrefChangeRegistrar pref_change_registrar_; |
| 189 ScopedVector<ManagementPolicy::Provider> providers_; | 189 ScopedVector<ManagementPolicy::Provider> providers_; |
| 190 | 190 |
| 191 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); | 191 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); |
| 192 }; | 192 }; |
| 193 | 193 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 210 content::BrowserContext* context) const override; | 210 content::BrowserContext* context) const override; |
| 211 void RegisterProfilePrefs( | 211 void RegisterProfilePrefs( |
| 212 user_prefs::PrefRegistrySyncable* registry) override; | 212 user_prefs::PrefRegistrySyncable* registry) override; |
| 213 | 213 |
| 214 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); | 214 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 } // namespace extensions | 217 } // namespace extensions |
| 218 | 218 |
| 219 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 219 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
| OLD | NEW |