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

Side by Side Diff: content/browser/host_zoom_map_impl.h

Issue 954923005: Make command-zero reset page scale in addition to zoom level (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again again Created 5 years, 9 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
« no previous file with comments | « components/ui/zoom/zoom_controller.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 11 matching lines...) Expand all
22 22
23 // HostZoomMap needs to be deleted on the UI thread because it listens 23 // HostZoomMap needs to be deleted on the UI thread because it listens
24 // to notifications on there (and holds a NotificationRegistrar). 24 // to notifications on there (and holds a NotificationRegistrar).
25 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), 25 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap),
26 public NotificationObserver { 26 public NotificationObserver {
27 public: 27 public:
28 HostZoomMapImpl(); 28 HostZoomMapImpl();
29 ~HostZoomMapImpl() override; 29 ~HostZoomMapImpl() override;
30 30
31 // HostZoomMap implementation: 31 // HostZoomMap implementation:
32 void SetPageScaleFactorIsOneForView(
33 int render_process_id, int render_view_id, bool is_one) override;
34 void ClearPageScaleFactorIsOneForView(
35 int render_process_id, int render_view_id) override;
32 void CopyFrom(HostZoomMap* copy) override; 36 void CopyFrom(HostZoomMap* copy) override;
33 double GetZoomLevelForHostAndScheme(const std::string& scheme, 37 double GetZoomLevelForHostAndScheme(const std::string& scheme,
34 const std::string& host) const override; 38 const std::string& host) const override;
35 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 39 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486
36 bool HasZoomLevel(const std::string& scheme, 40 bool HasZoomLevel(const std::string& scheme,
37 const std::string& host) const override; 41 const std::string& host) const override;
38 ZoomLevelVector GetAllZoomLevels() const override; 42 ZoomLevelVector GetAllZoomLevels() const override;
39 void SetZoomLevelForHost(const std::string& host, double level) override; 43 void SetZoomLevelForHost(const std::string& host, double level) override;
40 void SetZoomLevelForHostAndScheme(const std::string& scheme, 44 void SetZoomLevelForHostAndScheme(const std::string& scheme,
41 const std::string& host, 45 const std::string& host,
42 double level) override; 46 double level) override;
43 bool UsesTemporaryZoomLevel(int render_process_id, 47 bool UsesTemporaryZoomLevel(int render_process_id,
44 int render_view_id) const override; 48 int render_view_id) const override;
45 void SetTemporaryZoomLevel(int render_process_id, 49 void SetTemporaryZoomLevel(int render_process_id,
46 int render_view_id, 50 int render_view_id,
47 double level) override; 51 double level) override;
48 52
49 void ClearTemporaryZoomLevel(int render_process_id, 53 void ClearTemporaryZoomLevel(int render_process_id,
50 int render_view_id) override; 54 int render_view_id) override;
51 double GetDefaultZoomLevel() const override; 55 double GetDefaultZoomLevel() const override;
52 void SetDefaultZoomLevel(double level) override; 56 void SetDefaultZoomLevel(double level) override;
53 scoped_ptr<Subscription> AddZoomLevelChangedCallback( 57 scoped_ptr<Subscription> AddZoomLevelChangedCallback(
54 const ZoomLevelChangedCallback& callback) override; 58 const ZoomLevelChangedCallback& callback) override;
55 59
56 // Returns the current zoom level for the specified WebContents. This may 60 // Returns the current zoom level for the specified WebContents. This may
57 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). 61 // be a temporary zoom level, depending on UsesTemporaryZoomLevel().
58 double GetZoomLevelForWebContents( 62 double GetZoomLevelForWebContents(
59 const WebContentsImpl& web_contents_impl) const; 63 const WebContentsImpl& web_contents_impl) const;
60 64
65 bool PageScaleFactorIsOneForWebContents(
66 const WebContentsImpl& web_contents_impl) const;
67
61 // Sets the zoom level for this WebContents. If this WebContents is using 68 // Sets the zoom level for this WebContents. If this WebContents is using
62 // a temporary zoom level, then level is only applied to this WebContents. 69 // a temporary zoom level, then level is only applied to this WebContents.
63 // Otherwise, the level will be applied on a host level. 70 // Otherwise, the level will be applied on a host level.
64 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, 71 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl,
65 double level); 72 double level);
66 73
67 // Sets the zoom level for the specified view. The level may be set for only 74 // Sets the zoom level for the specified view. The level may be set for only
68 // this view, or for the host, depending on UsesTemporaryZoomLevel(). 75 // this view, or for the host, depending on UsesTemporaryZoomLevel().
69 void SetZoomLevelForView(int render_process_id, 76 void SetZoomLevelForView(int render_process_id,
70 int render_view_id, 77 int render_view_id,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 : render_process_id(render_process_id), 112 : render_process_id(render_process_id),
106 render_view_id(render_view_id) {} 113 render_view_id(render_view_id) {}
107 bool operator<(const RenderViewKey& other) const { 114 bool operator<(const RenderViewKey& other) const {
108 return render_process_id < other.render_process_id || 115 return render_process_id < other.render_process_id ||
109 ((render_process_id == other.render_process_id) && 116 ((render_process_id == other.render_process_id) &&
110 (render_view_id < other.render_view_id)); 117 (render_view_id < other.render_view_id));
111 } 118 }
112 }; 119 };
113 120
114 typedef std::map<RenderViewKey, double> TemporaryZoomLevels; 121 typedef std::map<RenderViewKey, double> TemporaryZoomLevels;
122 typedef std::map<RenderViewKey, bool> ViewPageScaleFactorsAreOne;
115 123
116 double GetZoomLevelForHost(const std::string& host) const; 124 double GetZoomLevelForHost(const std::string& host) const;
117 125
118 // Non-locked versions for internal use. These should only be called within 126 // Non-locked versions for internal use. These should only be called within
119 // a scope where a lock has been acquired. 127 // a scope where a lock has been acquired.
120 double GetZoomLevelForHostInternal(const std::string& host) const; 128 double GetZoomLevelForHostInternal(const std::string& host) const;
121 double GetZoomLevelForHostAndSchemeInternal(const std::string& scheme, 129 double GetZoomLevelForHostAndSchemeInternal(const std::string& scheme,
122 const std::string& host) const; 130 const std::string& host) const;
123 131
124 // Notifies the renderers from this browser context to change the zoom level 132 // Notifies the renderers from this browser context to change the zoom level
125 // for the specified host and scheme. 133 // for the specified host and scheme.
126 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 134 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486
127 void SendZoomLevelChange(const std::string& scheme, 135 void SendZoomLevelChange(const std::string& scheme,
128 const std::string& host, 136 const std::string& host,
129 double level); 137 double level);
130 138
131 // Callbacks called when zoom level changes. 139 // Callbacks called when zoom level changes.
132 base::CallbackList<void(const ZoomLevelChange&)> 140 base::CallbackList<void(const ZoomLevelChange&)>
133 zoom_level_changed_callbacks_; 141 zoom_level_changed_callbacks_;
134 142
135 // Copy of the pref data, so that we can read it on the IO thread. 143 // Copy of the pref data, so that we can read it on the IO thread.
136 HostZoomLevels host_zoom_levels_; 144 HostZoomLevels host_zoom_levels_;
137 SchemeHostZoomLevels scheme_host_zoom_levels_; 145 SchemeHostZoomLevels scheme_host_zoom_levels_;
138 double default_zoom_level_; 146 double default_zoom_level_;
139 147
148 // Page scale factor data for each renderer.
149 ViewPageScaleFactorsAreOne view_page_scale_factors_are_one_;
150
140 // Don't expect more than a couple of tabs that are using a temporary zoom 151 // Don't expect more than a couple of tabs that are using a temporary zoom
141 // level, so vector is fine for now. 152 // level, so vector is fine for now.
142 TemporaryZoomLevels temporary_zoom_levels_; 153 TemporaryZoomLevels temporary_zoom_levels_;
143 154
144 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 155 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_|,
145 // |temporary_zoom_levels_| to guarantee thread safety. 156 // |temporary_zoom_levels_|, and |view_page_scale_factors_are_one_| to
157 // guarantee thread safety.
146 mutable base::Lock lock_; 158 mutable base::Lock lock_;
147 159
148 NotificationRegistrar registrar_; 160 NotificationRegistrar registrar_;
149 161
150 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 162 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
151 }; 163 };
152 164
153 } // namespace content 165 } // namespace content
154 166
155 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 167 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW
« no previous file with comments | « components/ui/zoom/zoom_controller.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698