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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 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
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>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // PrefValueStore::extension_prefs(), which this class populates and 45 // PrefValueStore::extension_prefs(), which this class populates and
46 // maintains as the underlying extensions change. 46 // maintains as the underlying extensions change.
47 class ExtensionPrefs : public extensions::ContentSettingsStore::Observer, 47 class ExtensionPrefs : public extensions::ContentSettingsStore::Observer,
48 public ExtensionScopedPrefs { 48 public ExtensionScopedPrefs {
49 public: 49 public:
50 // Key name for a preference that keeps track of per-extension settings. This 50 // 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 51 // is a dictionary object read from the Preferences file, keyed off of
52 // extension ids. 52 // extension ids.
53 static const char kExtensionsPref[]; 53 static const char kExtensionsPref[];
54 54
55 typedef std::vector<linked_ptr<ExtensionInfo> > ExtensionsInfo; 55 typedef std::vector<linked_ptr<extensions::ExtensionInfo> > ExtensionsInfo;
56 56
57 // Vector containing identifiers for preferences. 57 // Vector containing identifiers for preferences.
58 typedef std::set<std::string> PrefKeySet; 58 typedef std::set<std::string> PrefKeySet;
59 59
60 // Vector containing identifiers for extensions. 60 // Vector containing identifiers for extensions.
61 typedef std::vector<std::string> ExtensionIdSet; 61 typedef std::vector<std::string> ExtensionIdSet;
62 62
63 // This enum is used for the launch type the user wants to use for an 63 // This enum is used for the launch type the user wants to use for an
64 // application. 64 // application.
65 // Do not remove items or re-order this enum as it is used in preferences 65 // Do not remove items or re-order this enum as it is used in preferences
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Get the order that the browser actions appear in the toolbar. 104 // Get the order that the browser actions appear in the toolbar.
105 std::vector<std::string> GetToolbarOrder(); 105 std::vector<std::string> GetToolbarOrder();
106 106
107 // Set the order that the browser actions appear in the toolbar. 107 // Set the order that the browser actions appear in the toolbar.
108 void SetToolbarOrder(const std::vector<std::string>& extension_ids); 108 void SetToolbarOrder(const std::vector<std::string>& extension_ids);
109 109
110 // Called when an extension is installed, so that prefs get created. 110 // Called when an extension is installed, so that prefs get created.
111 // If |page_ordinal| is an invalid ordinal, then a page will be found 111 // If |page_ordinal| is an invalid ordinal, then a page will be found
112 // for the App. 112 // for the App.
113 void OnExtensionInstalled(const Extension* extension, 113 void OnExtensionInstalled(const extensions::Extension* extension,
114 Extension::State initial_state, 114 extensions::Extension::State initial_state,
115 bool from_webstore, 115 bool from_webstore,
116 const StringOrdinal& page_ordinal); 116 const StringOrdinal& page_ordinal);
117 117
118 // Called when an extension is uninstalled, so that prefs get cleaned up. 118 // Called when an extension is uninstalled, so that prefs get cleaned up.
119 void OnExtensionUninstalled(const std::string& extension_id, 119 void OnExtensionUninstalled(const std::string& extension_id,
120 const Extension::Location& location, 120 const extensions::Extension::Location& location,
121 bool external_uninstall); 121 bool external_uninstall);
122 122
123 // Called to change the extension's state when it is enabled/disabled. 123 // Called to change the extension's state when it is enabled/disabled.
124 void SetExtensionState(const std::string& extension_id, Extension::State); 124 void SetExtensionState(const std::string& extension_id,
125 extensions::Extension::State);
125 126
126 // Returns all installed extensions 127 // Returns all installed extensions
127 void GetExtensions(ExtensionIdSet* out); 128 void GetExtensions(ExtensionIdSet* out);
128 129
129 // Returns all installed extensions from |extension_prefs|. This is exposed 130 // Returns all installed extensions from |extension_prefs|. This is exposed
130 // for ProtectedPrefsWatcher because it needs access to the extension ID list 131 // for ProtectedPrefsWatcher because it needs access to the extension ID list
131 // before the ExtensionService is initialized. 132 // before the ExtensionService is initialized.
132 static ExtensionIdSet GetExtensionsFrom( 133 static ExtensionIdSet GetExtensionsFrom(
133 const base::DictionaryValue* extension_prefs); 134 const base::DictionaryValue* extension_prefs);
134 135
135 // Getter and setter for browser action visibility. 136 // Getter and setter for browser action visibility.
136 bool GetBrowserActionVisibility(const Extension* extension); 137 bool GetBrowserActionVisibility(const extensions::Extension* extension);
137 void SetBrowserActionVisibility(const Extension* extension, bool visible); 138 void SetBrowserActionVisibility(const extensions::Extension* extension,
139 bool visible);
138 140
139 // Did the extension ask to escalate its permission during an upgrade? 141 // Did the extension ask to escalate its permission during an upgrade?
140 bool DidExtensionEscalatePermissions(const std::string& id); 142 bool DidExtensionEscalatePermissions(const std::string& id);
141 143
142 // If |did_escalate| is true, the preferences for |extension| will be set to 144 // If |did_escalate| is true, the preferences for |extension| will be set to
143 // require the install warning when the user tries to enable. 145 // require the install warning when the user tries to enable.
144 void SetDidExtensionEscalatePermissions(const Extension* extension, 146 void SetDidExtensionEscalatePermissions(
145 bool did_escalate); 147 const extensions::Extension* extension,
148 bool did_escalate);
146 149
147 // Getter and setters for disabled reason. 150 // Getter and setters for disabled reason.
148 Extension::DisableReason GetDisableReason(const std::string& extension_id); 151 extensions::Extension::DisableReason GetDisableReason(
152 const std::string& extension_id);
149 void SetDisableReason(const std::string& extension_id, 153 void SetDisableReason(const std::string& extension_id,
150 Extension::DisableReason disable_reason); 154 extensions::Extension::DisableReason disable_reason);
151 void RemoveDisableReason(const std::string& extension_id); 155 void RemoveDisableReason(const std::string& extension_id);
152 156
153 // Returns the version string for the currently installed extension, or 157 // Returns the version string for the currently installed extension, or
154 // the empty string if not found. 158 // the empty string if not found.
155 std::string GetVersionString(const std::string& extension_id); 159 std::string GetVersionString(const std::string& extension_id);
156 160
157 // Re-writes the extension manifest into the prefs. 161 // Re-writes the extension manifest into the prefs.
158 // Called to change the extension's manifest when it's re-localized. 162 // Called to change the extension's manifest when it's re-localized.
159 void UpdateManifest(const Extension* extension); 163 void UpdateManifest(const extensions::Extension* extension);
160 164
161 // Returns extension path based on extension ID, or empty FilePath on error. 165 // Returns extension path based on extension ID, or empty FilePath on error.
162 FilePath GetExtensionPath(const std::string& extension_id); 166 FilePath GetExtensionPath(const std::string& extension_id);
163 167
164 // Returns base extensions install directory. 168 // Returns base extensions install directory.
165 const FilePath& install_directory() const { return install_directory_; } 169 const FilePath& install_directory() const { return install_directory_; }
166 170
167 // Updates the prefs based on the blacklist. 171 // Updates the prefs based on the blacklist.
168 void UpdateBlacklist(const std::set<std::string>& blacklist_set); 172 void UpdateBlacklist(const std::set<std::string>& blacklist_set);
169 173
(...skipping 28 matching lines...) Expand all
198 void SetAppNotificationClientId(const std::string& extension_id, 202 void SetAppNotificationClientId(const std::string& extension_id,
199 const std::string& oauth_client_id); 203 const std::string& oauth_client_id);
200 204
201 // Whether app notifications are disabled for the given app. 205 // Whether app notifications are disabled for the given app.
202 bool IsAppNotificationDisabled(const std::string& extension_id) const; 206 bool IsAppNotificationDisabled(const std::string& extension_id) const;
203 void SetAppNotificationDisabled(const std::string& extension_id, bool value); 207 void SetAppNotificationDisabled(const std::string& extension_id, bool value);
204 208
205 // Is the extension with |extension_id| allowed by policy (checking both 209 // Is the extension with |extension_id| allowed by policy (checking both
206 // whitelist and blacklist). 210 // whitelist and blacklist).
207 bool IsExtensionAllowedByPolicy(const std::string& extension_id, 211 bool IsExtensionAllowedByPolicy(const std::string& extension_id,
208 Extension::Location location) const; 212 extensions::Extension::Location location) const;
209 213
210 // Checks if extensions are blacklisted by default, by policy. When true, this 214 // Checks if extensions are blacklisted by default, by policy. When true, this
211 // means that even extensions without an ID should be blacklisted (e.g. 215 // means that even extensions without an ID should be blacklisted (e.g.
212 // from the command line, or when loaded as an unpacked extension). 216 // from the command line, or when loaded as an unpacked extension).
213 // IsExtensionAllowedByPolicy() also takes this into account, and should be 217 // IsExtensionAllowedByPolicy() also takes this into account, and should be
214 // used instead when the extension ID is known. 218 // used instead when the extension ID is known.
215 bool ExtensionsBlacklistedByDefault() const; 219 bool ExtensionsBlacklistedByDefault() const;
216 220
217 // Returns the last value set via SetLastPingDay. If there isn't such a 221 // Returns the last value set via SetLastPingDay. If there isn't such a
218 // pref, the returned Time will return true for is_null(). 222 // pref, the returned Time will return true for is_null().
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // |default_pref_value|. 298 // |default_pref_value|.
295 LaunchType GetLaunchType(const std::string& extension_id, 299 LaunchType GetLaunchType(const std::string& extension_id,
296 LaunchType default_pref_value); 300 LaunchType default_pref_value);
297 301
298 void SetLaunchType(const std::string& extension_id, LaunchType launch_type); 302 void SetLaunchType(const std::string& extension_id, LaunchType launch_type);
299 303
300 // Find the right launch container based on the launch type. 304 // Find the right launch container based on the launch type.
301 // If |extension|'s prefs do not have a launch type set, then 305 // If |extension|'s prefs do not have a launch type set, then
302 // use |default_pref_value|. 306 // use |default_pref_value|.
303 extension_misc::LaunchContainer GetLaunchContainer( 307 extension_misc::LaunchContainer GetLaunchContainer(
304 const Extension* extension, 308 const extensions::Extension* extension,
305 LaunchType default_pref_value); 309 LaunchType default_pref_value);
306 310
307 // Saves ExtensionInfo for each installed extension with the path to the 311 // Saves ExtensionInfo for each installed extension with the path to the
308 // version directory and the location. Blacklisted extensions won't be saved 312 // version directory and the location. Blacklisted extensions won't be saved
309 // and neither will external extensions the user has explicitly uninstalled. 313 // and neither will external extensions the user has explicitly uninstalled.
310 // Caller takes ownership of returned structure. 314 // Caller takes ownership of returned structure.
311 ExtensionsInfo* GetInstalledExtensionsInfo(); 315 ExtensionsInfo* GetInstalledExtensionsInfo();
312 316
313 // Returns the ExtensionInfo from the prefs for the given extension. If the 317 // Returns the ExtensionInfo from the prefs for the given extension. If the
314 // extension is not present, NULL is returned. 318 // extension is not present, NULL is returned.
315 ExtensionInfo* GetInstalledExtensionInfo(const std::string& extension_id); 319 extensions::ExtensionInfo* GetInstalledExtensionInfo(
320 const std::string& extension_id);
316 321
317 // We've downloaded an updated .crx file for the extension, but are waiting 322 // We've downloaded an updated .crx file for the extension, but are waiting
318 // for idle time to install it. 323 // for idle time to install it.
319 void SetIdleInstallInfo(const std::string& extension_id, 324 void SetIdleInstallInfo(const std::string& extension_id,
320 const FilePath& crx_path, 325 const FilePath& crx_path,
321 const std::string& version, 326 const std::string& version,
322 const base::Time& fetch_time); 327 const base::Time& fetch_time);
323 328
324 // Removes any idle install information we have for the given |extension_id|. 329 // Removes any idle install information we have for the given |extension_id|.
325 // Returns true if there was info to remove; false otherwise. 330 // Returns true if there was info to remove; false otherwise.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 // Installs the persistent extension preferences into |prefs_|'s extension 520 // Installs the persistent extension preferences into |prefs_|'s extension
516 // pref store. Does nothing if |extensions_disabled| is true. 521 // pref store. Does nothing if |extensions_disabled| is true.
517 void InitPrefStore(bool extensions_disabled); 522 void InitPrefStore(bool extensions_disabled);
518 523
519 // Migrates the permissions data in the pref store. 524 // Migrates the permissions data in the pref store.
520 void MigratePermissions(const ExtensionIdSet& extension_ids); 525 void MigratePermissions(const ExtensionIdSet& extension_ids);
521 526
522 // Checks whether there is a state pref for the extension and if so, whether 527 // Checks whether there is a state pref for the extension and if so, whether
523 // it matches |check_state|. 528 // it matches |check_state|.
524 bool DoesExtensionHaveState(const std::string& id, 529 bool DoesExtensionHaveState(const std::string& id,
525 Extension::State check_state) const; 530 extensions::Extension::State check_state) const;
526 531
527 // The pref service specific to this set of extension prefs. Owned by profile. 532 // The pref service specific to this set of extension prefs. Owned by profile.
528 PrefService* prefs_; 533 PrefService* prefs_;
529 534
530 // Base extensions install directory. 535 // Base extensions install directory.
531 FilePath install_directory_; 536 FilePath install_directory_;
532 537
533 // Weak pointer, owned by Profile. 538 // Weak pointer, owned by Profile.
534 ExtensionPrefValueMap* extension_pref_value_map_; 539 ExtensionPrefValueMap* extension_pref_value_map_;
535 540
536 // Contains all the logic for handling the order for various extension 541 // Contains all the logic for handling the order for various extension
537 // properties. 542 // properties.
538 scoped_ptr<ExtensionSorting> extension_sorting_; 543 scoped_ptr<ExtensionSorting> extension_sorting_;
539 544
540 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_; 545 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_;
541 546
542 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 547 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
543 }; 548 };
544 549
545 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 550 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_override_apitest.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698