| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #endif | 11 #endif |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
| 16 #include "chrome/browser/extensions/extension_browsertest.h" | 16 #include "chrome/browser/extensions/extension_browsertest.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_tab_helper.h" | 18 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 19 #include "chrome/browser/first_run/first_run.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/tabs/pinned_tab_codec.h" | 21 #include "chrome/browser/tabs/pinned_tab_codec.h" |
| 21 #include "chrome/browser/tabs/tab_strip_model.h" | 22 #include "chrome/browser/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/translate/translate_tab_helper.h" | 23 #include "chrome/browser/translate/translate_tab_helper.h" |
| 23 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 24 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 24 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 25 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 25 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 26 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_init.h" | 28 #include "chrome/browser/ui/browser_init.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 ASSERT_TRUE(test_server()->Start()); | 725 ASSERT_TRUE(test_server()->Start()); |
| 725 | 726 |
| 726 // Load an app. | 727 // Load an app. |
| 727 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 728 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 728 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 729 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 729 const Extension* extension_app = GetExtension(); | 730 const Extension* extension_app = GetExtension(); |
| 730 | 731 |
| 731 CommandLine command_line(CommandLine::NO_PROGRAM); | 732 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 732 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); | 733 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); |
| 733 | 734 |
| 734 BrowserInit::LaunchWithProfile launch(FilePath(), command_line); | 735 BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? |
| 736 BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; |
| 737 BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); |
| 735 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); | 738 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); |
| 736 | 739 |
| 737 // Check that the new browser has an app name. | 740 // Check that the new browser has an app name. |
| 738 // The launch should have created a new browser. | 741 // The launch should have created a new browser. |
| 739 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 742 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); |
| 740 | 743 |
| 741 // Find the new browser. | 744 // Find the new browser. |
| 742 Browser* new_browser = NULL; | 745 Browser* new_browser = NULL; |
| 743 for (BrowserList::const_iterator i = BrowserList::begin(); | 746 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 744 i != BrowserList::end() && !new_browser; ++i) { | 747 i != BrowserList::end() && !new_browser; ++i) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 // Add a pinned non-app tab. | 932 // Add a pinned non-app tab. |
| 930 browser()->NewTab(); | 933 browser()->NewTab(); |
| 931 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 934 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
| 932 model->SetTabPinned(2, true); | 935 model->SetTabPinned(2, true); |
| 933 | 936 |
| 934 // Write out the pinned tabs. | 937 // Write out the pinned tabs. |
| 935 PinnedTabCodec::WritePinnedTabs(browser()->profile()); | 938 PinnedTabCodec::WritePinnedTabs(browser()->profile()); |
| 936 | 939 |
| 937 // Simulate launching again. | 940 // Simulate launching again. |
| 938 CommandLine dummy(CommandLine::NO_PROGRAM); | 941 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 939 BrowserInit::LaunchWithProfile launch(FilePath(), dummy); | 942 BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? |
| 943 BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; |
| 944 BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); |
| 940 launch.profile_ = browser()->profile(); | 945 launch.profile_ = browser()->profile(); |
| 941 launch.ProcessStartupURLs(std::vector<GURL>()); | 946 launch.ProcessStartupURLs(std::vector<GURL>()); |
| 942 | 947 |
| 943 // The launch should have created a new browser. | 948 // The launch should have created a new browser. |
| 944 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); | 949 ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); |
| 945 | 950 |
| 946 // Find the new browser. | 951 // Find the new browser. |
| 947 Browser* new_browser = NULL; | 952 Browser* new_browser = NULL; |
| 948 for (BrowserList::const_iterator i = BrowserList::begin(); | 953 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 949 i != BrowserList::end() && !new_browser; ++i) { | 954 i != BrowserList::end() && !new_browser; ++i) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1143 |
| 1139 // The normal browser should now have four. | 1144 // The normal browser should now have four. |
| 1140 EXPECT_EQ(4, browser()->tab_count()); | 1145 EXPECT_EQ(4, browser()->tab_count()); |
| 1141 | 1146 |
| 1142 // Close the additional browsers. | 1147 // Close the additional browsers. |
| 1143 popup_browser->CloseAllTabs(); | 1148 popup_browser->CloseAllTabs(); |
| 1144 app_browser->CloseAllTabs(); | 1149 app_browser->CloseAllTabs(); |
| 1145 app_popup_browser->CloseAllTabs(); | 1150 app_popup_browser->CloseAllTabs(); |
| 1146 } | 1151 } |
| 1147 #endif | 1152 #endif |
| OLD | NEW |