Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h" | 16 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h" |
| 17 #include "chrome/browser/extensions/extension_prefs_scope.h" | 17 #include "chrome/browser/extensions/extension_prefs_scope.h" |
| 18 #include "chrome/browser/extensions/extension_scoped_prefs.h" | 18 #include "chrome/browser/extensions/extension_scoped_prefs.h" |
| 19 #include "chrome/browser/extensions/management_policy.h" | |
| 19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/string_ordinal.h" | 21 #include "chrome/common/string_ordinal.h" |
| 21 | 22 |
| 22 class ExtensionPrefValueMap; | 23 class ExtensionPrefValueMap; |
| 23 class ExtensionSorting; | 24 class ExtensionSorting; |
| 24 class PrefService; | 25 class PrefService; |
| 25 class URLPatternSet; | 26 class URLPatternSet; |
| 26 | 27 |
| 27 namespace extensions { | 28 namespace extensions { |
| 28 struct AlarmPref; | 29 struct AlarmPref; |
| 29 struct ExtensionOmniboxSuggestion; | 30 struct ExtensionOmniboxSuggestion; |
| 30 } | 31 } |
| 31 | 32 |
| 32 // Class for managing global and per-extension preferences. | 33 // Class for managing global and per-extension preferences. |
| 33 // | 34 // |
| 34 // This class distinguishes the following kinds of preferences: | 35 // This class distinguishes the following kinds of preferences: |
| 35 // - global preferences: | 36 // - global preferences: |
| 36 // internal state for the extension system in general, not associated | 37 // internal state for the extension system in general, not associated |
| 37 // with an individual extension, such as lastUpdateTime. | 38 // with an individual extension, such as lastUpdateTime. |
| 38 // - per-extension preferences: | 39 // - per-extension preferences: |
| 39 // meta-preferences describing properties of the extension like | 40 // meta-preferences describing properties of the extension like |
| 40 // installation time, whether the extension is enabled, etc. | 41 // installation time, whether the extension is enabled, etc. |
| 41 // - extension controlled preferences: | 42 // - extension controlled preferences: |
| 42 // browser preferences that an extension controls. For example, an | 43 // browser preferences that an extension controls. For example, an |
| 43 // extension could use the proxy API to specify the browser's proxy | 44 // extension could use the proxy API to specify the browser's proxy |
| 44 // preference. Extension-controlled preferences are stored in | 45 // preference. Extension-controlled preferences are stored in |
| 45 // PrefValueStore::extension_prefs(), which this class populates and | 46 // PrefValueStore::extension_prefs(), which this class populates and |
| 46 // maintains as the underlying extensions change. | 47 // maintains as the underlying extensions change. |
| 47 class ExtensionPrefs : public extensions::ContentSettingsStore::Observer, | 48 class ExtensionPrefs : public extensions::ContentSettingsStore::Observer, |
| 49 public extensions::ManagementPolicy::Provider, | |
| 48 public ExtensionScopedPrefs { | 50 public ExtensionScopedPrefs { |
| 49 public: | 51 public: |
| 50 // Key name for a preference that keeps track of per-extension settings. This | 52 // Key name for a preference that keeps track of per-extension settings. This |
| 51 // is a dictionary object read from the Preferences file, keyed off of | 53 // is a dictionary object read from the Preferences file, keyed off of |
| 52 // extension ids. | 54 // extension ids. |
| 53 static const char kExtensionsPref[]; | 55 static const char kExtensionsPref[]; |
| 54 | 56 |
| 55 typedef std::vector<linked_ptr<extensions::ExtensionInfo> > ExtensionsInfo; | 57 typedef std::vector<linked_ptr<extensions::ExtensionInfo> > ExtensionsInfo; |
| 56 | 58 |
| 57 // Vector containing identifiers for preferences. | 59 // Vector containing identifiers for preferences. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 | 201 |
| 200 // The oauth client id used for app notification setup, if any. | 202 // The oauth client id used for app notification setup, if any. |
| 201 std::string GetAppNotificationClientId(const std::string& extension_id) const; | 203 std::string GetAppNotificationClientId(const std::string& extension_id) const; |
| 202 void SetAppNotificationClientId(const std::string& extension_id, | 204 void SetAppNotificationClientId(const std::string& extension_id, |
| 203 const std::string& oauth_client_id); | 205 const std::string& oauth_client_id); |
| 204 | 206 |
| 205 // Whether app notifications are disabled for the given app. | 207 // Whether app notifications are disabled for the given app. |
| 206 bool IsAppNotificationDisabled(const std::string& extension_id) const; | 208 bool IsAppNotificationDisabled(const std::string& extension_id) const; |
| 207 void SetAppNotificationDisabled(const std::string& extension_id, bool value); | 209 void SetAppNotificationDisabled(const std::string& extension_id, bool value); |
| 208 | 210 |
| 209 // Is the extension with |extension_id| allowed by policy (checking both | 211 // ManagementPolicy::Provider |
|
Pam (message me for reviews)
2012/05/22 12:51:07
On 2012/05/17 22:41:06, Aaron Boodman wrote:
> We
| |
| 210 // whitelist and blacklist). | 212 virtual std::string PolicyProviderName() const OVERRIDE; |
| 211 bool IsExtensionAllowedByPolicy(const std::string& extension_id, | 213 // Retruns true if the extension is allowed by admin policy. |
|
Aaron Boodman
2012/05/24 08:11:23
sp: Retruns
| |
| 212 extensions::Extension::Location location) const; | 214 virtual bool UserMayLoad(const extensions::Extension* extension, |
|
Pam (message me for reviews)
2012/05/22 12:51:07
I clarified that this particular management policy
Aaron Boodman
2012/05/22 15:56:11
Ah. You could make that more self-documenting and
Pam (message me for reviews)
2012/05/23 15:00:58
How important is this to you? It feels like overco
Aaron Boodman
2012/05/24 08:11:23
Shrug, ok.
| |
| 215 extensions::Extension::Location location, | |
| 216 string16* error) const OVERRIDE; | |
| 213 | 217 |
| 214 // Checks if extensions are blacklisted by default, by policy. When true, this | 218 // Checks if extensions are blacklisted by default, by policy. When true, this |
| 215 // means that even extensions without an ID should be blacklisted (e.g. | 219 // means that even extensions without an ID should be blacklisted (e.g. |
| 216 // from the command line, or when loaded as an unpacked extension). | 220 // from the command line, or when loaded as an unpacked extension). |
| 217 // IsExtensionAllowedByPolicy() also takes this into account, and should be | 221 // IsExtensionAllowedByPolicy() also takes this into account, and should be |
| 218 // used instead when the extension ID is known. | 222 // used instead when the extension ID is known. |
| 219 bool ExtensionsBlacklistedByDefault() const; | 223 bool ExtensionsBlacklistedByDefault() const; |
| 220 | 224 |
| 221 // Returns the last value set via SetLastPingDay. If there isn't such a | 225 // Returns the last value set via SetLastPingDay. If there isn't such a |
| 222 // pref, the returned Time will return true for is_null(). | 226 // pref, the returned Time will return true for is_null(). |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 // Contains all the logic for handling the order for various extension | 545 // Contains all the logic for handling the order for various extension |
| 542 // properties. | 546 // properties. |
| 543 scoped_ptr<ExtensionSorting> extension_sorting_; | 547 scoped_ptr<ExtensionSorting> extension_sorting_; |
| 544 | 548 |
| 545 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_; | 549 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_; |
| 546 | 550 |
| 547 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 551 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 548 }; | 552 }; |
| 549 | 553 |
| 550 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 554 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |