OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... |
34 const std::string& scheme, | 34 const std::string& scheme, |
35 const std::string& host) const OVERRIDE; | 35 const std::string& host) const OVERRIDE; |
36 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE; | 36 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE; |
37 virtual void SetZoomLevelForHost( | 37 virtual void SetZoomLevelForHost( |
38 const std::string& host, | 38 const std::string& host, |
39 double level) OVERRIDE; | 39 double level) OVERRIDE; |
40 virtual void SetZoomLevelForHostAndScheme( | 40 virtual void SetZoomLevelForHostAndScheme( |
41 const std::string& scheme, | 41 const std::string& scheme, |
42 const std::string& host, | 42 const std::string& host, |
43 double level) OVERRIDE; | 43 double level) OVERRIDE; |
| 44 virtual void SetTemporaryZoomLevel(int render_process_id, |
| 45 int render_view_id, |
| 46 const std::string& host, |
| 47 double level) OVERRIDE; |
| 48 virtual void EraseTemporaryZoomLevel(int render_process_id, |
| 49 int render_view_id) OVERRIDE; |
44 virtual double GetDefaultZoomLevel() const OVERRIDE; | 50 virtual double GetDefaultZoomLevel() const OVERRIDE; |
45 virtual void SetDefaultZoomLevel(double level) OVERRIDE; | 51 virtual void SetDefaultZoomLevel(double level) OVERRIDE; |
46 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 52 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
47 const ZoomLevelChangedCallback& callback) OVERRIDE; | 53 const ZoomLevelChangedCallback& callback) OVERRIDE; |
48 | 54 |
49 // Returns the current zoom level for the specified WebContents. This may | 55 // Returns the current zoom level for the specified WebContents. This may |
50 // be a temporary zoom level, depending on UsesTemporarySoomLevel(). | 56 // be a temporary zoom level, depending on UsesTemporarySoomLevel(). |
51 double GetZoomLevelForWebContents( | 57 double GetZoomLevelForWebContents( |
52 const WebContents& web_contents) const; | 58 const WebContents& web_contents) const; |
53 | 59 |
(...skipping 22 matching lines...) Expand all Loading... |
76 bool uses_temporary_zoom_settings); | 82 bool uses_temporary_zoom_settings); |
77 | 83 |
78 // Returns the temporary zoom level that's only valid for the lifetime of | 84 // Returns the temporary zoom level that's only valid for the lifetime of |
79 // the given WebContents (i.e. isn't saved and doesn't affect other | 85 // the given WebContents (i.e. isn't saved and doesn't affect other |
80 // WebContentses) if it exists, the default zoom level otherwise. | 86 // WebContentses) if it exists, the default zoom level otherwise. |
81 // | 87 // |
82 // This may be called on any thread. | 88 // This may be called on any thread. |
83 double GetTemporaryZoomLevel(int render_process_id, | 89 double GetTemporaryZoomLevel(int render_process_id, |
84 int render_view_id) const; | 90 int render_view_id) const; |
85 | 91 |
86 // Sets the temporary zoom level that's only valid for the lifetime of this | |
87 // WebContents. | |
88 // | |
89 // This should only be called on the UI thread. | |
90 void SetTemporaryZoomLevel(int render_process_id, | |
91 int render_view_id, | |
92 double level); | |
93 | |
94 // NotificationObserver implementation. | 92 // NotificationObserver implementation. |
95 virtual void Observe(int type, | 93 virtual void Observe(int type, |
96 const NotificationSource& source, | 94 const NotificationSource& source, |
97 const NotificationDetails& details) OVERRIDE; | 95 const NotificationDetails& details) OVERRIDE; |
98 | 96 |
99 private: | 97 private: |
100 double GetZoomLevelForHost(const std::string& host) const; | 98 double GetZoomLevelForHost(const std::string& host) const; |
101 | 99 |
| 100 // Notifies the renderers from this browser context to change the zoom level |
| 101 // for the specified host and scheme. |
| 102 void SendZoomLevelChange(const std::string& scheme, |
| 103 const std::string& host, |
| 104 double level); |
| 105 |
102 typedef std::map<std::string, double> HostZoomLevels; | 106 typedef std::map<std::string, double> HostZoomLevels; |
103 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; | 107 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; |
104 | 108 |
105 // Callbacks called when zoom level changes. | 109 // Callbacks called when zoom level changes. |
106 base::CallbackList<void(const ZoomLevelChange&)> | 110 base::CallbackList<void(const ZoomLevelChange&)> |
107 zoom_level_changed_callbacks_; | 111 zoom_level_changed_callbacks_; |
108 | 112 |
109 // Copy of the pref data, so that we can read it on the IO thread. | 113 // Copy of the pref data, so that we can read it on the IO thread. |
110 HostZoomLevels host_zoom_levels_; | 114 HostZoomLevels host_zoom_levels_; |
111 SchemeHostZoomLevels scheme_host_zoom_levels_; | 115 SchemeHostZoomLevels scheme_host_zoom_levels_; |
(...skipping 30 matching lines...) Expand all Loading... |
142 mutable base::Lock lock_; | 146 mutable base::Lock lock_; |
143 | 147 |
144 NotificationRegistrar registrar_; | 148 NotificationRegistrar registrar_; |
145 | 149 |
146 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 150 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
147 }; | 151 }; |
148 | 152 |
149 } // namespace content | 153 } // namespace content |
150 | 154 |
151 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 155 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
OLD | NEW |