| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "chrome/browser/extensions/extension_content_settings_store.h" | 15 #include "chrome/browser/extensions/extension_content_settings_store.h" |
| 16 #include "chrome/browser/extensions/extension_prefs_scope.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 | 20 |
| 20 class ExtensionPrefValueMap; | 21 class ExtensionPrefValueMap; |
| 21 class URLPatternSet; | 22 class URLPatternSet; |
| 22 | 23 |
| 23 // Class for managing global and per-extension preferences. | 24 // Class for managing global and per-extension preferences. |
| 24 // | 25 // |
| 25 // This class distinguishes the following kinds of preferences: | 26 // This class distinguishes the following kinds of preferences: |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 void SetUpdateUrlData(const std::string& extension_id, | 297 void SetUpdateUrlData(const std::string& extension_id, |
| 297 const std::string& data); | 298 const std::string& data); |
| 298 std::string GetUpdateUrlData(const std::string& extension_id); | 299 std::string GetUpdateUrlData(const std::string& extension_id); |
| 299 | 300 |
| 300 // Sets a preference value that is controlled by the extension. In other | 301 // Sets a preference value that is controlled by the extension. In other |
| 301 // words, this is not a pref value *about* the extension but something | 302 // words, this is not a pref value *about* the extension but something |
| 302 // global the extension wants to override. | 303 // global the extension wants to override. |
| 303 // Takes ownership of |value|. | 304 // Takes ownership of |value|. |
| 304 void SetExtensionControlledPref(const std::string& extension_id, | 305 void SetExtensionControlledPref(const std::string& extension_id, |
| 305 const std::string& pref_key, | 306 const std::string& pref_key, |
| 306 bool incognito, | 307 extension_prefs_scope::Scope scope, |
| 307 Value* value); | 308 Value* value); |
| 308 | 309 |
| 309 void RemoveExtensionControlledPref(const std::string& extension_id, | 310 void RemoveExtensionControlledPref(const std::string& extension_id, |
| 310 const std::string& pref_key, | 311 const std::string& pref_key, |
| 311 bool incognito); | 312 extension_prefs_scope::Scope scope); |
| 312 | 313 |
| 313 // Returns true if currently no extension with higher precedence controls the | 314 // Returns true if currently no extension with higher precedence controls the |
| 314 // preference. | 315 // preference. |
| 315 bool CanExtensionControlPref(const std::string& extension_id, | 316 bool CanExtensionControlPref(const std::string& extension_id, |
| 316 const std::string& pref_key, | 317 const std::string& pref_key, |
| 317 bool incognito); | 318 bool incognito); |
| 318 | 319 |
| 319 // Returns true if extension |extension_id| currently controls the | 320 // Returns true if extension |extension_id| currently controls the |
| 320 // preference. | 321 // preference. |
| 321 bool DoesExtensionControlPref(const std::string& extension_id, | 322 bool DoesExtensionControlPref(const std::string& extension_id, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 const std::set<std::string>& added_values); | 409 const std::set<std::string>& added_values); |
| 409 | 410 |
| 410 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't | 411 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't |
| 411 // exist. | 412 // exist. |
| 412 const DictionaryValue* GetExtensionPref(const std::string& id) const; | 413 const DictionaryValue* GetExtensionPref(const std::string& id) const; |
| 413 | 414 |
| 414 // Returns the dictionary of preferences controlled by the specified extension | 415 // Returns the dictionary of preferences controlled by the specified extension |
| 415 // or creates a new one. All entries in the dictionary contain non-expanded | 416 // or creates a new one. All entries in the dictionary contain non-expanded |
| 416 // paths. | 417 // paths. |
| 417 const DictionaryValue* GetExtensionControlledPrefs( | 418 const DictionaryValue* GetExtensionControlledPrefs( |
| 418 const std::string& id) const; | 419 const std::string& id, |
| 420 bool incognito) const; |
| 419 | 421 |
| 420 // Serializes the data and schedules a persistent save via the |PrefService|. | 422 // Serializes the data and schedules a persistent save via the |PrefService|. |
| 421 // TODO(andybons): Fire an EXTENSION_PREF_CHANGED notification to be more | 423 // TODO(andybons): Fire an EXTENSION_PREF_CHANGED notification to be more |
| 422 // granular than PREF_CHANGED. | 424 // granular than PREF_CHANGED. |
| 423 void SavePrefs(); | 425 void SavePrefs(); |
| 424 | 426 |
| 425 // Checks if kPrefBlacklist is set to true in the DictionaryValue. | 427 // Checks if kPrefBlacklist is set to true in the DictionaryValue. |
| 426 // Return false if the value is false or kPrefBlacklist does not exist. | 428 // Return false if the value is false or kPrefBlacklist does not exist. |
| 427 // This is used to decide if an extension is blacklisted. | 429 // This is used to decide if an extension is blacklisted. |
| 428 static bool IsBlacklistBitSet(DictionaryValue* ext); | 430 static bool IsBlacklistBitSet(DictionaryValue* ext); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 446 | 448 |
| 447 scoped_ptr<ExtensionContentSettingsStore> content_settings_store_; | 449 scoped_ptr<ExtensionContentSettingsStore> content_settings_store_; |
| 448 | 450 |
| 449 // The URLs of all of the toolstrips. | 451 // The URLs of all of the toolstrips. |
| 450 URLList shelf_order_; | 452 URLList shelf_order_; |
| 451 | 453 |
| 452 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 454 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 453 }; | 455 }; |
| 454 | 456 |
| 455 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 457 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |