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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 content::WebContents* web_contents = | 251 content::WebContents* web_contents = |
252 browser()->tab_strip_model()->GetActiveWebContents(); | 252 browser()->tab_strip_model()->GetActiveWebContents(); |
253 | 253 |
254 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); | 254 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); |
255 | 255 |
256 // For the webview based sign-in code, the sign in page uses the default host | 256 // For the webview based sign-in code, the sign in page uses the default host |
257 // zoom map. | 257 // zoom map. |
258 HostZoomMap* default_profile_host_zoom_map = | 258 HostZoomMap* default_profile_host_zoom_map = |
259 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); | 259 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); |
260 // Since ChromeOS still uses IFrame-based signin, we should expect the | 260 EXPECT_EQ(host_zoom_map, default_profile_host_zoom_map); |
261 // storage partition to be different if Webview signin is not enabled. | |
262 if (switches::IsEnableWebviewBasedSignin()) | |
263 EXPECT_EQ(host_zoom_map, default_profile_host_zoom_map); | |
264 else | |
265 EXPECT_NE(host_zoom_map, default_profile_host_zoom_map); | |
266 } | 261 } |
267 | 262 |
268 class HostZoomMapIframeSigninBrowserTest : public HostZoomMapBrowserTest { | 263 class HostZoomMapIframeSigninBrowserTest : public HostZoomMapBrowserTest { |
269 public: | |
270 void SetUpCommandLine(base::CommandLine* command_line) override { | |
271 command_line->AppendSwitch(switches::kEnableIframeBasedSignin); | |
272 } | |
273 }; | 264 }; |
274 | 265 |
275 // Regression test for crbug.com/435017. | 266 // Regression test for crbug.com/435017. |
276 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest, | 267 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest, |
277 EventsForNonDefaultStoragePartition) { | 268 EventsForNonDefaultStoragePartition) { |
278 ZoomLevelChangeObserver observer(browser()->profile()); | 269 ZoomLevelChangeObserver observer(browser()->profile()); |
279 // TODO(wjmaclean): Make this test more general by implementing a way to | 270 // TODO(wjmaclean): Make this test more general by implementing a way to |
280 // force a generic URL to be loaded in a non-default storage partition. This | 271 // force a generic URL to be loaded in a non-default storage partition. This |
281 // test currently relies on the signin page being loaded into a non-default | 272 // test currently relies on the signin page being loaded into a non-default |
282 // storage partition (and verifies this is the case), but ultimately it would | 273 // storage partition (and verifies this is the case), but ultimately it would |
283 // be better not to rely on what the signin page is doing. | 274 // be better not to rely on what the signin page is doing. |
284 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); | 275 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); |
285 std::string test_host(test_url.host()); | 276 std::string test_host(test_url.host()); |
286 std::string test_scheme(test_url.scheme()); | 277 std::string test_scheme(test_url.scheme()); |
287 ui_test_utils::NavigateToURL(browser(), test_url); | 278 ui_test_utils::NavigateToURL(browser(), test_url); |
288 | 279 |
289 content::WebContents* web_contents = | 280 content::WebContents* web_contents = |
290 browser()->tab_strip_model()->GetActiveWebContents(); | 281 browser()->tab_strip_model()->GetActiveWebContents(); |
291 | 282 |
292 // We are forcing non-webview based signin, so we expect the signin page to | 283 // We are forcing non-webview based signin, so we expect the signin page to |
293 // be in a different storage partition, and hence a different HostZoomMap. | 284 // be in a different storage partition, and hence a different HostZoomMap. |
294 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); | 285 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); |
295 | 286 |
296 EXPECT_FALSE(switches::IsEnableWebviewBasedSignin()); | |
297 HostZoomMap* default_profile_host_zoom_map = | 287 HostZoomMap* default_profile_host_zoom_map = |
298 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); | 288 HostZoomMap::GetDefaultForBrowserContext(browser()->profile()); |
299 EXPECT_NE(host_zoom_map, default_profile_host_zoom_map); | 289 EXPECT_EQ(host_zoom_map, default_profile_host_zoom_map); |
300 | 290 |
301 double new_zoom_level = | 291 double new_zoom_level = |
302 host_zoom_map->GetZoomLevelForHostAndScheme(test_scheme, test_host) + 0.5; | 292 host_zoom_map->GetZoomLevelForHostAndScheme(test_scheme, test_host) + 0.5; |
303 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host, | 293 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host, |
304 new_zoom_level); | 294 new_zoom_level); |
305 observer.BlockUntilZoomLevelForHostHasChanged(test_host); | 295 observer.BlockUntilZoomLevelForHostHasChanged(test_host); |
306 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme( | 296 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme( |
307 test_scheme, test_host)); | 297 test_scheme, test_host)); |
308 } | 298 } |
309 | 299 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 HostZoomMap::GetDefaultForBrowserContext(child_profile); | 415 HostZoomMap::GetDefaultForBrowserContext(child_profile); |
426 ASSERT_TRUE(parent_host_zoom_map); | 416 ASSERT_TRUE(parent_host_zoom_map); |
427 ASSERT_TRUE(child_host_zoom_map); | 417 ASSERT_TRUE(child_host_zoom_map); |
428 EXPECT_NE(parent_host_zoom_map, child_host_zoom_map); | 418 EXPECT_NE(parent_host_zoom_map, child_host_zoom_map); |
429 EXPECT_NE(new_default_zoom_level, child_host_zoom_map->GetDefaultZoomLevel()); | 419 EXPECT_NE(new_default_zoom_level, child_host_zoom_map->GetDefaultZoomLevel()); |
430 | 420 |
431 parent_profile->GetZoomLevelPrefs()->SetDefaultZoomLevelPref( | 421 parent_profile->GetZoomLevelPrefs()->SetDefaultZoomLevelPref( |
432 new_default_zoom_level); | 422 new_default_zoom_level); |
433 EXPECT_EQ(new_default_zoom_level, child_host_zoom_map->GetDefaultZoomLevel()); | 423 EXPECT_EQ(new_default_zoom_level, child_host_zoom_map->GetDefaultZoomLevel()); |
434 } | 424 } |
OLD | NEW |