OLD | NEW |
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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace zoom { | 25 namespace zoom { |
26 class ZoomEventManager; | 26 class ZoomEventManager; |
27 } | 27 } |
28 | 28 |
29 // A class to manage per-partition default and per-host zoom levels in Chrome's | 29 // A class to manage per-partition default and per-host zoom levels in Chrome's |
30 // preference system. It implements an interface between the content/ zoom | 30 // preference system. It implements an interface between the content/ zoom |
31 // levels in HostZoomMap and Chrome's preference system. All changes | 31 // levels in HostZoomMap and Chrome's preference system. All changes |
32 // to the per-partition default zoom levels from chrome/ flow through this | 32 // to the per-partition default zoom levels from chrome/ flow through this |
33 // class. Any changes to per-host levels are updated when HostZoomMap calls | 33 // class. Any changes to per-host levels are updated when HostZoomMap calls |
34 // OnZoomLevelChanged. | 34 // OnZoomLevelChanged. This also provides access to the default zoom scope |
| 35 // preference. |
35 class ChromeZoomLevelPrefs : public content::ZoomLevelDelegate { | 36 class ChromeZoomLevelPrefs : public content::ZoomLevelDelegate { |
36 public: | 37 public: |
37 typedef base::CallbackList<void(void)>::Subscription | 38 typedef base::CallbackList<void(void)>::Subscription |
38 DefaultZoomLevelSubscription; | 39 DefaultZoomLevelSubscription; |
39 | 40 |
40 // Initialize the pref_service and the partition_key via the constructor, | 41 // Initialize the pref_service and the partition_key via the constructor, |
41 // as these concepts won't be available in the content base class | 42 // as these concepts won't be available in the content base class |
42 // ZoomLevelDelegate, which will define the InitHostZoomMap interface. | 43 // ZoomLevelDelegate, which will define the InitHostZoomMap interface. |
43 // |pref_service_| must outlive this class. | 44 // |pref_service_| must outlive this class. |
44 ChromeZoomLevelPrefs( | 45 ChromeZoomLevelPrefs( |
45 PrefService* pref_service, | 46 PrefService* pref_service, |
46 const base::FilePath& profile_path, | 47 const base::FilePath& profile_path, |
47 const base::FilePath& partition_path, | 48 const base::FilePath& partition_path, |
48 base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager); | 49 base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager); |
49 ~ChromeZoomLevelPrefs() override; | 50 ~ChromeZoomLevelPrefs() override; |
50 | 51 |
51 static std::string GetHashForTesting(const base::FilePath& relative_path); | 52 static std::string GetHashForTesting(const base::FilePath& relative_path); |
52 | 53 |
53 void SetDefaultZoomLevelPref(double level); | 54 void SetDefaultZoomLevelPref(double level); |
54 double GetDefaultZoomLevelPref() const; | 55 double GetDefaultZoomLevelPref() const; |
55 std::unique_ptr<DefaultZoomLevelSubscription> | 56 std::unique_ptr<DefaultZoomLevelSubscription> |
56 RegisterDefaultZoomLevelCallback(const base::Closure& callback); | 57 RegisterDefaultZoomLevelCallback(const base::Closure& callback); |
57 | 58 |
| 59 void SetIsOriginScopePref(bool default_per_origin); |
| 60 |
58 void ExtractPerHostZoomLevels( | 61 void ExtractPerHostZoomLevels( |
59 const base::DictionaryValue* host_zoom_dictionary, | 62 const base::DictionaryValue* host_zoom_dictionary, |
60 bool sanitize_partition_host_zoom_levels); | 63 bool sanitize_partition_host_zoom_levels); |
61 | 64 |
62 // content::ZoomLevelDelegate | 65 // content::ZoomLevelDelegate |
63 void InitHostZoomMap(content::HostZoomMap* host_zoom_map) override; | 66 void InitHostZoomMap(content::HostZoomMap* host_zoom_map) override; |
64 | 67 |
| 68 bool GetIsOriginScopePref() const override; |
| 69 std::unique_ptr<DefaultZoomScopeSubscription> |
| 70 RegisterDefaultZoomScopeCallback(const base::Closure& callback) override; |
| 71 |
65 private: | 72 private: |
66 // This is a callback function that receives notifications from HostZoomMap | 73 // This is a callback function that receives notifications from HostZoomMap |
67 // when per-host zoom levels change. It is used to update the per-host | 74 // when per-host zoom levels change. It is used to update the per-host |
68 // zoom levels (if any) managed by this class (for its associated partition). | 75 // zoom levels (if any) managed by this class (for its associated partition). |
69 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | 76 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); |
70 | 77 |
71 PrefService* pref_service_; | 78 PrefService* pref_service_; |
72 base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager_; | 79 base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager_; |
73 content::HostZoomMap* host_zoom_map_; | 80 content::HostZoomMap* host_zoom_map_; |
74 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_; | 81 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_; |
75 std::string partition_key_; | 82 std::string partition_key_; |
76 base::CallbackList<void(void)> default_zoom_changed_callbacks_; | 83 base::CallbackList<void(void)> default_zoom_changed_callbacks_; |
| 84 base::CallbackList<void(void)> default_scope_changed_callbacks_; |
77 | 85 |
78 DISALLOW_COPY_AND_ASSIGN(ChromeZoomLevelPrefs); | 86 DISALLOW_COPY_AND_ASSIGN(ChromeZoomLevelPrefs); |
79 }; | 87 }; |
80 | 88 |
81 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ | 89 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ |
OLD | NEW |