OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Sets the order that toolstrip URLs appear in the shelf. | 99 // Sets the order that toolstrip URLs appear in the shelf. |
100 void SetShelfToolstripOrder(const URLList& urls); | 100 void SetShelfToolstripOrder(const URLList& urls); |
101 | 101 |
102 // Get the order that the browser actions appear in the toolbar. | 102 // Get the order that the browser actions appear in the toolbar. |
103 std::vector<std::string> GetToolbarOrder(); | 103 std::vector<std::string> GetToolbarOrder(); |
104 | 104 |
105 // Set the order that the browser actions appear in the toolbar. | 105 // Set the order that the browser actions appear in the toolbar. |
106 void SetToolbarOrder(const std::vector<std::string>& extension_ids); | 106 void SetToolbarOrder(const std::vector<std::string>& extension_ids); |
107 | 107 |
108 // Called when an extension is installed, so that prefs get created. | 108 // Called when an extension is installed, so that prefs get created. |
109 // If |page_index| is -1, and the then a page will be found for the App. | 109 // If |page_index| is kUnsetIndex, and the then a page will be found |
| 110 // for the App. |
110 void OnExtensionInstalled(const Extension* extension, | 111 void OnExtensionInstalled(const Extension* extension, |
111 Extension::State initial_state, | 112 Extension::State initial_state, |
112 bool from_webstore, | 113 bool from_webstore, |
113 int page_index); | 114 std::string page_index); |
114 | 115 |
115 // Called when an extension is uninstalled, so that prefs get cleaned up. | 116 // Called when an extension is uninstalled, so that prefs get cleaned up. |
116 void OnExtensionUninstalled(const std::string& extension_id, | 117 void OnExtensionUninstalled(const std::string& extension_id, |
117 const Extension::Location& location, | 118 const Extension::Location& location, |
118 bool external_uninstall); | 119 bool external_uninstall); |
119 | 120 |
120 // Called to change the extension's state when it is enabled/disabled. | 121 // Called to change the extension's state when it is enabled/disabled. |
121 void SetExtensionState(const std::string& extension_id, Extension::State); | 122 void SetExtensionState(const std::string& extension_id, Extension::State); |
122 | 123 |
123 // Returns all installed extensions | 124 // Returns all installed extensions |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // purchase is made, so that when a user logs into sync with a different | 267 // purchase is made, so that when a user logs into sync with a different |
267 // account we can recognize the situation. The Get function returns true if | 268 // account we can recognize the situation. The Get function returns true if |
268 // there was previously stored data (placing it in |result|), or false | 269 // there was previously stored data (placing it in |result|), or false |
269 // otherwise. The Set will overwrite any previous login. | 270 // otherwise. The Set will overwrite any previous login. |
270 bool GetWebStoreLogin(std::string* result); | 271 bool GetWebStoreLogin(std::string* result); |
271 void SetWebStoreLogin(const std::string& login); | 272 void SetWebStoreLogin(const std::string& login); |
272 | 273 |
273 // Get the application launch index for an extension with |extension_id|. This | 274 // Get the application launch index for an extension with |extension_id|. This |
274 // determines the order of which the applications appear on the New Tab Page. | 275 // determines the order of which the applications appear on the New Tab Page. |
275 // A value of 0 generally indicates top left. If the extension has no launch | 276 // A value of 0 generally indicates top left. If the extension has no launch |
276 // index a -1 value is returned. | 277 // index a kUnsetIndex value is returned. |
277 int GetAppLaunchIndex(const std::string& extension_id); | 278 std::string GetAppLaunchIndex(const std::string& extension_id); |
278 | 279 |
279 // Sets a specific launch index for an extension with |extension_id|. | 280 // Sets a specific launch index for an extension with |extension_id|. |
280 void SetAppLaunchIndex(const std::string& extension_id, int index); | 281 void SetAppLaunchIndex(const std::string& extension_id, |
| 282 const std::string& index); |
281 | 283 |
282 // Gets the next available application launch index. This is 1 higher than the | 284 // Gets the next available application launch index. This is 1 higher than the |
283 // highest current application launch index found for the page |on_page|. | 285 // highest current application launch index found for the page |on_page|. |
284 int GetNextAppLaunchIndex(int on_page); | 286 std::string GetNextAppLaunchIndex(std::string on_page); |
285 | 287 |
286 // Gets the page a new app should install to. Starts on page 0, and if there | 288 // Gets the page a new app should install to. Starts on page 0, and if there |
287 // are N or more apps on it, tries to install on the next page. | 289 // are N or more apps on it, tries to install on the next page. |
288 int GetNaturalAppPageIndex(); | 290 std::string GetNaturalAppPageIndex(); |
289 | 291 |
290 // Sets the order the apps should be displayed in the app launcher. | 292 // Sets the order the apps should be displayed in the app launcher. |
291 void SetAppLauncherOrder(const std::vector<std::string>& extension_ids); | 293 void SetAppLauncherOrder(const std::vector<std::string>& extension_ids); |
292 | 294 |
293 // Get the application page index for an extension with |extension_id|. This | 295 // Get the application page index for an extension with |extension_id|. This |
294 // determines which page an app will appear on in page-based NTPs. If | 296 // determines which page an app will appear on in page-based NTPs. If |
295 // the app has no page specified, -1 is returned. | 297 // the app has no page specified, kUnsetIndex is returned. |
296 int GetPageIndex(const std::string& extension_id); | 298 std::string GetPageIndex(const std::string& extension_id); |
297 | 299 |
298 // Sets a specific page index for an extension with |extension_id|. | 300 // Sets a specific page index for an extension with |extension_id|. |
299 void SetPageIndex(const std::string& extension_id, int index); | 301 void SetPageIndex(const std::string& extension_id, |
| 302 const std::string& index); |
300 | 303 |
301 // Returns true if the user repositioned the app on the app launcher via drag | 304 // Returns true if the user repositioned the app on the app launcher via drag |
302 // and drop. | 305 // and drop. |
303 bool WasAppDraggedByUser(const std::string& extension_id); | 306 bool WasAppDraggedByUser(const std::string& extension_id); |
304 | 307 |
305 // Sets a flag indicating that the user repositioned the app on the app | 308 // Sets a flag indicating that the user repositioned the app on the app |
306 // launcher by drag and dropping it. | 309 // launcher by drag and dropping it. |
307 void SetAppDraggedByUser(const std::string& extension_id); | 310 void SetAppDraggedByUser(const std::string& extension_id); |
308 | 311 |
309 // The extension's update URL data. If not empty, the ExtensionUpdater | 312 // The extension's update URL data. If not empty, the ExtensionUpdater |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // Reads an integer pref |pref_key| from extension with id |extension_id|. | 416 // Reads an integer pref |pref_key| from extension with id |extension_id|. |
414 bool ReadExtensionPrefInteger(const std::string& extension_id, | 417 bool ReadExtensionPrefInteger(const std::string& extension_id, |
415 const std::string& pref_key, | 418 const std::string& pref_key, |
416 int* out_value); | 419 int* out_value); |
417 | 420 |
418 // Reads a list pref |pref_key| from extension with id |extension_id|. | 421 // Reads a list pref |pref_key| from extension with id |extension_id|. |
419 bool ReadExtensionPrefList(const std::string& extension_id, | 422 bool ReadExtensionPrefList(const std::string& extension_id, |
420 const std::string& pref_key, | 423 const std::string& pref_key, |
421 const base::ListValue** out_value); | 424 const base::ListValue** out_value); |
422 | 425 |
| 426 // Reads a string pref |pref_key| from extension with id |extension_id| |
| 427 bool ReadExtensionPrefString(const std::string& extension_id, |
| 428 const std::string& pref_key, |
| 429 std::string* out_value); |
| 430 |
423 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a | 431 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a |
424 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. | 432 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. |
425 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, | 433 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, |
426 const std::string& pref_key, | 434 const std::string& pref_key, |
427 URLPatternSet* result, | 435 URLPatternSet* result, |
428 int valid_schemes); | 436 int valid_schemes); |
429 | 437 |
430 // Converts |new_value| to a list of strings and sets the |pref_key| pref | 438 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
431 // belonging to |extension_id|. | 439 // belonging to |extension_id|. |
432 void SetExtensionPrefURLPatternSet(const std::string& extension_id, | 440 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // in a later Chrome version. | 478 // in a later Chrome version. |
471 void FixMissingPrefs(const ExtensionIdSet& extension_ids); | 479 void FixMissingPrefs(const ExtensionIdSet& extension_ids); |
472 | 480 |
473 // Installs the persistent extension preferences into |prefs_|'s extension | 481 // Installs the persistent extension preferences into |prefs_|'s extension |
474 // pref store. Does nothing if |extensions_disabled| is true. | 482 // pref store. Does nothing if |extensions_disabled| is true. |
475 void InitPrefStore(bool extensions_disabled); | 483 void InitPrefStore(bool extensions_disabled); |
476 | 484 |
477 // Migrates the permissions data in the pref store. | 485 // Migrates the permissions data in the pref store. |
478 void MigratePermissions(const ExtensionIdSet& extension_ids); | 486 void MigratePermissions(const ExtensionIdSet& extension_ids); |
479 | 487 |
| 488 // Migrates the app launcher and page index values. |
| 489 void MigrateAppIndex(const ExtensionIdSet& extension_ids); |
| 490 |
480 // Checks whether there is a state pref for the extension and if so, whether | 491 // Checks whether there is a state pref for the extension and if so, whether |
481 // it matches |check_state|. | 492 // it matches |check_state|. |
482 bool DoesExtensionHaveState(const std::string& id, | 493 bool DoesExtensionHaveState(const std::string& id, |
483 Extension::State check_state) const; | 494 Extension::State check_state) const; |
484 | 495 |
485 // The pref service specific to this set of extension prefs. Owned by profile. | 496 // The pref service specific to this set of extension prefs. Owned by profile. |
486 PrefService* prefs_; | 497 PrefService* prefs_; |
487 | 498 |
488 // Base extensions install directory. | 499 // Base extensions install directory. |
489 FilePath install_directory_; | 500 FilePath install_directory_; |
490 | 501 |
491 // Weak pointer, owned by Profile. | 502 // Weak pointer, owned by Profile. |
492 ExtensionPrefValueMap* extension_pref_value_map_; | 503 ExtensionPrefValueMap* extension_pref_value_map_; |
493 | 504 |
494 scoped_refptr<ExtensionContentSettingsStore> content_settings_store_; | 505 scoped_refptr<ExtensionContentSettingsStore> content_settings_store_; |
495 | 506 |
496 // The URLs of all of the toolstrips. | 507 // The URLs of all of the toolstrips. |
497 URLList shelf_order_; | 508 URLList shelf_order_; |
498 | 509 |
499 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 510 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
500 }; | 511 }; |
501 | 512 |
502 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 513 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
OLD | NEW |