Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/browser/extensions/extension_prefs.h

Issue 10382149: Refactor the various ways to control what users can do to extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments from partial review Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
Aaron Boodman 2012/05/29 03:03:08 I would really prefer this be a separate helper cl
210 // whitelist and blacklist). 212 virtual std::string GetPolicyProviderName() const OVERRIDE;
211 bool IsExtensionAllowedByPolicy(const std::string& extension_id, 213 // Returns true if the extension is allowed by admin policy white- and
212 extensions::Extension::Location location) const; 214 // blacklists.
215 virtual bool UserMayLoad(const extensions::Extension* extension,
216 string16* error) const OVERRIDE;
217 // Returns false if the extension is required to remain running, as determined
218 // by Extension::IsRequired(). In practice this enforces the admin policy
219 // forcelist.
220 virtual bool UserMayModifySettings(const extensions::Extension* extension,
221 string16* error) const OVERRIDE;
222 // Returns true if the extension is required to remain running, as determined
223 // by Extension::IsRequired(). In practice this enforces the admin policy
224 // forcelist.
225 virtual bool MustRemainEnabled(const extensions::Extension* extension,
226 string16* error) const OVERRIDE;
213 227
214 // Checks if extensions are blacklisted by default, by policy. When true, this 228 // 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. 229 // means that even extensions without an ID should be blacklisted (e.g.
216 // from the command line, or when loaded as an unpacked extension). 230 // from the command line, or when loaded as an unpacked extension).
217 // IsExtensionAllowedByPolicy() also takes this into account, and should be 231 // IsExtensionAllowedByPolicy() also takes this into account, and should be
218 // used instead when the extension ID is known. 232 // used instead when the extension ID is known.
219 bool ExtensionsBlacklistedByDefault() const; 233 bool ExtensionsBlacklistedByDefault() const;
220 234
221 // Returns the last value set via SetLastPingDay. If there isn't such a 235 // Returns the last value set via SetLastPingDay. If there isn't such a
222 // pref, the returned Time will return true for is_null(). 236 // pref, the returned Time will return true for is_null().
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // exist. 515 // exist.
502 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; 516 const base::DictionaryValue* GetExtensionPref(const std::string& id) const;
503 517
504 // Returns the dictionary of preferences controlled by the specified extension 518 // Returns the dictionary of preferences controlled by the specified extension
505 // or creates a new one. All entries in the dictionary contain non-expanded 519 // or creates a new one. All entries in the dictionary contain non-expanded
506 // paths. 520 // paths.
507 const base::DictionaryValue* GetExtensionControlledPrefs( 521 const base::DictionaryValue* GetExtensionControlledPrefs(
508 const std::string& id, 522 const std::string& id,
509 bool incognito) const; 523 bool incognito) const;
510 524
525 // Internal implementation for certain ManagementPolicy::Delegate methods.
526 // Returns |modifiable_value| if the extension can be modified.
527 bool ManagementPolicyImpl(const extensions::Extension* extension,
528 string16* error,
529 bool modifiable_value) const;
530
511 // Checks if kPrefBlacklist is set to true in the DictionaryValue. 531 // Checks if kPrefBlacklist is set to true in the DictionaryValue.
512 // Return false if the value is false or kPrefBlacklist does not exist. 532 // Return false if the value is false or kPrefBlacklist does not exist.
513 // This is used to decide if an extension is blacklisted. 533 // This is used to decide if an extension is blacklisted.
514 static bool IsBlacklistBitSet(base::DictionaryValue* ext); 534 static bool IsBlacklistBitSet(base::DictionaryValue* ext);
515 535
516 // Fix missing preference entries in the extensions that are were introduced 536 // Fix missing preference entries in the extensions that are were introduced
517 // in a later Chrome version. 537 // in a later Chrome version.
518 void FixMissingPrefs(const ExtensionIdSet& extension_ids); 538 void FixMissingPrefs(const ExtensionIdSet& extension_ids);
519 539
520 // Installs the persistent extension preferences into |prefs_|'s extension 540 // Installs the persistent extension preferences into |prefs_|'s extension
(...skipping 20 matching lines...) Expand all
541 // Contains all the logic for handling the order for various extension 561 // Contains all the logic for handling the order for various extension
542 // properties. 562 // properties.
543 scoped_ptr<ExtensionSorting> extension_sorting_; 563 scoped_ptr<ExtensionSorting> extension_sorting_;
544 564
545 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_; 565 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_;
546 566
547 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 567 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
548 }; 568 };
549 569
550 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 570 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698