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

Side by Side Diff: components/zoom/zoom_controller.h

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: ... and tell closure_compiler. Created 3 years, 10 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/zoom/BUILD.gn ('k') | components/zoom/zoom_controller.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 COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_ 5 #ifndef COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_
6 #define COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_ 6 #define COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "components/prefs/pref_member.h" 15 #include "components/prefs/pref_member.h"
16 #include "components/zoom/zoom_prefs_delegate.h"
15 #include "content/public/browser/host_zoom_map.h" 17 #include "content/public/browser/host_zoom_map.h"
16 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/browser/web_contents_user_data.h" 19 #include "content/public/browser/web_contents_user_data.h"
20 #include "content/public/browser/zoom_level_delegate.h"
18 21
19 class ZoomControllerTest; 22 class ZoomControllerTest;
23 FORWARD_DECLARE_TEST(ZoomControllerTest, OnDefaultZoomScopeChanged);
24 FORWARD_DECLARE_TEST(ZoomControllerPerTabTest, OnDefaultZoomScopeChanged);
20 25
21 namespace content { 26 namespace content {
22 class WebContents; 27 class WebContents;
23 } 28 }
24 29
25 namespace zoom { 30 namespace zoom {
26 class ZoomObserver; 31 class ZoomObserver;
27 32
28 class ZoomRequestClient : public base::RefCounted<ZoomRequestClient> { 33 class ZoomRequestClient : public base::RefCounted<ZoomRequestClient> {
29 public: 34 public:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 double zoom_level, 146 double zoom_level,
142 const scoped_refptr<const ZoomRequestClient>& client); 147 const scoped_refptr<const ZoomRequestClient>& client);
143 148
144 // Sets the zoom mode, which defines zoom behavior (see enum ZoomMode). 149 // Sets the zoom mode, which defines zoom behavior (see enum ZoomMode).
145 void SetZoomMode(ZoomMode zoom_mode); 150 void SetZoomMode(ZoomMode zoom_mode);
146 151
147 // Set and query whether or not the page scale factor is one. 152 // Set and query whether or not the page scale factor is one.
148 void SetPageScaleFactorIsOneForTesting(bool is_one); 153 void SetPageScaleFactorIsOneForTesting(bool is_one);
149 bool PageScaleFactorIsOne() const; 154 bool PageScaleFactorIsOne() const;
150 155
156 // Called by TabStripModel to notify us when it replaces a tab's WebContents
157 // with another.
158 // Virtual for testing.
159 virtual void WebContentsReplaced(content::WebContents* new_web_contents);
160
151 // content::WebContentsObserver overrides: 161 // content::WebContentsObserver overrides:
152 void DidFinishNavigation( 162 void DidFinishNavigation(
153 content::NavigationHandle* navigation_handle) override; 163 content::NavigationHandle* navigation_handle) override;
154 void WebContentsDestroyed() override; 164 void WebContentsDestroyed() override;
155 void RenderFrameHostChanged(content::RenderFrameHost* old_host, 165 void RenderFrameHostChanged(content::RenderFrameHost* old_host,
156 content::RenderFrameHost* new_host) override; 166 content::RenderFrameHost* new_host) override;
167 void DidCloneToNewWebContents(
168 content::WebContents* old_web_contents,
169 content::WebContents* new_web_contents) override;
157 170
158 protected: 171 protected:
159 // Protected for testing. 172 // Protected for testing.
160 explicit ZoomController(content::WebContents* web_contents); 173 explicit ZoomController(content::WebContents* web_contents);
161 174
162 private: 175 private:
163 friend class content::WebContentsUserData<ZoomController>; 176 friend class content::WebContentsUserData<ZoomController>;
164 friend class ::ZoomControllerTest; 177 friend class ::ZoomControllerTest;
178 FRIEND_TEST_ALL_PREFIXES(::ZoomControllerTest, OnDefaultZoomScopeChanged);
179 FRIEND_TEST_ALL_PREFIXES(::ZoomControllerPerTabTest,
180 OnDefaultZoomScopeChanged);
165 181
166 void ResetZoomModeOnNavigationIfNeeded(const GURL& url); 182 void ResetZoomModeOnNavigationIfNeeded(const GURL& url);
183 void UpdateZoomModeOnScopeChangeIfNeeded();
184 void PreserveTemporaryZoomLevel(const content::HostZoomMap* old_zoom_map,
185 content::HostZoomMap* new_zoom_map,
186 content::RenderFrameHost* old_host,
187 content::RenderFrameHost* new_host) const;
188 void PreserveTemporaryZoomLevel(content::WebContents* old_web_contents,
189 content::WebContents* new_web_contents) const;
167 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); 190 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
191 void OnDefaultZoomScopeChanged();
168 192
169 // Updates the zoom icon and zoom percentage based on current values and 193 // Updates the zoom icon and zoom percentage based on current values and
170 // notifies the observer if changes have occurred. |host| may be empty, 194 // notifies the observer if changes have occurred. |host| may be empty,
171 // meaning the change should apply to ~all sites. If it is not empty, the 195 // meaning the change should apply to ~all sites. If it is not empty, the
172 // change only affects sites with the given host. 196 // change only affects sites with the given host.
173 void UpdateState(const std::string& host); 197 void UpdateState(const std::string& host);
174 198
175 // True if changes to zoom level can trigger the zoom notification bubble. 199 // True if changes to zoom level can trigger the zoom notification bubble.
176 bool can_show_bubble_; 200 bool can_show_bubble_;
177 201
178 // The current zoom mode. 202 // The current zoom mode.
179 ZoomMode zoom_mode_; 203 ZoomMode zoom_mode_;
180 204
205 // Whether zoom changes are by default scoped to a page's origin.
206 // If false, they are scoped to the tab.
207 bool default_scope_is_per_origin_;
208
181 // Current zoom level. 209 // Current zoom level.
182 double zoom_level_; 210 double zoom_level_;
183 211
184 std::unique_ptr<ZoomChangedEventData> event_data_; 212 std::unique_ptr<ZoomChangedEventData> event_data_;
185 213
186 // Keeps track of the extension (if any) that initiated the last zoom change 214 // Keeps track of the extension (if any) that initiated the last zoom change
187 // that took effect. 215 // that took effect.
188 scoped_refptr<const ZoomRequestClient> last_client_; 216 scoped_refptr<const ZoomRequestClient> last_client_;
189 217
190 // Observer receiving notifications on state changes. 218 // Observer receiving notifications on state changes.
191 base::ObserverList<ZoomObserver> observers_; 219 base::ObserverList<ZoomObserver> observers_;
192 220
193 content::BrowserContext* browser_context_; 221 content::BrowserContext* browser_context_;
194 // Keep track of the HostZoomMap we're currently subscribed to. 222 // Keep track of the HostZoomMap we're currently subscribed to.
195 content::HostZoomMap* host_zoom_map_; 223 content::HostZoomMap* host_zoom_map_;
196 224
197 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_; 225 std::unique_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
226 std::unique_ptr<ZoomPrefsDelegate::DefaultZoomScopeSubscription>
227 default_zoom_scope_subscription_;
198 228
199 DISALLOW_COPY_AND_ASSIGN(ZoomController); 229 DISALLOW_COPY_AND_ASSIGN(ZoomController);
200 }; 230 };
201 231
202 } // namespace zoom 232 } // namespace zoom
203 233
204 #endif // COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_ 234 #endif // COMPONENTS_ZOOM_ZOOM_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/zoom/BUILD.gn ('k') | components/zoom/zoom_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698