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 #include "components/ui/zoom/zoom_controller.h" | 5 #include "components/ui/zoom/zoom_controller.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 content::WebContents* web_contents = | 131 content::WebContents* web_contents = |
132 browser()->tab_strip_model()->GetActiveWebContents(); | 132 browser()->tab_strip_model()->GetActiveWebContents(); |
133 double new_default_zoom_level = 1.0; | 133 double new_default_zoom_level = 1.0; |
134 // Since this page uses the default zoom level, the changes to the default | 134 // Since this page uses the default zoom level, the changes to the default |
135 // zoom level will change the zoom level for this web_contents. | 135 // zoom level will change the zoom level for this web_contents. |
136 ZoomController::ZoomChangedEventData zoom_change_data( | 136 ZoomController::ZoomChangedEventData zoom_change_data( |
137 web_contents, | 137 web_contents, |
138 new_default_zoom_level, | 138 new_default_zoom_level, |
139 new_default_zoom_level, | 139 new_default_zoom_level, |
140 ZoomController::ZOOM_MODE_DEFAULT, | 140 ZoomController::ZOOM_MODE_DEFAULT, |
141 true); | 141 false); |
142 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); | 142 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); |
143 // TODO(wjmaclean): Convert this to call partition-specific zoom level prefs | 143 // TODO(wjmaclean): Convert this to call partition-specific zoom level prefs |
144 // when they become available. | 144 // when they become available. |
145 browser()->profile()->GetZoomLevelPrefs()->SetDefaultZoomLevelPref( | 145 browser()->profile()->GetZoomLevelPrefs()->SetDefaultZoomLevelPref( |
146 new_default_zoom_level); | 146 new_default_zoom_level); |
147 // Because this test relies on a round-trip IPC to/from the renderer process, | 147 // Because this test relies on a round-trip IPC to/from the renderer process, |
148 // we need to wait for it to propagate. | 148 // we need to wait for it to propagate. |
149 zoom_change_watcher.Wait(); | 149 zoom_change_watcher.Wait(); |
150 } | 150 } |
151 | 151 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 browser()->tab_strip_model()->GetActiveWebContents(); | 225 browser()->tab_strip_model()->GetActiveWebContents(); |
226 | 226 |
227 double new_zoom_level = 1.0; | 227 double new_zoom_level = 1.0; |
228 // When the event is initiated from HostZoomMap, the old zoom level is not | 228 // When the event is initiated from HostZoomMap, the old zoom level is not |
229 // available. | 229 // available. |
230 ZoomController::ZoomChangedEventData zoom_change_data( | 230 ZoomController::ZoomChangedEventData zoom_change_data( |
231 web_contents, | 231 web_contents, |
232 new_zoom_level, | 232 new_zoom_level, |
233 new_zoom_level, | 233 new_zoom_level, |
234 ZoomController::ZOOM_MODE_DEFAULT, | 234 ZoomController::ZOOM_MODE_DEFAULT, |
235 true); // We have a non-empty host, so this will be 'true'. | 235 false); // The ZoomController did not initiate, so this will be 'false'. |
236 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); | 236 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); |
237 | 237 |
238 content::HostZoomMap* host_zoom_map = | 238 content::HostZoomMap* host_zoom_map = |
239 content::HostZoomMap::GetDefaultForBrowserContext( | 239 content::HostZoomMap::GetDefaultForBrowserContext( |
240 web_contents->GetBrowserContext()); | 240 web_contents->GetBrowserContext()); |
241 | 241 |
242 host_zoom_map->SetZoomLevelForHost("about:blank", new_zoom_level); | 242 host_zoom_map->SetZoomLevelForHost("about:blank", new_zoom_level); |
243 zoom_change_watcher.Wait(); | 243 zoom_change_watcher.Wait(); |
244 } | 244 } |
245 | 245 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 web_contents, | 314 web_contents, |
315 old_zoom_level, | 315 old_zoom_level, |
316 new_zoom_level, | 316 new_zoom_level, |
317 ZoomController::ZOOM_MODE_DEFAULT, | 317 ZoomController::ZOOM_MODE_DEFAULT, |
318 true); // We have a non-empty host, so this will be 'true'. | 318 true); // We have a non-empty host, so this will be 'true'. |
319 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); | 319 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); |
320 zoom_controller->SetZoomLevel(new_zoom_level); | 320 zoom_controller->SetZoomLevel(new_zoom_level); |
321 zoom_change_watcher.Wait(); | 321 zoom_change_watcher.Wait(); |
322 } | 322 } |
323 #endif // !defined(OS_CHROMEOS) | 323 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |