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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 void OnExtensionUninstalled(const std::string& extension_id, | 121 void OnExtensionUninstalled(const std::string& extension_id, |
| 122 const Extension::Location& location, | 122 const Extension::Location& location, |
| 123 bool external_uninstall); | 123 bool external_uninstall); |
| 124 | 124 |
| 125 // Called to change the extension's state when it is enabled/disabled. | 125 // Called to change the extension's state when it is enabled/disabled. |
| 126 void SetExtensionState(const std::string& extension_id, Extension::State); | 126 void SetExtensionState(const std::string& extension_id, Extension::State); |
| 127 | 127 |
| 128 // Returns all installed extensions | 128 // Returns all installed extensions |
| 129 void GetExtensions(ExtensionIdSet* out); | 129 void GetExtensions(ExtensionIdSet* out); |
| 130 | 130 |
| 131 // Returns all installed extensions from |extension_prefs|. This is exposed | 131 // Returns all installed extensions from extension preferences provided by |
| 132 // for ProtectedPrefsWatcher because it needs access to the extension ID list | 132 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs |
| 133 // before the ExtensionService is initialized. | 133 // access to the extension ID list before the ExtensionService is initialized. |
| 134 static ExtensionIdSet GetExtensionsFrom( | 134 static ExtensionIdSet GetExtensionsFrom(const PrefService* pref_service); |
| 135 const base::DictionaryValue* extension_prefs); | |
| 136 | 135 |
| 137 // Getter and setter for browser action visibility. | 136 // Getter and setter for browser action visibility. |
| 138 bool GetBrowserActionVisibility(const Extension* extension); | 137 bool GetBrowserActionVisibility(const Extension* extension); |
| 139 void SetBrowserActionVisibility(const Extension* extension, | 138 void SetBrowserActionVisibility(const Extension* extension, |
| 140 bool visible); | 139 bool visible); |
| 141 | 140 |
| 142 // Did the extension ask to escalate its permission during an upgrade? | 141 // Did the extension ask to escalate its permission during an upgrade? |
| 143 bool DidExtensionEscalatePermissions(const std::string& id); | 142 bool DidExtensionEscalatePermissions(const std::string& id); |
| 144 | 143 |
| 145 // 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 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 166 // 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. |
| 167 FilePath GetExtensionPath(const std::string& extension_id); | 166 FilePath GetExtensionPath(const std::string& extension_id); |
| 168 | 167 |
| 169 // Returns base extensions install directory. | 168 // Returns base extensions install directory. |
| 170 const FilePath& install_directory() const { return install_directory_; } | 169 const FilePath& install_directory() const { return install_directory_; } |
| 171 | 170 |
| 172 // Updates the prefs based on the blacklist. | 171 // Updates the prefs based on the blacklist. |
| 173 void UpdateBlacklist(const std::set<std::string>& blacklist_set); | 172 void UpdateBlacklist(const std::set<std::string>& blacklist_set); |
| 174 | 173 |
| 175 // Based on extension id, checks prefs to see if it is blacklisted. | 174 // Based on extension id, checks prefs to see if it is blacklisted. |
| 176 bool IsExtensionBlacklisted(const std::string& id); | 175 bool IsExtensionBlacklisted(const std::string& id) const; |
| 176 | |
| 177 // Same as above, but can be called when no class instance is available. | |
| 178 static bool IsExtensionBlacklisted(const std::string& extension_id, | |
|
Matt Perry
2012/08/07 19:50:04
static methods should all be before non-static. yo
qfel
2012/08/13 16:03:01
Done.
Is this some kind of extension-code-specifi
| |
| 179 const PrefService* pref_service); | |
| 177 | 180 |
| 178 // Based on extension id, checks prefs to see if it is orphaned. | 181 // Based on extension id, checks prefs to see if it is orphaned. |
| 179 bool IsExtensionOrphaned(const std::string& id); | 182 bool IsExtensionOrphaned(const std::string& id); |
| 180 | 183 |
| 181 // Whether the user has acknowledged an external extension. | 184 // Whether the user has acknowledged an external extension. |
| 182 bool IsExternalExtensionAcknowledged(const std::string& extension_id); | 185 bool IsExternalExtensionAcknowledged(const std::string& extension_id); |
| 183 void AcknowledgeExternalExtension(const std::string& extension_id); | 186 void AcknowledgeExternalExtension(const std::string& extension_id); |
| 184 | 187 |
| 185 // Whether the user has acknowledged a blacklisted extension. | 188 // Whether the user has acknowledged a blacklisted extension. |
| 186 bool IsBlacklistedExtensionAcknowledged(const std::string& extension_id); | 189 bool IsBlacklistedExtensionAcknowledged(const std::string& extension_id); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 std::string* out_value) const OVERRIDE; | 484 std::string* out_value) const OVERRIDE; |
| 482 | 485 |
| 483 // Converts absolute paths in the pref to paths relative to the | 486 // Converts absolute paths in the pref to paths relative to the |
| 484 // install_directory_. | 487 // install_directory_. |
| 485 void MakePathsRelative(); | 488 void MakePathsRelative(); |
| 486 | 489 |
| 487 // Converts internal relative paths to be absolute. Used for export to | 490 // Converts internal relative paths to be absolute. Used for export to |
| 488 // consumers who expect full paths. | 491 // consumers who expect full paths. |
| 489 void MakePathsAbsolute(base::DictionaryValue* dict); | 492 void MakePathsAbsolute(base::DictionaryValue* dict); |
| 490 | 493 |
| 491 // Reads a boolean pref from |ext| with key |pref_key|. | |
| 492 // Return false if the value is false or |pref_key| does not exist. | |
| 493 static bool ReadBooleanFromPref(const base::DictionaryValue* ext, | |
| 494 const std::string& pref_key); | |
| 495 | |
| 496 // Reads an integer pref from |ext| with key |pref_key|. | |
| 497 // Return false if the value does not exist. | |
| 498 static bool ReadIntegerFromPref(const base::DictionaryValue* ext, | |
| 499 const std::string& pref_key, | |
| 500 int* out_value); | |
| 501 | |
| 502 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a | 494 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a |
| 503 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. | 495 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. |
| 504 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, | 496 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, |
| 505 const std::string& pref_key, | 497 const std::string& pref_key, |
| 506 URLPatternSet* result, | 498 URLPatternSet* result, |
| 507 int valid_schemes); | 499 int valid_schemes); |
| 508 | 500 |
| 509 // Converts |new_value| to a list of strings and sets the |pref_key| pref | 501 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
| 510 // belonging to |extension_id|. | 502 // belonging to |extension_id|. |
| 511 void SetExtensionPrefURLPatternSet(const std::string& extension_id, | 503 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 525 | 517 |
| 526 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't | 518 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't |
| 527 // exist. | 519 // exist. |
| 528 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; | 520 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; |
| 529 | 521 |
| 530 // Loads the preferences controlled by the specified extension from their | 522 // Loads the preferences controlled by the specified extension from their |
| 531 // dictionary and sets them in the |pref_value_map_|. | 523 // dictionary and sets them in the |pref_value_map_|. |
| 532 void LoadExtensionControlledPrefs(const std::string& id, | 524 void LoadExtensionControlledPrefs(const std::string& id, |
| 533 ExtensionPrefsScope scope); | 525 ExtensionPrefsScope scope); |
| 534 | 526 |
| 535 // Checks if kPrefBlacklist is set to true in the DictionaryValue. | |
| 536 // Return false if the value is false or kPrefBlacklist does not exist. | |
| 537 // This is used to decide if an extension is blacklisted. | |
| 538 static bool IsBlacklistBitSet(const base::DictionaryValue* ext); | |
| 539 | |
| 540 // Fix missing preference entries in the extensions that are were introduced | 527 // Fix missing preference entries in the extensions that are were introduced |
| 541 // in a later Chrome version. | 528 // in a later Chrome version. |
| 542 void FixMissingPrefs(const ExtensionIdSet& extension_ids); | 529 void FixMissingPrefs(const ExtensionIdSet& extension_ids); |
| 543 | 530 |
| 544 // Installs the persistent extension preferences into |prefs_|'s extension | 531 // Installs the persistent extension preferences into |prefs_|'s extension |
| 545 // pref store. Does nothing if |extensions_disabled| is true. | 532 // pref store. Does nothing if |extensions_disabled| is true. |
| 546 void InitPrefStore(bool extensions_disabled); | 533 void InitPrefStore(bool extensions_disabled); |
| 547 | 534 |
| 548 // Migrates the permissions data in the pref store. | 535 // Migrates the permissions data in the pref store. |
| 549 void MigratePermissions(const ExtensionIdSet& extension_ids); | 536 void MigratePermissions(const ExtensionIdSet& extension_ids); |
| 550 | 537 |
| 551 // Checks whether there is a state pref for the extension and if so, whether | 538 // Checks whether there is a state pref for the extension and if so, whether |
| 552 // it matches |check_state|. | 539 // it matches |check_state|. |
| 553 bool DoesExtensionHaveState(const std::string& id, | 540 bool DoesExtensionHaveState(const std::string& id, |
| 554 Extension::State check_state) const; | 541 Extension::State check_state) const; |
| 555 | 542 |
| 543 // Helper function for GetInstalledExtensionInfo and | |
| 544 // GetInstalledExtensionsInfo. | |
| 545 ExtensionInfo* GetInstalledExtensionInfoImpl( | |
| 546 DictionaryValue* extension_data, | |
| 547 DictionaryValue::key_iterator extension_id) const; | |
| 548 | |
| 556 // The pref service specific to this set of extension prefs. Owned by profile. | 549 // The pref service specific to this set of extension prefs. Owned by profile. |
| 557 PrefService* prefs_; | 550 PrefService* prefs_; |
| 558 | 551 |
| 559 // Base extensions install directory. | 552 // Base extensions install directory. |
| 560 FilePath install_directory_; | 553 FilePath install_directory_; |
| 561 | 554 |
| 562 // Weak pointer, owned by Profile. | 555 // Weak pointer, owned by Profile. |
| 563 ExtensionPrefValueMap* extension_pref_value_map_; | 556 ExtensionPrefValueMap* extension_pref_value_map_; |
| 564 | 557 |
| 565 // Contains all the logic for handling the order for various extension | 558 // Contains all the logic for handling the order for various extension |
| 566 // properties. | 559 // properties. |
| 567 scoped_ptr<ExtensionSorting> extension_sorting_; | 560 scoped_ptr<ExtensionSorting> extension_sorting_; |
| 568 | 561 |
| 569 scoped_refptr<ContentSettingsStore> content_settings_store_; | 562 scoped_refptr<ContentSettingsStore> content_settings_store_; |
| 570 | 563 |
| 571 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 564 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 572 }; | 565 }; |
| 573 | 566 |
| 574 } // namespace extensions | 567 } // namespace extensions |
| 575 | 568 |
| 576 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 569 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |