| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 25 matching lines...) Expand all Loading... |
| 36 // Sets the order that toolstrip URLs appear in the shelf. | 36 // Sets the order that toolstrip URLs appear in the shelf. |
| 37 void SetShelfToolstripOrder(const URLList& urls); | 37 void SetShelfToolstripOrder(const URLList& urls); |
| 38 | 38 |
| 39 // Called when an extension is installed, so that prefs get created. | 39 // Called when an extension is installed, so that prefs get created. |
| 40 void OnExtensionInstalled(Extension* extension); | 40 void OnExtensionInstalled(Extension* extension); |
| 41 | 41 |
| 42 // Called when an extension is uninstalled, so that prefs get cleaned up. | 42 // Called when an extension is uninstalled, so that prefs get cleaned up. |
| 43 void OnExtensionUninstalled(const Extension* extension, | 43 void OnExtensionUninstalled(const Extension* extension, |
| 44 bool external_uninstall); | 44 bool external_uninstall); |
| 45 | 45 |
| 46 // Returns the state (enabled/disabled) of the given extension. |
| 47 Extension::State GetExtensionState(const std::string& extension_id); |
| 48 |
| 49 // Called to change the extension's state when it is enabled/disabled. |
| 50 void SetExtensionState(Extension* extension, Extension::State); |
| 51 |
| 46 // Returns base extensions install directory. | 52 // Returns base extensions install directory. |
| 47 const FilePath& install_directory() const { return install_directory_; } | 53 const FilePath& install_directory() const { return install_directory_; } |
| 48 | 54 |
| 49 // Updates the prefs based on the blacklist. | 55 // Updates the prefs based on the blacklist. |
| 50 void UpdateBlacklist(const std::set<std::string>& blacklist_set); | 56 void UpdateBlacklist(const std::set<std::string>& blacklist_set); |
| 51 | 57 |
| 52 // Based on extension id, checks prefs to see if it is blacklisted. | 58 // Based on extension id, checks prefs to see if it is blacklisted. |
| 53 bool IsExtensionBlacklisted(const std::string& id); | 59 bool IsExtensionBlacklisted(const std::string& id); |
| 54 | 60 |
| 55 private: | 61 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 66 bool UpdateExtensionPref(const std::string& id, | 72 bool UpdateExtensionPref(const std::string& id, |
| 67 const std::wstring& key, | 73 const std::wstring& key, |
| 68 Value* value); | 74 Value* value); |
| 69 | 75 |
| 70 // Deletes the pref dictionary for extension |id|. | 76 // Deletes the pref dictionary for extension |id|. |
| 71 void DeleteExtensionPrefs(const std::string& id); | 77 void DeleteExtensionPrefs(const std::string& id); |
| 72 | 78 |
| 73 // Ensures and returns a mutable dictionary for extension |id|'s prefs. | 79 // Ensures and returns a mutable dictionary for extension |id|'s prefs. |
| 74 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); | 80 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); |
| 75 | 81 |
| 82 // Same as above, but returns NULL if it doesn't exist. |
| 83 DictionaryValue* GetExtensionPref(const std::string& id); |
| 84 |
| 76 // Checks if kPrefBlacklist is set to true in the DictionaryValue. | 85 // Checks if kPrefBlacklist is set to true in the DictionaryValue. |
| 77 // Return false if the value is false or kPrefBlacklist does not exist. | 86 // Return false if the value is false or kPrefBlacklist does not exist. |
| 78 // This is used to decide if an extension is blacklisted. | 87 // This is used to decide if an extension is blacklisted. |
| 79 bool IsBlacklistBitSet(DictionaryValue* ext); | 88 bool IsBlacklistBitSet(DictionaryValue* ext); |
| 80 | 89 |
| 81 // The pref service specific to this set of extension prefs. | 90 // The pref service specific to this set of extension prefs. |
| 82 PrefService* prefs_; | 91 PrefService* prefs_; |
| 83 | 92 |
| 84 // Base extensions install directory. | 93 // Base extensions install directory. |
| 85 FilePath install_directory_; | 94 FilePath install_directory_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 | 108 |
| 100 typedef Callback3<const std::string&, | 109 typedef Callback3<const std::string&, |
| 101 const FilePath&, | 110 const FilePath&, |
| 102 Extension::Location>::Type Callback; | 111 Extension::Location>::Type Callback; |
| 103 | 112 |
| 104 // Runs |callback| for each installed extension with the path to the | 113 // Runs |callback| for each installed extension with the path to the |
| 105 // version directory and the location. Blacklisted extensions won't trigger | 114 // version directory and the location. Blacklisted extensions won't trigger |
| 106 // the callback. | 115 // the callback. |
| 107 void VisitInstalledExtensions(Callback *callback); | 116 void VisitInstalledExtensions(Callback *callback); |
| 108 | 117 |
| 118 // Same as above, but only for the given extension. |
| 119 void VisitInstalledExtension(const std::string& extension_id, |
| 120 Callback *callback); |
| 121 |
| 109 private: | 122 private: |
| 110 // A copy of the extensions pref dictionary so that this can be passed | 123 // A copy of the extensions pref dictionary so that this can be passed |
| 111 // around without a dependency on prefs. | 124 // around without a dependency on prefs. |
| 112 scoped_ptr<DictionaryValue> extension_data_; | 125 scoped_ptr<DictionaryValue> extension_data_; |
| 113 | 126 |
| 114 DISALLOW_COPY_AND_ASSIGN(InstalledExtensions); | 127 DISALLOW_COPY_AND_ASSIGN(InstalledExtensions); |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 130 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| 118 | 131 |
| OLD | NEW |