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 "content/public/browser/host_zoom_map.h" | 5 #include "content/public/browser/host_zoom_map.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 content::WebContents* web_contents = | 259 content::WebContents* web_contents = |
260 browser()->tab_strip_model()->GetActiveWebContents(); | 260 browser()->tab_strip_model()->GetActiveWebContents(); |
261 | 261 |
262 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); | 262 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); |
263 | 263 |
264 // For the webview based sign-in code, the sign in page uses the default host | 264 // For the webview based sign-in code, the sign in page uses the default host |
265 // zoom map. | 265 // zoom map. |
266 HostZoomMap* default_profile_host_zoom_map = | 266 HostZoomMap* default_profile_host_zoom_map = |
267 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); | 267 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); |
268 // Since ChromeOS still uses IFrame-based signin, we should expect the | 268 EXPECT_EQ(host_zoom_map, default_profile_host_zoom_map); |
269 // storage partition to be different if Webview signin is not enabled. | |
270 if (switches::IsEnableWebviewBasedSignin()) | |
271 EXPECT_EQ(host_zoom_map, default_profile_host_zoom_map); | |
272 else | |
273 EXPECT_NE(host_zoom_map, default_profile_host_zoom_map); | |
274 } | |
275 | |
276 class HostZoomMapIframeSigninBrowserTest : public HostZoomMapBrowserTest { | |
277 public: | |
278 void SetUpCommandLine(base::CommandLine* command_line) override { | |
279 command_line->AppendSwitch(switches::kEnableIframeBasedSignin); | |
280 } | |
281 }; | |
282 | |
283 // Regression test for crbug.com/435017. | |
284 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest, | |
285 EventsForNonDefaultStoragePartition) { | |
286 ZoomLevelChangeObserver observer(browser()->profile()); | |
287 // TODO(wjmaclean): Make this test more general by implementing a way to | |
288 // force a generic URL to be loaded in a non-default storage partition. This | |
289 // test currently relies on the signin page being loaded into a non-default | |
290 // storage partition (and verifies this is the case), but ultimately it would | |
291 // be better not to rely on what the signin page is doing. | |
292 GURL test_url = ConstructTestServerURL(GetSigninPromoURL().c_str()); | |
293 std::string test_host(test_url.host()); | |
294 std::string test_scheme(test_url.scheme()); | |
295 ui_test_utils::NavigateToURL(browser(), test_url); | |
296 | |
297 content::WebContents* web_contents = | |
298 browser()->tab_strip_model()->GetActiveWebContents(); | |
299 | |
300 // We are forcing non-webview based signin, so we expect the signin page to | |
301 // be in a different storage partition, and hence a different HostZoomMap. | |
302 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); | |
303 | |
304 EXPECT_FALSE(switches::IsEnableWebviewBasedSignin()); | |
305 HostZoomMap* default_profile_host_zoom_map = | |
306 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); | |
307 EXPECT_NE(host_zoom_map, default_profile_host_zoom_map); | |
308 | |
309 double new_zoom_level = | |
310 host_zoom_map->GetZoomLevelForHostAndScheme(test_scheme, test_host) + 0.5; | |
311 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host, | |
312 new_zoom_level); | |
313 observer.BlockUntilZoomLevelForHostHasChanged(test_host); | |
314 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme( | |
315 test_scheme, test_host)); | |
316 } | 269 } |
317 | 270 |
318 // Regression test for crbug.com/364399. | 271 // Regression test for crbug.com/364399. |
319 IN_PROC_BROWSER_TEST_F(HostZoomMapBrowserTest, ToggleDefaultZoomLevel) { | 272 IN_PROC_BROWSER_TEST_F(HostZoomMapBrowserTest, ToggleDefaultZoomLevel) { |
320 const double default_zoom_level = content::ZoomFactorToZoomLevel(1.5); | 273 const double default_zoom_level = content::ZoomFactorToZoomLevel(1.5); |
321 | 274 |
322 const char kTestURLTemplate1[] = "http://host1:%u/"; | 275 const char kTestURLTemplate1[] = "http://host1:%u/"; |
323 const char kTestURLTemplate2[] = "http://host2:%u/"; | 276 const char kTestURLTemplate2[] = "http://host2:%u/"; |
324 | 277 |
325 ZoomLevelChangeObserver observer(browser()->profile()); | 278 ZoomLevelChangeObserver observer(browser()->profile()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 ZoomLevelChangeObserver observer(browser()->profile()); | 407 ZoomLevelChangeObserver observer(browser()->profile()); |
455 | 408 |
456 web_contents->SetPageScale(1.5); | 409 web_contents->SetPageScale(1.5); |
457 observer.BlockUntilZoomLevelForHostHasChanged(test_host); | 410 observer.BlockUntilZoomLevelForHostHasChanged(test_host); |
458 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); | 411 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); |
459 | 412 |
460 web_contents->SetPageScale(1.f); | 413 web_contents->SetPageScale(1.f); |
461 observer.BlockUntilZoomLevelForHostHasChanged(test_host); | 414 observer.BlockUntilZoomLevelForHostHasChanged(test_host); |
462 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); | 415 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); |
463 } | 416 } |
OLD | NEW |