| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 base::Time LastActivePingDay(const std::string& extension_id); | 166 base::Time LastActivePingDay(const std::string& extension_id); |
| 167 void SetLastActivePingDay(const std::string& extension_id, | 167 void SetLastActivePingDay(const std::string& extension_id, |
| 168 const base::Time& time); | 168 const base::Time& time); |
| 169 | 169 |
| 170 // A bit we use for determining if we should send the "days since active" | 170 // A bit we use for determining if we should send the "days since active" |
| 171 // ping. A value of true means the item has been active (launched) since the | 171 // ping. A value of true means the item has been active (launched) since the |
| 172 // last update check. | 172 // last update check. |
| 173 bool GetActiveBit(const std::string& extension_id); | 173 bool GetActiveBit(const std::string& extension_id); |
| 174 void SetActiveBit(const std::string& extension_id, bool active); | 174 void SetActiveBit(const std::string& extension_id, bool active); |
| 175 | 175 |
| 176 // Gets the permissions (|api_permissions|, |host_extent| and |full_access|) | 176 // Returns the granted permission set for the extension with |extension_id|, |
| 177 // granted to the extension with |extension_id|. |full_access| will be true | 177 // and NULL if no preferences were found for |extension_id|. |
| 178 // if the extension has all effective permissions (like from an NPAPI plugin). | 178 // This passes ownership of the returned set to the caller. |
| 179 // Returns false if the granted permissions haven't been initialized yet. | 179 ExtensionPermissionSet* GetGrantedPermissions( |
| 180 // TODO(jstritar): Refactor the permissions into a class that encapsulates | 180 const std::string& extension_id); |
| 181 // all granted permissions, can be initialized from preferences or | |
| 182 // a manifest file, and can be compared to each other. | |
| 183 bool GetGrantedPermissions(const std::string& extension_id, | |
| 184 bool* full_access, | |
| 185 std::set<std::string>* api_permissions, | |
| 186 URLPatternSet* host_extent); | |
| 187 | 181 |
| 188 // Adds the specified |api_permissions|, |host_extent| and |full_access| | 182 // Adds |permissions| to the granted permissions set for the extension with |
| 189 // to the granted permissions for extension with |extension_id|. | 183 // |extension_id|. The new granted permissions set will be the union of |
| 190 // |full_access| should be set to true if the extension effectively has all | 184 // |permissions| and the already granted permissions. |
| 191 // permissions (such as by having an NPAPI plugin). | |
| 192 void AddGrantedPermissions(const std::string& extension_id, | 185 void AddGrantedPermissions(const std::string& extension_id, |
| 193 const bool full_access, | 186 const ExtensionPermissionSet* permissions); |
| 194 const std::set<std::string>& api_permissions, | |
| 195 const URLPatternSet& host_extent); | |
| 196 | 187 |
| 197 // Returns true if the user enabled this extension to be loaded in incognito | 188 // Returns true if the user enabled this extension to be loaded in incognito |
| 198 // mode. | 189 // mode. |
| 199 bool IsIncognitoEnabled(const std::string& extension_id); | 190 bool IsIncognitoEnabled(const std::string& extension_id); |
| 200 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); | 191 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); |
| 201 | 192 |
| 202 // Returns true if the user has chosen to allow this extension to inject | 193 // Returns true if the user has chosen to allow this extension to inject |
| 203 // scripts into pages with file URLs. | 194 // scripts into pages with file URLs. |
| 204 bool AllowFileAccess(const std::string& extension_id); | 195 bool AllowFileAccess(const std::string& extension_id); |
| 205 void SetAllowFileAccess(const std::string& extension_id, bool allow); | 196 void SetAllowFileAccess(const std::string& extension_id, bool allow); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Return false if the value does not exist. | 377 // Return false if the value does not exist. |
| 387 static bool ReadIntegerFromPref(const DictionaryValue* ext, | 378 static bool ReadIntegerFromPref(const DictionaryValue* ext, |
| 388 const std::string& pref_key, | 379 const std::string& pref_key, |
| 389 int* out_value); | 380 int* out_value); |
| 390 | 381 |
| 391 // Reads an integer pref |pref_key| from extension with id |extension_id|. | 382 // Reads an integer pref |pref_key| from extension with id |extension_id|. |
| 392 bool ReadExtensionPrefInteger(const std::string& extension_id, | 383 bool ReadExtensionPrefInteger(const std::string& extension_id, |
| 393 const std::string& pref_key, | 384 const std::string& pref_key, |
| 394 int* out_value); | 385 int* out_value); |
| 395 | 386 |
| 396 // Reads a list pref |pref_key| from extension with id | extension_id|. | 387 // Reads a list pref |pref_key| from extension with id |extension_id|. |
| 397 bool ReadExtensionPrefList(const std::string& extension_id, | 388 bool ReadExtensionPrefList(const std::string& extension_id, |
| 398 const std::string& pref_key, | 389 const std::string& pref_key, |
| 399 const ListValue** out_value); | 390 const ListValue** out_value); |
| 400 | 391 |
| 401 // Reads a list pref |pref_key| as a string set from the extension with | 392 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a |
| 402 // id |extension_id|. | 393 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. |
| 403 bool ReadExtensionPrefStringSet(const std::string& extension_id, | 394 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, |
| 404 const std::string& pref_key, | 395 const std::string& pref_key, |
| 405 std::set<std::string>* result); | 396 URLPatternSet* result, |
| 397 int valid_schemes); |
| 406 | 398 |
| 407 // Adds the |added_values| to the value of |pref_key| for the extension | 399 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
| 408 // with id |extension_id| (the new value will be the union of the existing | 400 // belonging to |extension_id|. |
| 409 // value and |added_values|). | 401 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
| 410 void AddToExtensionPrefStringSet(const std::string& extension_id, | 402 const std::string& pref_key, |
| 411 const std::string& pref_key, | 403 const URLPatternSet& new_value); |
| 412 const std::set<std::string>& added_values); | |
| 413 | 404 |
| 414 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't | 405 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't |
| 415 // exist. | 406 // exist. |
| 416 const DictionaryValue* GetExtensionPref(const std::string& id) const; | 407 const DictionaryValue* GetExtensionPref(const std::string& id) const; |
| 417 | 408 |
| 418 // Returns the dictionary of preferences controlled by the specified extension | 409 // Returns the dictionary of preferences controlled by the specified extension |
| 419 // or creates a new one. All entries in the dictionary contain non-expanded | 410 // or creates a new one. All entries in the dictionary contain non-expanded |
| 420 // paths. | 411 // paths. |
| 421 const DictionaryValue* GetExtensionControlledPrefs( | 412 const DictionaryValue* GetExtensionControlledPrefs( |
| 422 const std::string& id, | 413 const std::string& id, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 433 static bool IsBlacklistBitSet(DictionaryValue* ext); | 424 static bool IsBlacklistBitSet(DictionaryValue* ext); |
| 434 | 425 |
| 435 // Fix missing preference entries in the extensions that are were introduced | 426 // Fix missing preference entries in the extensions that are were introduced |
| 436 // in a later Chrome version. | 427 // in a later Chrome version. |
| 437 void FixMissingPrefs(const ExtensionIdSet& extension_ids); | 428 void FixMissingPrefs(const ExtensionIdSet& extension_ids); |
| 438 | 429 |
| 439 // Installs the persistent extension preferences into |prefs_|'s extension | 430 // Installs the persistent extension preferences into |prefs_|'s extension |
| 440 // pref store. | 431 // pref store. |
| 441 void InitPrefStore(); | 432 void InitPrefStore(); |
| 442 | 433 |
| 434 // Migrates the permissions data in the pref store. |
| 435 void MigratePermissions(const ExtensionIdSet& extension_ids); |
| 436 |
| 443 // The pref service specific to this set of extension prefs. Owned by profile. | 437 // The pref service specific to this set of extension prefs. Owned by profile. |
| 444 PrefService* prefs_; | 438 PrefService* prefs_; |
| 445 | 439 |
| 446 // Base extensions install directory. | 440 // Base extensions install directory. |
| 447 FilePath install_directory_; | 441 FilePath install_directory_; |
| 448 | 442 |
| 449 // Weak pointer, owned by Profile. | 443 // Weak pointer, owned by Profile. |
| 450 ExtensionPrefValueMap* extension_pref_value_map_; | 444 ExtensionPrefValueMap* extension_pref_value_map_; |
| 451 | 445 |
| 452 scoped_ptr<ExtensionContentSettingsStore> content_settings_store_; | 446 scoped_ptr<ExtensionContentSettingsStore> content_settings_store_; |
| 453 | 447 |
| 454 // The URLs of all of the toolstrips. | 448 // The URLs of all of the toolstrips. |
| 455 URLList shelf_order_; | 449 URLList shelf_order_; |
| 456 | 450 |
| 457 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 451 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 458 }; | 452 }; |
| 459 | 453 |
| 460 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 454 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |