| 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "chrome/browser/ui/browser_commands.h" | 49 #include "chrome/browser/ui/browser_commands.h" |
| 50 #include "chrome/browser/ui/browser_finder.h" | 50 #include "chrome/browser/ui/browser_finder.h" |
| 51 #include "chrome/browser/ui/browser_list.h" | 51 #include "chrome/browser/ui/browser_list.h" |
| 52 #include "chrome/browser/ui/browser_tabstrip.h" | 52 #include "chrome/browser/ui/browser_tabstrip.h" |
| 53 #include "chrome/browser/ui/browser_ui_prefs.h" | 53 #include "chrome/browser/ui/browser_ui_prefs.h" |
| 54 #include "chrome/browser/ui/browser_window.h" | 54 #include "chrome/browser/ui/browser_window.h" |
| 55 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 55 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| 56 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 56 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 57 #include "chrome/browser/ui/extensions/app_launch_params.h" | 57 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 58 #include "chrome/browser/ui/extensions/application_launch.h" | 58 #include "chrome/browser/ui/extensions/application_launch.h" |
| 59 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 59 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 60 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 60 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 61 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 61 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 62 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 62 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 63 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 63 #include "chrome/common/chrome_paths.h" | 64 #include "chrome/common/chrome_paths.h" |
| 64 #include "chrome/common/chrome_switches.h" | 65 #include "chrome/common/chrome_switches.h" |
| 65 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 66 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 66 #include "chrome/common/pref_names.h" | 67 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/url_constants.h" | 68 #include "chrome/common/url_constants.h" |
| 68 #include "chrome/grit/chromium_strings.h" | 69 #include "chrome/grit/chromium_strings.h" |
| 69 #include "chrome/grit/generated_resources.h" | 70 #include "chrome/grit/generated_resources.h" |
| 70 #include "chrome/test/base/in_process_browser_test.h" | 71 #include "chrome/test/base/in_process_browser_test.h" |
| 71 #include "chrome/test/base/ui_test_utils.h" | 72 #include "chrome/test/base/ui_test_utils.h" |
| 72 #include "components/app_modal/app_modal_dialog.h" | 73 #include "components/app_modal/app_modal_dialog.h" |
| 73 #include "components/app_modal/app_modal_dialog_queue.h" | 74 #include "components/app_modal/app_modal_dialog_queue.h" |
| 74 #include "components/app_modal/javascript_app_modal_dialog.h" | 75 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 75 #include "components/app_modal/native_app_modal_dialog.h" | 76 #include "components/app_modal/native_app_modal_dialog.h" |
| 76 #include "components/content_settings/core/browser/host_content_settings_map.h" | 77 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 78 #include "components/omnibox/common/omnibox_focus_state.h" |
| 77 #include "components/prefs/pref_service.h" | 79 #include "components/prefs/pref_service.h" |
| 78 #include "components/sessions/core/base_session_service_test_helper.h" | 80 #include "components/sessions/core/base_session_service_test_helper.h" |
| 79 #include "components/translate/core/browser/language_state.h" | 81 #include "components/translate/core/browser/language_state.h" |
| 80 #include "components/translate/core/common/language_detection_details.h" | 82 #include "components/translate/core/common/language_detection_details.h" |
| 81 #include "content/public/browser/favicon_status.h" | 83 #include "content/public/browser/favicon_status.h" |
| 82 #include "content/public/browser/host_zoom_map.h" | 84 #include "content/public/browser/host_zoom_map.h" |
| 83 #include "content/public/browser/interstitial_page.h" | 85 #include "content/public/browser/interstitial_page.h" |
| 84 #include "content/public/browser/interstitial_page_delegate.h" | 86 #include "content/public/browser/interstitial_page_delegate.h" |
| 85 #include "content/public/browser/navigation_entry.h" | 87 #include "content/public/browser/navigation_entry.h" |
| 86 #include "content/public/browser/navigation_handle.h" | 88 #include "content/public/browser/navigation_handle.h" |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1510 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
| 1509 | 1511 |
| 1510 // App windows can show location bars, for example when they navigate away | 1512 // App windows can show location bars, for example when they navigate away |
| 1511 // from their starting origin. | 1513 // from their starting origin. |
| 1512 EXPECT_TRUE( | 1514 EXPECT_TRUE( |
| 1513 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1515 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
| 1514 | 1516 |
| 1515 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); | 1517 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
| 1516 } | 1518 } |
| 1517 | 1519 |
| 1520 // Regression test for crbug.com/702505. |
| 1521 IN_PROC_BROWSER_TEST_F(BrowserTest, ReattachDevToolsWindow) { |
| 1522 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1523 WebContents* web_contents = |
| 1524 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1525 GURL ntp_url = search::GetNewTabPageURL(browser()->profile()); |
| 1526 ui_test_utils::NavigateToURL(browser(), ntp_url); |
| 1527 |
| 1528 // Open a devtools window. |
| 1529 DevToolsWindow* devtools_window = |
| 1530 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), |
| 1531 /*is_docked=*/true); |
| 1532 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
| 1533 |
| 1534 // Grab its main web contents. |
| 1535 content::WebContents* devtools_main_web_contents = |
| 1536 DevToolsWindow::GetInTabWebContents( |
| 1537 devtools_window->GetInspectedWebContents(), nullptr); |
| 1538 ASSERT_NE(web_contents, devtools_main_web_contents); |
| 1539 |
| 1540 // Detach the devtools window. |
| 1541 DevToolsUIBindings::Delegate* devtools_delegate = |
| 1542 static_cast<DevToolsUIBindings::Delegate*>(devtools_window); |
| 1543 devtools_delegate->SetIsDocked(false); |
| 1544 // This should have created a new dev tools browser. |
| 1545 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
| 1546 |
| 1547 // Re-attach the dev tools window. This resets its Browser*. |
| 1548 devtools_delegate->SetIsDocked(true); |
| 1549 // Wait until the browser actually gets closed. |
| 1550 content::RunAllPendingInMessageLoop(); |
| 1551 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
| 1552 |
| 1553 // Do something that will make SearchTabHelper access its OmniboxView. This |
| 1554 // should not crash, even though the Browser association and thus the |
| 1555 // OmniboxView* has changed, and the old OmniboxView has been deleted. |
| 1556 SearchTabHelper* search_tab_helper = |
| 1557 SearchTabHelper::FromWebContents(devtools_main_web_contents); |
| 1558 SearchIPCRouter::Delegate* search_ipc_router_delegate = |
| 1559 static_cast<SearchIPCRouter::Delegate*>(search_tab_helper); |
| 1560 search_ipc_router_delegate->FocusOmnibox(OMNIBOX_FOCUS_INVISIBLE); |
| 1561 |
| 1562 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
| 1563 } |
| 1564 |
| 1518 // Chromeos defaults to restoring the last session, so this test isn't | 1565 // Chromeos defaults to restoring the last session, so this test isn't |
| 1519 // applicable. | 1566 // applicable. |
| 1520 #if !defined(OS_CHROMEOS) | 1567 #if !defined(OS_CHROMEOS) |
| 1521 // Makes sure pinned tabs are restored correctly on start. | 1568 // Makes sure pinned tabs are restored correctly on start. |
| 1522 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 1569 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
| 1523 ASSERT_TRUE(embedded_test_server()->Start()); | 1570 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1524 | 1571 |
| 1525 // Add a pinned tab. | 1572 // Add a pinned tab. |
| 1526 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1573 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1527 GURL url(embedded_test_server()->GetURL("/empty.html")); | 1574 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2933 Browser* browser = new Browser(params); | 2980 Browser* browser = new Browser(params); |
| 2934 gfx::Rect bounds = browser->window()->GetBounds(); | 2981 gfx::Rect bounds = browser->window()->GetBounds(); |
| 2935 | 2982 |
| 2936 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 2983 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
| 2937 // See https://crbug.com/567925. | 2984 // See https://crbug.com/567925. |
| 2938 EXPECT_GE(bounds.width(), 100); | 2985 EXPECT_GE(bounds.width(), 100); |
| 2939 EXPECT_EQ(122, bounds.height()); | 2986 EXPECT_EQ(122, bounds.height()); |
| 2940 browser->window()->Close(); | 2987 browser->window()->Close(); |
| 2941 } | 2988 } |
| 2942 } | 2989 } |
| OLD | NEW |