| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/extensions/extension_tab_helper.h" | 21 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 22 #include "chrome/browser/first_run/first_run.h" | 22 #include "chrome/browser/first_run/first_run.h" |
| 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/translate/translate_tab_helper.h" | 26 #include "chrome/browser/translate/translate_tab_helper.h" |
| 27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 28 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 28 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 29 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 29 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 32 #include "chrome/browser/ui/browser_navigator.h" | 33 #include "chrome/browser/ui/browser_navigator.h" |
| 33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/fullscreen_controller.h" | 35 #include "chrome/browser/ui/fullscreen_controller.h" |
| 35 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" | 36 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
| 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 37 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 37 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 38 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 39 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 40 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { | 763 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { |
| 763 ASSERT_TRUE(test_server()->Start()); | 764 ASSERT_TRUE(test_server()->Start()); |
| 764 GURL http_url(test_server()->GetURL("")); | 765 GURL http_url(test_server()->GetURL("")); |
| 765 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); | 766 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); |
| 766 | 767 |
| 767 ASSERT_EQ(1, browser()->tab_count()); | 768 ASSERT_EQ(1, browser()->tab_count()); |
| 768 WebContents* initial_tab = browser()->GetWebContentsAt(0); | 769 WebContents* initial_tab = browser()->GetWebContentsAt(0); |
| 769 WebContents* app_tab = browser()->AddSelectedTabWithURL( | 770 WebContents* app_tab = browser()->AddSelectedTabWithURL( |
| 770 http_url, content::PAGE_TRANSITION_TYPED)->web_contents(); | 771 http_url, content::PAGE_TRANSITION_TYPED)->web_contents(); |
| 771 ASSERT_EQ(2, browser()->tab_count()); | 772 ASSERT_EQ(2, browser()->tab_count()); |
| 772 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 773 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
| 773 | 774 |
| 774 // Normal tabs should accept load drops. | 775 // Normal tabs should accept load drops. |
| 775 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 776 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 776 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 777 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 777 | 778 |
| 778 // Turn |app_tab| into a tab in an app panel. | 779 // Turn |app_tab| into a tab in an app panel. |
| 779 browser()->ConvertContentsToApplication(app_tab); | 780 browser()->ConvertContentsToApplication(app_tab); |
| 780 | 781 |
| 781 // The launch should have created a new browser. | 782 // The launch should have created a new browser. |
| 782 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 783 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 783 | 784 |
| 784 // Find the new browser. | 785 // Find the new browser. |
| 785 Browser* app_browser = NULL; | 786 Browser* app_browser = NULL; |
| 786 for (BrowserList::const_iterator i = BrowserList::begin(); | 787 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 787 i != BrowserList::end() && !app_browser; ++i) { | 788 i != BrowserList::end() && !app_browser; ++i) { |
| 788 if (*i != browser()) | 789 if (*i != browser()) |
| 789 app_browser = *i; | 790 app_browser = *i; |
| 790 } | 791 } |
| 791 ASSERT_TRUE(app_browser); | 792 ASSERT_TRUE(app_browser); |
| 792 | 793 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); | 901 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); |
| 901 | 902 |
| 902 browser::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 903 browser::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 903 browser::startup::IS_FIRST_RUN : | 904 browser::startup::IS_FIRST_RUN : |
| 904 browser::startup::IS_NOT_FIRST_RUN; | 905 browser::startup::IS_NOT_FIRST_RUN; |
| 905 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run); | 906 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run); |
| 906 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); | 907 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); |
| 907 | 908 |
| 908 // Check that the new browser has an app name. | 909 // Check that the new browser has an app name. |
| 909 // The launch should have created a new browser. | 910 // The launch should have created a new browser. |
| 910 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 911 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 911 | 912 |
| 912 // Find the new browser. | 913 // Find the new browser. |
| 913 Browser* new_browser = NULL; | 914 Browser* new_browser = NULL; |
| 914 for (BrowserList::const_iterator i = BrowserList::begin(); | 915 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 915 i != BrowserList::end() && !new_browser; ++i) { | 916 i != BrowserList::end() && !new_browser; ++i) { |
| 916 if (*i != browser()) | 917 if (*i != browser()) |
| 917 new_browser = *i; | 918 new_browser = *i; |
| 918 } | 919 } |
| 919 ASSERT_TRUE(new_browser); | 920 ASSERT_TRUE(new_browser); |
| 920 ASSERT_TRUE(new_browser != browser()); | 921 ASSERT_TRUE(new_browser != browser()); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 | 1253 |
| 1253 // Simulate launching again. | 1254 // Simulate launching again. |
| 1254 CommandLine dummy(CommandLine::NO_PROGRAM); | 1255 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 1255 browser::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 1256 browser::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 1256 browser::startup::IS_FIRST_RUN : browser::startup::IS_NOT_FIRST_RUN; | 1257 browser::startup::IS_FIRST_RUN : browser::startup::IS_NOT_FIRST_RUN; |
| 1257 StartupBrowserCreatorImpl launch(FilePath(), dummy, first_run); | 1258 StartupBrowserCreatorImpl launch(FilePath(), dummy, first_run); |
| 1258 launch.profile_ = browser()->profile(); | 1259 launch.profile_ = browser()->profile(); |
| 1259 launch.ProcessStartupURLs(std::vector<GURL>()); | 1260 launch.ProcessStartupURLs(std::vector<GURL>()); |
| 1260 | 1261 |
| 1261 // The launch should have created a new browser. | 1262 // The launch should have created a new browser. |
| 1262 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 1263 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 1263 | 1264 |
| 1264 // Find the new browser. | 1265 // Find the new browser. |
| 1265 Browser* new_browser = NULL; | 1266 Browser* new_browser = NULL; |
| 1266 for (BrowserList::const_iterator i = BrowserList::begin(); | 1267 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 1267 i != BrowserList::end() && !new_browser; ++i) { | 1268 i != BrowserList::end() && !new_browser; ++i) { |
| 1268 if (*i != browser()) | 1269 if (*i != browser()) |
| 1269 new_browser = *i; | 1270 new_browser = *i; |
| 1270 } | 1271 } |
| 1271 ASSERT_TRUE(new_browser); | 1272 ASSERT_TRUE(new_browser); |
| 1272 ASSERT_TRUE(new_browser != browser()); | 1273 ASSERT_TRUE(new_browser != browser()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 ASSERT_TRUE(app_window); | 1331 ASSERT_TRUE(app_window); |
| 1331 | 1332 |
| 1332 // Apps launched in a window from the NTP do not have extension_app set in | 1333 // Apps launched in a window from the NTP do not have extension_app set in |
| 1333 // tab contents. | 1334 // tab contents. |
| 1334 TabContentsWrapper* wrapper = | 1335 TabContentsWrapper* wrapper = |
| 1335 TabContentsWrapper::GetCurrentWrapperForContents(app_window); | 1336 TabContentsWrapper::GetCurrentWrapperForContents(app_window); |
| 1336 EXPECT_FALSE(wrapper->extension_tab_helper()->extension_app()); | 1337 EXPECT_FALSE(wrapper->extension_tab_helper()->extension_app()); |
| 1337 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); | 1338 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); |
| 1338 | 1339 |
| 1339 // The launch should have created a new browser. | 1340 // The launch should have created a new browser. |
| 1340 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 1341 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 1341 | 1342 |
| 1342 // Find the new browser. | 1343 // Find the new browser. |
| 1343 Browser* new_browser = NULL; | 1344 Browser* new_browser = NULL; |
| 1344 for (BrowserList::const_iterator i = BrowserList::begin(); | 1345 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 1345 i != BrowserList::end() && !new_browser; ++i) { | 1346 i != BrowserList::end() && !new_browser; ++i) { |
| 1346 if (*i != browser()) | 1347 if (*i != browser()) |
| 1347 new_browser = *i; | 1348 new_browser = *i; |
| 1348 } | 1349 } |
| 1349 ASSERT_TRUE(new_browser); | 1350 ASSERT_TRUE(new_browser); |
| 1350 ASSERT_TRUE(new_browser != browser()); | 1351 ASSERT_TRUE(new_browser != browser()); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 command_line->AppendSwitchASCII(switches::kApp, url.spec()); | 1902 command_line->AppendSwitchASCII(switches::kApp, url.spec()); |
| 1902 } | 1903 } |
| 1903 }; | 1904 }; |
| 1904 | 1905 |
| 1905 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { | 1906 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { |
| 1906 // Test that an application browser window loads correctly. | 1907 // Test that an application browser window loads correctly. |
| 1907 | 1908 |
| 1908 // Verify the browser is in application mode. | 1909 // Verify the browser is in application mode. |
| 1909 EXPECT_TRUE(browser()->IsApplication()); | 1910 EXPECT_TRUE(browser()->IsApplication()); |
| 1910 } | 1911 } |
| OLD | NEW |