| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_util.h" | 19 #include "chrome/browser/extensions/extension_util.h" |
| 20 #include "chrome/browser/extensions/launch_util.h" | 20 #include "chrome/browser/extensions/launch_util.h" |
| 21 #include "chrome/browser/first_run/first_run.h" | 21 #include "chrome/browser/first_run/first_run.h" |
| 22 #include "chrome/browser/infobars/infobar_service.h" | 22 #include "chrome/browser/infobars/infobar_service.h" |
| 23 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 24 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 23 #include "chrome/browser/prefs/session_startup_pref.h" | 25 #include "chrome/browser/prefs/session_startup_pref.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_impl.h" | 27 #include "chrome/browser/profiles/profile_impl.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/sessions/session_restore.h" | 29 #include "chrome/browser/sessions/session_restore.h" |
| 28 #include "chrome/browser/signin/signin_promo.h" | 30 #include "chrome/browser/signin/signin_promo.h" |
| 29 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" | 32 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" | 33 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_list.h" | 34 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 urls.push_back(embedded_test_server()->GetURL("/title2.html")); | 265 urls.push_back(embedded_test_server()->GetURL("/title2.html")); |
| 264 | 266 |
| 265 Profile* profile = browser()->profile(); | 267 Profile* profile = browser()->profile(); |
| 266 | 268 |
| 267 // Set the startup preference to open these URLs. | 269 // Set the startup preference to open these URLs. |
| 268 SessionStartupPref pref(SessionStartupPref::URLS); | 270 SessionStartupPref pref(SessionStartupPref::URLS); |
| 269 pref.urls = urls; | 271 pref.urls = urls; |
| 270 SessionStartupPref::SetStartupPref(profile, pref); | 272 SessionStartupPref::SetStartupPref(profile, pref); |
| 271 | 273 |
| 272 // Keep the browser process running while browsers are closed. | 274 // Keep the browser process running while browsers are closed. |
| 273 g_browser_process->AddRefModule(); | 275 ScopedKeepAlive keep_alive(KeepAliveOrigin::BROWSER, |
| 276 KeepAliveRestartOption::DISABLED); |
| 274 | 277 |
| 275 // Close the browser. | 278 // Close the browser. |
| 276 CloseBrowserAsynchronously(browser()); | 279 CloseBrowserAsynchronously(browser()); |
| 277 | 280 |
| 278 // Do a simple non-process-startup browser launch. | 281 // Do a simple non-process-startup browser launch. |
| 279 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 282 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 280 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 283 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 281 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 284 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 282 { | 285 { |
| 283 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 286 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 326 |
| 324 // Find the new browser and ensure that it has only the specified URLs this | 327 // Find the new browser and ensure that it has only the specified URLs this |
| 325 // time. Both the original browser created by the fixture and the one | 328 // time. Both the original browser created by the fixture and the one |
| 326 // created above have been closed, so the new browser is the only one | 329 // created above have been closed, so the new browser is the only one |
| 327 // remaining. | 330 // remaining. |
| 328 new_browser = chrome::FindTabbedBrowser(profile, true); | 331 new_browser = chrome::FindTabbedBrowser(profile, true); |
| 329 ASSERT_TRUE(new_browser); | 332 ASSERT_TRUE(new_browser); |
| 330 ASSERT_EQ(static_cast<int>(urls.size()), | 333 ASSERT_EQ(static_cast<int>(urls.size()), |
| 331 new_browser->tab_strip_model()->count()); | 334 new_browser->tab_strip_model()->count()); |
| 332 } | 335 } |
| 333 | |
| 334 g_browser_process->ReleaseModule(); | |
| 335 } | 336 } |
| 336 | 337 |
| 337 // Verify that startup URLs aren't used when the process already exists | 338 // Verify that startup URLs aren't used when the process already exists |
| 338 // and has other tabbed browser windows. This is the common case of starting a | 339 // and has other tabbed browser windows. This is the common case of starting a |
| 339 // new browser. | 340 // new browser. |
| 340 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, | 341 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, |
| 341 StartupURLsOnNewWindow) { | 342 StartupURLsOnNewWindow) { |
| 342 // Use a couple arbitrary URLs. | 343 // Use a couple arbitrary URLs. |
| 343 std::vector<GURL> urls; | 344 std::vector<GURL> urls; |
| 344 urls.push_back(ui_test_utils::GetTestUrl( | 345 urls.push_back(ui_test_utils::GetTestUrl( |
| (...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 | 1665 |
| 1665 // Verify that the URL specified through policy is shown and no sync promo has | 1666 // Verify that the URL specified through policy is shown and no sync promo has |
| 1666 // been added. | 1667 // been added. |
| 1667 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1668 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1668 ASSERT_EQ(1, tab_strip->count()); | 1669 ASSERT_EQ(1, tab_strip->count()); |
| 1669 EXPECT_EQ("title1.html", | 1670 EXPECT_EQ("title1.html", |
| 1670 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1671 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1671 } | 1672 } |
| 1672 | 1673 |
| 1673 #endif // !defined(OS_CHROMEOS) | 1674 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |