| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // Does not assume ownership of |prefs| and |incognito_prefs|. | 70 // Does not assume ownership of |prefs| and |incognito_prefs|. |
| 71 explicit ExtensionPrefs(PrefService* prefs, | 71 explicit ExtensionPrefs(PrefService* prefs, |
| 72 const FilePath& root_dir, | 72 const FilePath& root_dir, |
| 73 ExtensionPrefValueMap* extension_pref_value_map); | 73 ExtensionPrefValueMap* extension_pref_value_map); |
| 74 virtual ~ExtensionPrefs(); | 74 virtual ~ExtensionPrefs(); |
| 75 | 75 |
| 76 // Returns a copy of the Extensions prefs. | 76 // Returns a copy of the Extensions prefs. |
| 77 // TODO(erikkay) Remove this so that external consumers don't need to be | 77 // TODO(erikkay) Remove this so that external consumers don't need to be |
| 78 // aware of the internal structure of the preferences. | 78 // aware of the internal structure of the preferences. |
| 79 DictionaryValue* CopyCurrentExtensions(); | 79 base::DictionaryValue* CopyCurrentExtensions(); |
| 80 | 80 |
| 81 // Returns true if the specified external extension was uninstalled by the | 81 // Returns true if the specified external extension was uninstalled by the |
| 82 // user. | 82 // user. |
| 83 bool IsExternalExtensionUninstalled(const std::string& id) const; | 83 bool IsExternalExtensionUninstalled(const std::string& id) const; |
| 84 | 84 |
| 85 // Get the order that toolstrip URLs appear in the shelf. | 85 // Get the order that toolstrip URLs appear in the shelf. |
| 86 typedef std::vector<GURL> URLList; | 86 typedef std::vector<GURL> URLList; |
| 87 URLList GetShelfToolstripOrder(); | 87 URLList GetShelfToolstripOrder(); |
| 88 | 88 |
| 89 // Sets the order that toolstrip URLs appear in the shelf. | 89 // Sets the order that toolstrip URLs appear in the shelf. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 const std::string& data); | 290 const std::string& data); |
| 291 std::string GetUpdateUrlData(const std::string& extension_id); | 291 std::string GetUpdateUrlData(const std::string& extension_id); |
| 292 | 292 |
| 293 // Sets a preference value that is controlled by the extension. In other | 293 // Sets a preference value that is controlled by the extension. In other |
| 294 // words, this is not a pref value *about* the extension but something | 294 // words, this is not a pref value *about* the extension but something |
| 295 // global the extension wants to override. | 295 // global the extension wants to override. |
| 296 // Takes ownership of |value|. | 296 // Takes ownership of |value|. |
| 297 void SetExtensionControlledPref(const std::string& extension_id, | 297 void SetExtensionControlledPref(const std::string& extension_id, |
| 298 const std::string& pref_key, | 298 const std::string& pref_key, |
| 299 ExtensionPrefsScope scope, | 299 ExtensionPrefsScope scope, |
| 300 Value* value); | 300 base::Value* value); |
| 301 | 301 |
| 302 void RemoveExtensionControlledPref(const std::string& extension_id, | 302 void RemoveExtensionControlledPref(const std::string& extension_id, |
| 303 const std::string& pref_key, | 303 const std::string& pref_key, |
| 304 ExtensionPrefsScope scope); | 304 ExtensionPrefsScope scope); |
| 305 | 305 |
| 306 // Returns true if currently no extension with higher precedence controls the | 306 // Returns true if currently no extension with higher precedence controls the |
| 307 // preference. | 307 // preference. |
| 308 bool CanExtensionControlPref(const std::string& extension_id, | 308 bool CanExtensionControlPref(const std::string& extension_id, |
| 309 const std::string& pref_key, | 309 const std::string& pref_key, |
| 310 bool incognito); | 310 bool incognito); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 virtual void OnContentSettingChanged( | 346 virtual void OnContentSettingChanged( |
| 347 const std::string& extension_id, | 347 const std::string& extension_id, |
| 348 bool incognito) OVERRIDE; | 348 bool incognito) OVERRIDE; |
| 349 | 349 |
| 350 // Converts absolute paths in the pref to paths relative to the | 350 // Converts absolute paths in the pref to paths relative to the |
| 351 // install_directory_. | 351 // install_directory_. |
| 352 void MakePathsRelative(); | 352 void MakePathsRelative(); |
| 353 | 353 |
| 354 // Converts internal relative paths to be absolute. Used for export to | 354 // Converts internal relative paths to be absolute. Used for export to |
| 355 // consumers who expect full paths. | 355 // consumers who expect full paths. |
| 356 void MakePathsAbsolute(DictionaryValue* dict); | 356 void MakePathsAbsolute(base::DictionaryValue* dict); |
| 357 | 357 |
| 358 // Sets the pref |key| for extension |id| to |value|. | 358 // Sets the pref |key| for extension |id| to |value|. |
| 359 void UpdateExtensionPref(const std::string& id, | 359 void UpdateExtensionPref(const std::string& id, |
| 360 const std::string& key, | 360 const std::string& key, |
| 361 Value* value); | 361 base::Value* value); |
| 362 | 362 |
| 363 // Deletes the pref dictionary for extension |id|. | 363 // Deletes the pref dictionary for extension |id|. |
| 364 void DeleteExtensionPrefs(const std::string& id); | 364 void DeleteExtensionPrefs(const std::string& id); |
| 365 | 365 |
| 366 // Reads a boolean pref from |ext| with key |pref_key|. | 366 // Reads a boolean pref from |ext| with key |pref_key|. |
| 367 // Return false if the value is false or |pref_key| does not exist. | 367 // Return false if the value is false or |pref_key| does not exist. |
| 368 static bool ReadBooleanFromPref(const DictionaryValue* ext, | 368 static bool ReadBooleanFromPref(const base::DictionaryValue* ext, |
| 369 const std::string& pref_key); | 369 const std::string& pref_key); |
| 370 | 370 |
| 371 // Reads a boolean pref |pref_key| from extension with id |extension_id|. | 371 // Reads a boolean pref |pref_key| from extension with id |extension_id|. |
| 372 bool ReadExtensionPrefBoolean(const std::string& extension_id, | 372 bool ReadExtensionPrefBoolean(const std::string& extension_id, |
| 373 const std::string& pref_key); | 373 const std::string& pref_key); |
| 374 | 374 |
| 375 // Reads an integer pref from |ext| with key |pref_key|. | 375 // Reads an integer pref from |ext| with key |pref_key|. |
| 376 // Return false if the value does not exist. | 376 // Return false if the value does not exist. |
| 377 static bool ReadIntegerFromPref(const DictionaryValue* ext, | 377 static bool ReadIntegerFromPref(const base::DictionaryValue* ext, |
| 378 const std::string& pref_key, | 378 const std::string& pref_key, |
| 379 int* out_value); | 379 int* out_value); |
| 380 | 380 |
| 381 // Reads an integer pref |pref_key| from extension with id |extension_id|. | 381 // Reads an integer pref |pref_key| from extension with id |extension_id|. |
| 382 bool ReadExtensionPrefInteger(const std::string& extension_id, | 382 bool ReadExtensionPrefInteger(const std::string& extension_id, |
| 383 const std::string& pref_key, | 383 const std::string& pref_key, |
| 384 int* out_value); | 384 int* out_value); |
| 385 | 385 |
| 386 // Reads a list pref |pref_key| from extension with id |extension_id|. | 386 // Reads a list pref |pref_key| from extension with id |extension_id|. |
| 387 bool ReadExtensionPrefList(const std::string& extension_id, | 387 bool ReadExtensionPrefList(const std::string& extension_id, |
| 388 const std::string& pref_key, | 388 const std::string& pref_key, |
| 389 const ListValue** out_value); | 389 const base::ListValue** out_value); |
| 390 | 390 |
| 391 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a | 391 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a |
| 392 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. | 392 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. |
| 393 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, | 393 bool ReadExtensionPrefURLPatternSet(const std::string& extension_id, |
| 394 const std::string& pref_key, | 394 const std::string& pref_key, |
| 395 URLPatternSet* result, | 395 URLPatternSet* result, |
| 396 int valid_schemes); | 396 int valid_schemes); |
| 397 | 397 |
| 398 // Converts |new_value| to a list of strings and sets the |pref_key| pref | 398 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
| 399 // belonging to |extension_id|. | 399 // belonging to |extension_id|. |
| 400 void SetExtensionPrefURLPatternSet(const std::string& extension_id, | 400 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
| 401 const std::string& pref_key, | 401 const std::string& pref_key, |
| 402 const URLPatternSet& new_value); | 402 const URLPatternSet& new_value); |
| 403 | 403 |
| 404 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't | 404 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't |
| 405 // exist. | 405 // exist. |
| 406 const DictionaryValue* GetExtensionPref(const std::string& id) const; | 406 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; |
| 407 | 407 |
| 408 // Returns the dictionary of preferences controlled by the specified extension | 408 // Returns the dictionary of preferences controlled by the specified extension |
| 409 // or creates a new one. All entries in the dictionary contain non-expanded | 409 // or creates a new one. All entries in the dictionary contain non-expanded |
| 410 // paths. | 410 // paths. |
| 411 const DictionaryValue* GetExtensionControlledPrefs( | 411 const base::DictionaryValue* GetExtensionControlledPrefs( |
| 412 const std::string& id, | 412 const std::string& id, |
| 413 bool incognito) const; | 413 bool incognito) const; |
| 414 | 414 |
| 415 // Serializes the data and schedules a persistent save via the |PrefService|. | 415 // Serializes the data and schedules a persistent save via the |PrefService|. |
| 416 // TODO(andybons): Fire an EXTENSION_PREF_CHANGED notification to be more | 416 // TODO(andybons): Fire an EXTENSION_PREF_CHANGED notification to be more |
| 417 // granular than PREF_CHANGED. | 417 // granular than PREF_CHANGED. |
| 418 void SavePrefs(); | 418 void SavePrefs(); |
| 419 | 419 |
| 420 // Checks if kPrefBlacklist is set to true in the DictionaryValue. | 420 // Checks if kPrefBlacklist is set to true in the DictionaryValue. |
| 421 // Return false if the value is false or kPrefBlacklist does not exist. | 421 // Return false if the value is false or kPrefBlacklist does not exist. |
| 422 // This is used to decide if an extension is blacklisted. | 422 // This is used to decide if an extension is blacklisted. |
| 423 static bool IsBlacklistBitSet(DictionaryValue* ext); | 423 static bool IsBlacklistBitSet(base::DictionaryValue* ext); |
| 424 | 424 |
| 425 // Fix missing preference entries in the extensions that are were introduced | 425 // Fix missing preference entries in the extensions that are were introduced |
| 426 // in a later Chrome version. | 426 // in a later Chrome version. |
| 427 void FixMissingPrefs(const ExtensionIdSet& extension_ids); | 427 void FixMissingPrefs(const ExtensionIdSet& extension_ids); |
| 428 | 428 |
| 429 // Installs the persistent extension preferences into |prefs_|'s extension | 429 // Installs the persistent extension preferences into |prefs_|'s extension |
| 430 // pref store. | 430 // pref store. |
| 431 void InitPrefStore(); | 431 void InitPrefStore(); |
| 432 | 432 |
| 433 // Migrates the permissions data in the pref store. | 433 // Migrates the permissions data in the pref store. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 444 | 444 |
| 445 scoped_refptr<ExtensionContentSettingsStore> content_settings_store_; | 445 scoped_refptr<ExtensionContentSettingsStore> content_settings_store_; |
| 446 | 446 |
| 447 // The URLs of all of the toolstrips. | 447 // The URLs of all of the toolstrips. |
| 448 URLList shelf_order_; | 448 URLList shelf_order_; |
| 449 | 449 |
| 450 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 450 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 451 }; | 451 }; |
| 452 | 452 |
| 453 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 453 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |