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

Side by Side Diff: content/public/browser/host_zoom_map.h

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: Add more tests. Created 3 years, 11 months 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
OLDNEW
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_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_
6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/callback_list.h" 14 #include "base/callback_list.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class NavigationEntry; 20 class NavigationEntry;
21 class BrowserContext; 21 class BrowserContext;
22 class RenderFrameHost;
22 class SiteInstance; 23 class SiteInstance;
23 class WebContents; 24 class WebContents;
24 25
25 // Maps hostnames to custom zoom levels. Written on the UI thread and read on 26 // Maps hostnames to custom zoom levels. Written on the UI thread and read on
26 // any thread. One instance per browser context. Must be created on the UI 27 // any thread. One instance per browser context. Must be created on the UI
27 // thread, and it'll delete itself on the UI thread as well. 28 // thread, and it'll delete itself on the UI thread as well.
28 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom 29 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom
29 // for host with specific scheme. Setting any of the levels leaves settings 30 // for host with specific scheme. Setting any of the levels leaves settings
30 // for other settings intact. Getting the zoom level starts at the most 31 // for other settings intact. Getting the zoom level starts at the most
31 // specific setting and progresses to the less specific: first the zoom for the 32 // specific setting and progresses to the less specific: first the zoom for the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Set or clear whether or not the page scale factor for a view is one. 96 // Set or clear whether or not the page scale factor for a view is one.
96 virtual void SetPageScaleFactorIsOneForView( 97 virtual void SetPageScaleFactorIsOneForView(
97 int render_process_id, int render_view_id, bool is_one) = 0; 98 int render_process_id, int render_view_id, bool is_one) = 0;
98 virtual void ClearPageScaleFactorIsOneForView( 99 virtual void ClearPageScaleFactorIsOneForView(
99 int render_process_id, int render_view_id) = 0; 100 int render_process_id, int render_view_id) = 0;
100 101
101 // Copy the zoom levels from the given map. Can only be called on the UI 102 // Copy the zoom levels from the given map. Can only be called on the UI
102 // thread. 103 // thread.
103 virtual void CopyFrom(HostZoomMap* copy) = 0; 104 virtual void CopyFrom(HostZoomMap* copy) = 0;
104 105
106 // Copy the temporary zoom level entry of |old_host| from the given map to
107 // this map's entry for |new_host|.
108 virtual void PreserveTemporaryZoomLevelFrom(
109 const HostZoomMap* copy, RenderFrameHost* old_host,
110 RenderFrameHost* new_host) = 0;
111
105 // Here |host| is the host portion of URL, or (in the absence of a host) 112 // Here |host| is the host portion of URL, or (in the absence of a host)
106 // the complete spec of the URL. 113 // the complete spec of the URL.
107 // Returns the zoom for the specified |scheme| and |host|. See class 114 // Returns the zoom for the specified |scheme| and |host|. See class
108 // description for details. 115 // description for details.
109 // 116 //
110 // This may be called on any thread. 117 // This may be called on any thread.
111 virtual double GetZoomLevelForHostAndScheme( 118 virtual double GetZoomLevelForHostAndScheme(
112 const std::string& scheme, 119 const std::string& scheme,
113 const std::string& host) const = 0; 120 const std::string& host) const = 0;
114 121
(...skipping 26 matching lines...) Expand all
141 // This should only be called on the UI thread. 148 // This should only be called on the UI thread.
142 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme, 149 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme,
143 const std::string& host, 150 const std::string& host,
144 double level) = 0; 151 double level) = 0;
145 152
146 // Returns whether the view manages its zoom level independently of other 153 // Returns whether the view manages its zoom level independently of other
147 // views displaying content from the same host. 154 // views displaying content from the same host.
148 virtual bool UsesTemporaryZoomLevel(int render_process_id, 155 virtual bool UsesTemporaryZoomLevel(int render_process_id,
149 int render_view_id) const = 0; 156 int render_view_id) const = 0;
150 157
151 // Sets the temporary zoom level that's only valid for the lifetime of this 158 // Sets the temporary zoom level that's only valid for the lifetime of the
152 // WebContents. 159 // given view.
153 // 160 //
154 // This should only be called on the UI thread. 161 // This should only be called on the UI thread.
155 virtual void SetTemporaryZoomLevel(int render_process_id, 162 virtual void SetTemporaryZoomLevel(int render_process_id,
156 int render_view_id, 163 int render_view_id,
157 double level) = 0; 164 double level) = 0;
158 165
159 // Clears the temporary zoom level stored for this WebContents. 166 // Clears the temporary zoom level stored for the given view.
160 // 167 //
161 // This should only be called on the UI thread. 168 // This should only be called on the UI thread.
162 virtual void ClearTemporaryZoomLevel(int render_process_id, 169 virtual void ClearTemporaryZoomLevel(int render_process_id,
163 int render_view_id) = 0; 170 int render_view_id) = 0;
164 171
165 // Get/Set the default zoom level for pages that don't override it. 172 // Get/Set the default zoom level for pages that don't override it.
166 virtual double GetDefaultZoomLevel() const = 0; 173 virtual double GetDefaultZoomLevel() const = 0;
167 virtual void SetDefaultZoomLevel(double level) = 0; 174 virtual void SetDefaultZoomLevel(double level) = 0;
168 175
169 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback; 176 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback;
170 typedef base::CallbackList<void(const ZoomLevelChange&)>::Subscription 177 typedef base::CallbackList<void(const ZoomLevelChange&)>::Subscription
171 Subscription; 178 Subscription;
172 // Add and remove zoom level changed callbacks. 179 // Add and remove zoom level changed callbacks.
173 virtual std::unique_ptr<Subscription> AddZoomLevelChangedCallback( 180 virtual std::unique_ptr<Subscription> AddZoomLevelChangedCallback(
174 const ZoomLevelChangedCallback& callback) = 0; 181 const ZoomLevelChangedCallback& callback) = 0;
175 182
176 protected: 183 protected:
177 virtual ~HostZoomMap() {} 184 virtual ~HostZoomMap() {}
178 }; 185 };
179 186
180 } // namespace content 187 } // namespace content
181 188
182 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 189 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698