Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: chrome/browser/ui/zoom/chrome_zoom_level_prefs.h

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ 5 #ifndef CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_
6 #define CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ 6 #define CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/prefs/json_pref_store.h" 13 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_change_registrar.h" 14 #include "base/prefs/pref_change_registrar.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/prefs/pref_store.h" 16 #include "base/prefs/pref_store.h"
17 #include "content/public/browser/host_zoom_map.h" 17 #include "content/public/browser/host_zoom_map.h"
18 #include "content/public/browser/zoom_level_delegate.h"
18 19
19 namespace base { 20 namespace base {
20 class DictionaryValue; 21 class DictionaryValue;
21 } 22 }
22 23
23 namespace chrome { 24 namespace chrome {
24 25
25 // A class to manage per-partition default and per-host zoom levels in Chrome's 26 // A class to manage per-partition default and per-host zoom levels in Chrome's
26 // preference system. It implements an interface between the content/ zoom 27 // preference system. It implements an interface between the content/ zoom
27 // levels in HostZoomMap and Chrome's preference system. All changes 28 // levels in HostZoomMap and Chrome's preference system. All changes
28 // to the per-partition default zoom levels from chrome/ flow through this 29 // to the per-partition default zoom levels from chrome/ flow through this
29 // class. Any changes to per-host levels are updated when HostZoomMap calls 30 // class. Any changes to per-host levels are updated when HostZoomMap calls
30 // OnZoomLevelChanged. 31 // OnZoomLevelChanged.
31 class ChromeZoomLevelPrefs { 32 class ChromeZoomLevelPrefs : public content::ZoomLevelDelegate {
32 public: 33 public:
33 typedef base::CallbackList<void(void)>::Subscription 34 typedef base::CallbackList<void(void)>::Subscription
34 DefaultZoomLevelSubscription; 35 DefaultZoomLevelSubscription;
35 36
36 // Initialize the pref_service and the profile_path via the constructor, 37 // Initialize the pref_service and the profile_path via the constructor,
37 // as these concepts won't be available in the content base class 38 // as these concepts won't be available in the content base class
38 // (to be added later) which will define the InitPrefsAndCopyToHostZoomMap 39 // (to be added later) which will define the InitPrefsAndCopyToHostZoomMap
39 // interface. |pref_service_| must outlive this class. 40 // interface. |pref_service_| must outlive this class.
40 ChromeZoomLevelPrefs(PrefService* pref_service, 41 ChromeZoomLevelPrefs(PrefService* pref_service,
41 const base::FilePath& profile_path); 42 const base::FilePath& profile_path);
42 virtual ~ChromeZoomLevelPrefs(); 43 virtual ~ChromeZoomLevelPrefs();
43 44
44 static std::string GetHashForTesting(const base::FilePath& relative_path); 45 static std::string GetHashForTesting(const base::FilePath& relative_path);
45 46
46 virtual void InitPrefsAndCopyToHostZoomMap(
47 const base::FilePath& partition_path,
48 content::HostZoomMap* host_zoom_map);
49
50 void SetDefaultZoomLevelPref(double level); 47 void SetDefaultZoomLevelPref(double level);
51 double GetDefaultZoomLevelPref() const; 48 double GetDefaultZoomLevelPref() const;
52 scoped_ptr<DefaultZoomLevelSubscription> RegisterDefaultZoomLevelCallback( 49 scoped_ptr<DefaultZoomLevelSubscription> RegisterDefaultZoomLevelCallback(
53 const base::Closure& callback); 50 const base::Closure& callback);
54 51
55 void ExtractPerHostZoomLevels( 52 void ExtractPerHostZoomLevels(
56 const base::DictionaryValue* host_zoom_dictionary, 53 const base::DictionaryValue* host_zoom_dictionary,
57 bool sanitize_partition_host_zoom_levels); 54 bool sanitize_partition_host_zoom_levels);
58 55
56 // content::ZoomLevelDelegate
57 void InitPrefsAndCopyToHostZoomMap(
Fady Samuel 2014/11/03 22:11:11 nit: Call something that doesn't mention Prefs in
wjmaclean 2014/11/04 19:34:25 Done.
58 const base::FilePath& partition_path,
59 content::HostZoomMap* host_zoom_map) override;
60
59 private: 61 private:
60 // This is a callback function that receives notifications from HostZoomMap 62 // This is a callback function that receives notifications from HostZoomMap
61 // when per-host zoom levels change. It is used to update the per-host 63 // when per-host zoom levels change. It is used to update the per-host
62 // zoom levels (if any) managed by this class (for its associated partition). 64 // zoom levels (if any) managed by this class (for its associated partition).
63 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); 65 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
64 66
65 PrefService* pref_service_; 67 PrefService* pref_service_;
66 const base::FilePath profile_path_; 68 const base::FilePath profile_path_;
67 content::HostZoomMap* host_zoom_map_; 69 content::HostZoomMap* host_zoom_map_;
68 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_; 70 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
69 std::string partition_key_; 71 std::string partition_key_;
70 base::CallbackList<void(void)> default_zoom_changed_callbacks_; 72 base::CallbackList<void(void)> default_zoom_changed_callbacks_;
71 73
72 DISALLOW_COPY_AND_ASSIGN(ChromeZoomLevelPrefs); 74 DISALLOW_COPY_AND_ASSIGN(ChromeZoomLevelPrefs);
73 }; 75 };
74 76
75 } // namespace chrome 77 } // namespace chrome
76 78
77 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ 79 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698