Home | History | Annotate | Download | only in browser
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef EXTENSIONS_BROWSER_EXTENSION_SCOPED_PREFS_H_
      6 #define EXTENSIONS_BROWSER_EXTENSION_SCOPED_PREFS_H_
      7 
      8 namespace extensions {
      9 
     10 class ExtensionScopedPrefs {
     11  public:
     12   ExtensionScopedPrefs() {}
     13   ~ExtensionScopedPrefs() {}
     14 
     15   // Sets the pref |key| for extension |id| to |value|.
     16   virtual void UpdateExtensionPref(const std::string& id,
     17                                    const std::string& key,
     18                                    base::Value* value) = 0;
     19 
     20   // Deletes the pref dictionary for extension |id|.
     21   virtual void DeleteExtensionPrefs(const std::string& id) = 0;
     22 
     23   // Reads a boolean pref |pref_key| from extension with id |extension_id|.
     24   virtual bool ReadPrefAsBoolean(const std::string& extension_id,
     25                                  const std::string& pref_key,
     26                                  bool* out_value) const = 0;
     27 
     28   // Reads an integer pref |pref_key| from extension with id |extension_id|.
     29   virtual bool ReadPrefAsInteger(const std::string& extension_id,
     30                                  const std::string& pref_key,
     31                                  int* out_value) const = 0;
     32 
     33   // Reads a string pref |pref_key| from extension with id |extension_id|.
     34   virtual bool ReadPrefAsString(const std::string& extension_id,
     35                                 const std::string& pref_key,
     36                                 std::string* out_value) const = 0;
     37 
     38   // Reads a list pref |pref_key| from extension with id |extension_id|.
     39   virtual bool ReadPrefAsList(const std::string& extension_id,
     40                               const std::string& pref_key,
     41                               const base::ListValue** out_value) const = 0;
     42 
     43   // Reads a dictionary pref |pref_key| from extension with id |extension_id|.
     44   virtual bool ReadPrefAsDictionary(
     45       const std::string& extension_id,
     46       const std::string& pref_key,
     47       const base::DictionaryValue** out_value) const = 0;
     48 
     49   // Returns true if the prefs contain an entry for an extension with id
     50   // |extension_id|.
     51   virtual bool HasPrefForExtension(const std::string& extension_id) const = 0;
     52 };
     53 
     54 }  // namespace extensions
     55 
     56 #endif  // EXTENSIONS_BROWSER_EXTENSION_SCOPED_PREFS_H_
     57