Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "chrome/browser/ui/browser_tabstrip.h" | 42 #include "chrome/browser/ui/browser_tabstrip.h" |
| 43 #include "chrome/browser/ui/browser_ui_prefs.h" | 43 #include "chrome/browser/ui/browser_ui_prefs.h" |
| 44 #include "chrome/browser/ui/browser_window.h" | 44 #include "chrome/browser/ui/browser_window.h" |
| 45 #include "chrome/browser/ui/extensions/app_launch_params.h" | 45 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 46 #include "chrome/browser/ui/extensions/application_launch.h" | 46 #include "chrome/browser/ui/extensions/application_launch.h" |
| 47 #include "chrome/browser/ui/host_desktop.h" | 47 #include "chrome/browser/ui/host_desktop.h" |
| 48 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 48 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 49 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 49 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 50 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 50 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 51 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 51 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 52 #include "chrome/browser/web_applications/web_app.h" | |
| 52 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 54 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 54 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
| 55 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
| 56 #include "chrome/grit/chromium_strings.h" | 57 #include "chrome/grit/chromium_strings.h" |
| 57 #include "chrome/grit/generated_resources.h" | 58 #include "chrome/grit/generated_resources.h" |
| 58 #include "chrome/test/base/in_process_browser_test.h" | 59 #include "chrome/test/base/in_process_browser_test.h" |
| 59 #include "chrome/test/base/test_switches.h" | 60 #include "chrome/test/base/test_switches.h" |
| 60 #include "chrome/test/base/ui_test_utils.h" | 61 #include "chrome/test/base/ui_test_utils.h" |
| 61 #include "components/app_modal/app_modal_dialog.h" | 62 #include "components/app_modal/app_modal_dialog.h" |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 ASSERT_TRUE(app_browser); | 1380 ASSERT_TRUE(app_browser); |
| 1380 ASSERT_TRUE(app_browser != browser()); | 1381 ASSERT_TRUE(app_browser != browser()); |
| 1381 | 1382 |
| 1382 EXPECT_FALSE( | 1383 EXPECT_FALSE( |
| 1383 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1384 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
| 1384 EXPECT_FALSE( | 1385 EXPECT_FALSE( |
| 1385 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1386 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
| 1386 | 1387 |
| 1387 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); | 1388 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
| 1388 } | 1389 } |
| 1390 | |
| 1391 // Check that the location bar is shown correctly for bookmark apps. | |
| 1392 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBarForBookmarkApp) { | |
| 1393 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1394 switches::kEnableNewBookmarkApps); | |
| 1395 ASSERT_TRUE(test_server()->Start()); | |
| 1396 | |
| 1397 // Setup the test server. | |
| 1398 host_resolver()->AddRule("www.foo.com", "127.0.0.1"); | |
| 1399 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
| 1400 | |
| 1401 // Load a http bookmark app. | |
| 1402 const Extension* http_bookmark_app = InstallExtensionWithSourceAndFlags( | |
| 1403 test_data_dir_.AppendASCII("app/"), | |
| 1404 1, | |
| 1405 extensions::Manifest::INTERNAL, | |
| 1406 extensions::Extension::FROM_BOOKMARK); | |
| 1407 ASSERT_TRUE(http_bookmark_app); | |
| 1408 | |
| 1409 // Load a https bookmark app. | |
| 1410 const Extension* https_bookmark_app = InstallExtensionWithSourceAndFlags( | |
| 1411 test_data_dir_.AppendASCII("https_app/"), | |
| 1412 1, | |
| 1413 extensions::Manifest::INTERNAL, | |
| 1414 extensions::Extension::FROM_BOOKMARK); | |
| 1415 ASSERT_TRUE(https_bookmark_app); | |
| 1416 | |
| 1417 // Load a https bookmark app. | |
| 1418 | |
| 1419 // Launch them in window. | |
| 1420 WebContents* app_window = OpenApplication(AppLaunchParams( | |
| 1421 browser()->profile(), http_bookmark_app, | |
| 1422 extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW, | |
| 1423 extensions::SOURCE_TEST)); | |
| 1424 ASSERT_TRUE(app_window); | |
| 1425 app_window = OpenApplication(AppLaunchParams( | |
| 1426 browser()->profile(), https_bookmark_app, | |
| 1427 extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW, | |
| 1428 extensions::SOURCE_TEST)); | |
| 1429 ASSERT_TRUE(app_window); | |
| 1430 | |
| 1431 // Find the new browsers. | |
| 1432 Browser* http_app_browser = NULL; | |
| 1433 Browser* https_app_browser = NULL; | |
| 1434 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
| 1435 if (*it == browser()) { | |
| 1436 continue; | |
| 1437 } else if (web_app::GetExtensionIdFromApplicationName((*it)->app_name()) == | |
|
Lei Zhang
2015/03/19 01:31:25
Just call GetExtensionIdFromApplicationName() once
benwells
2015/03/19 03:51:21
Done.
| |
| 1438 http_bookmark_app->id()) { | |
| 1439 http_app_browser = *it; | |
| 1440 } else if (web_app::GetExtensionIdFromApplicationName((*it)->app_name()) == | |
| 1441 https_bookmark_app->id()) { | |
| 1442 https_app_browser = *it; | |
| 1443 } | |
| 1444 } | |
| 1445 ASSERT_TRUE(http_app_browser); | |
| 1446 ASSERT_TRUE(https_app_browser); | |
| 1447 ASSERT_TRUE(http_app_browser != browser()); | |
| 1448 ASSERT_TRUE(https_app_browser != browser()); | |
| 1449 ASSERT_TRUE(http_app_browser != https_app_browser); | |
| 1450 | |
| 1451 // Navigate to the app's launch page; the location bar should be hidden. | |
| 1452 GURL url("http://www.example.com/empty.html"); | |
| 1453 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1454 EXPECT_FALSE( | |
| 1455 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1456 url = GURL("https://www.example.com/empty.html"); | |
| 1457 ui_test_utils::NavigateToURL(https_app_browser, url); | |
| 1458 EXPECT_FALSE( | |
| 1459 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1460 | |
| 1461 // Navigate to another page on the same origin; the location bar should still | |
| 1462 // hidden. | |
| 1463 url = GURL("http://www.example.com/blah"); | |
| 1464 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1465 EXPECT_FALSE( | |
| 1466 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1467 url = GURL("https://www.example.com/blah"); | |
| 1468 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1469 EXPECT_FALSE( | |
| 1470 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1471 | |
| 1472 // Navigate to the https version of the site; the location bar should | |
| 1473 // be hidden for both browsers. | |
| 1474 url = GURL("https://www.example.com/blah"); | |
| 1475 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1476 EXPECT_FALSE( | |
| 1477 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1478 ui_test_utils::NavigateToURL(https_app_browser, url); | |
| 1479 EXPECT_FALSE( | |
| 1480 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1481 | |
| 1482 // Navigate to the http version of the site; the location bar should | |
| 1483 // be visible for the https version as it is now on a less secure version | |
| 1484 // of its host. | |
| 1485 url = GURL("http://www.example.com/blah"); | |
| 1486 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1487 EXPECT_FALSE( | |
| 1488 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1489 ui_test_utils::NavigateToURL(https_app_browser, url); | |
| 1490 EXPECT_TRUE( | |
| 1491 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1492 | |
| 1493 // Navigate to different origin; the location bar should now be visible. | |
| 1494 url = GURL("http://www.foo.com/blah"); | |
| 1495 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1496 EXPECT_TRUE( | |
| 1497 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1498 ui_test_utils::NavigateToURL(https_app_browser, url); | |
| 1499 EXPECT_TRUE( | |
| 1500 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1501 | |
| 1502 // Navigate back to the app's origin; the location bar should now be hidden. | |
| 1503 url = GURL("http://www.example.com/blah"); | |
| 1504 ui_test_utils::NavigateToURL(http_app_browser, url); | |
| 1505 EXPECT_FALSE( | |
| 1506 http_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1507 url = GURL("https://www.example.com/blah"); | |
| 1508 ui_test_utils::NavigateToURL(https_app_browser, url); | |
| 1509 EXPECT_FALSE( | |
| 1510 https_app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | |
| 1511 } | |
| 1389 #endif | 1512 #endif |
| 1390 | 1513 |
| 1391 // Open a normal browser window, a hosted app window, a legacy packaged app | 1514 // Open a normal browser window, a hosted app window, a legacy packaged app |
| 1392 // window and a dev tools window, and check that the web app frame feature is | 1515 // window and a dev tools window, and check that the web app frame feature is |
| 1393 // supported correctly. | 1516 // supported correctly. |
| 1394 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldUseWebAppFrame) { | 1517 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldUseWebAppFrame) { |
| 1395 ASSERT_TRUE(test_server()->Start()); | 1518 ASSERT_TRUE(test_server()->Start()); |
| 1396 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1519 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1397 switches::kEnableWebAppFrame); | 1520 switches::kEnableWebAppFrame); |
| 1398 | 1521 |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2778 #endif | 2901 #endif |
| 2779 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2902 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
| 2780 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2903 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
| 2781 gfx::Size exp_final_size(initial_wcv_size); | 2904 gfx::Size exp_final_size(initial_wcv_size); |
| 2782 exp_final_size.Enlarge(wcv_resize_insets.width(), | 2905 exp_final_size.Enlarge(wcv_resize_insets.width(), |
| 2783 wcv_resize_insets.height() + height_inset); | 2906 wcv_resize_insets.height() + height_inset); |
| 2784 EXPECT_EQ(exp_final_size, | 2907 EXPECT_EQ(exp_final_size, |
| 2785 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2908 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
| 2786 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); | 2909 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); |
| 2787 } | 2910 } |
| OLD | NEW |