OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_PREFS_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_PREFS_HELPER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "components/prefs/scoped_user_pref_update.h" |
| 13 |
| 14 class PrefService; |
| 15 |
| 16 namespace base { |
| 17 class DictionaryValue; |
| 18 class FilePath; |
| 19 } |
| 20 |
| 21 // This class wraps a PrefService so that calls to get/set a preference value |
| 22 // apply to the value under the key for a specific storage partition. |
| 23 class ChromeZoomPrefsHelper { |
| 24 public: |
| 25 ChromeZoomPrefsHelper(PrefService* pref_service, |
| 26 const base::FilePath& profile_path, |
| 27 const base::FilePath& partition_path); |
| 28 |
| 29 static std::string GetHashForTesting(const base::FilePath& relative_path); |
| 30 |
| 31 // Get/set the value under our partition key for the pref. |
| 32 bool GetBoolean(const char* pref_name, bool* value) const; |
| 33 void SetBoolean(const char* pref_name, bool value); |
| 34 bool GetDouble(const char* pref_name, double* value) const; |
| 35 void SetDouble(const char* pref_name, double value); |
| 36 |
| 37 // Get the dictionary under our partition key for the pref. |
| 38 bool GetDictionary(const char* pref_name, |
| 39 const base::DictionaryValue** value) const; |
| 40 // Get a DictionaryPrefUpdate for the pref which can then be used to get a |
| 41 // mutable dictionary. |
| 42 std::unique_ptr<DictionaryPrefUpdate> GetUpdate(const char* pref_name); |
| 43 // Get a mutable dictionary under our partition key for the pref. |
| 44 // |update| must outlive the use of the returned dictionary. |
| 45 base::DictionaryValue* GetMutableDictionary( |
| 46 DictionaryPrefUpdate* update) const; |
| 47 |
| 48 private: |
| 49 PrefService* pref_service_; |
| 50 std::string partition_key_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(ChromeZoomPrefsHelper); |
| 53 }; |
| 54 |
| 55 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_PREFS_HELPER_H_ |
OLD | NEW |