| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/first_run/first_run.h" | 16 #include "chrome/browser/first_run/first_run.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" | 18 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" |
| 19 #include "chrome/browser/managed_mode/managed_user_service.h" | 19 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 20 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 20 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 21 #include "chrome/browser/prefs/session_startup_pref.h" | 21 #include "chrome/browser/prefs/session_startup_pref.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_impl.h" | 23 #include "chrome/browser/profiles/profile_impl.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/search/search.h" |
| 25 #include "chrome/browser/sessions/session_restore.h" | 26 #include "chrome/browser/sessions/session_restore.h" |
| 26 #include "chrome/browser/signin/signin_promo.h" | 27 #include "chrome/browser/signin/signin_promo.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_iterator.h" | 30 #include "chrome/browser/ui/browser_iterator.h" |
| 30 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
| 31 #include "chrome/browser/ui/browser_list_observer.h" | 32 #include "chrome/browser/ui/browser_list_observer.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/host_desktop.h" | 34 #include "chrome/browser/ui/host_desktop.h" |
| 34 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 35 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 432 |
| 432 // This should have created a new browser window. | 433 // This should have created a new browser window. |
| 433 Browser* new_browser = FindOneOtherBrowser(browser()); | 434 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 434 ASSERT_TRUE(new_browser); | 435 ASSERT_TRUE(new_browser); |
| 435 | 436 |
| 436 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 437 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 437 EXPECT_EQ(4, tab_strip->count()); | 438 EXPECT_EQ(4, tab_strip->count()); |
| 438 | 439 |
| 439 EXPECT_EQ("title1.html", | 440 EXPECT_EQ("title1.html", |
| 440 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 441 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 441 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 442 EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(1))); |
| 442 tab_strip->GetWebContentsAt(1)->GetURL()); | |
| 443 EXPECT_EQ("title2.html", | 443 EXPECT_EQ("title2.html", |
| 444 tab_strip->GetWebContentsAt(2)->GetURL().ExtractFileName()); | 444 tab_strip->GetWebContentsAt(2)->GetURL().ExtractFileName()); |
| 445 EXPECT_EQ(internals::GetWelcomePageURL(), | 445 EXPECT_EQ(internals::GetWelcomePageURL(), |
| 446 tab_strip->GetWebContentsAt(3)->GetURL()); | 446 tab_strip->GetWebContentsAt(3)->GetURL()); |
| 447 } | 447 } |
| 448 | 448 |
| 449 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) { | 449 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) { |
| 450 // Do a simple non-process-startup browser launch. | 450 // Do a simple non-process-startup browser launch. |
| 451 CommandLine dummy(CommandLine::NO_PROGRAM); | 451 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 452 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, | 452 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, |
| 453 chrome::startup::IS_FIRST_RUN); | 453 chrome::startup::IS_FIRST_RUN); |
| 454 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, | 454 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, |
| 455 browser()->host_desktop_type())); | 455 browser()->host_desktop_type())); |
| 456 | 456 |
| 457 // This should have created a new browser window. | 457 // This should have created a new browser window. |
| 458 Browser* new_browser = FindOneOtherBrowser(browser()); | 458 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 459 ASSERT_TRUE(new_browser); | 459 ASSERT_TRUE(new_browser); |
| 460 | 460 |
| 461 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 461 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 462 EXPECT_EQ(1, tab_strip->count()); | 462 EXPECT_EQ(1, tab_strip->count()); |
| 463 | 463 |
| 464 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { | 464 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
| 465 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 465 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 466 tab_strip->GetWebContentsAt(0)->GetURL()); | 466 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 467 } else { | 467 } else { |
| 468 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 468 EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(0))); |
| 469 tab_strip->GetWebContentsAt(0)->GetURL()); | |
| 470 } | 469 } |
| 471 } | 470 } |
| 472 | 471 |
| 473 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) { | 472 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) { |
| 474 first_run::SetShouldShowWelcomePage(); | 473 first_run::SetShouldShowWelcomePage(); |
| 475 | 474 |
| 476 // Do a simple non-process-startup browser launch. | 475 // Do a simple non-process-startup browser launch. |
| 477 CommandLine dummy(CommandLine::NO_PROGRAM); | 476 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 478 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, | 477 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, |
| 479 chrome::startup::IS_FIRST_RUN); | 478 chrome::startup::IS_FIRST_RUN); |
| 480 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, | 479 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, |
| 481 browser()->host_desktop_type())); | 480 browser()->host_desktop_type())); |
| 482 | 481 |
| 483 // This should have created a new browser window. | 482 // This should have created a new browser window. |
| 484 Browser* new_browser = FindOneOtherBrowser(browser()); | 483 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 485 ASSERT_TRUE(new_browser); | 484 ASSERT_TRUE(new_browser); |
| 486 | 485 |
| 487 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 486 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 488 EXPECT_EQ(2, tab_strip->count()); | 487 EXPECT_EQ(2, tab_strip->count()); |
| 489 | 488 |
| 490 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { | 489 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
| 491 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 490 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 492 tab_strip->GetWebContentsAt(0)->GetURL()); | 491 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 493 } else { | 492 } else { |
| 494 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 493 EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(0))); |
| 495 tab_strip->GetWebContentsAt(0)->GetURL()); | |
| 496 } | 494 } |
| 497 EXPECT_EQ(internals::GetWelcomePageURL(), | 495 EXPECT_EQ(internals::GetWelcomePageURL(), |
| 498 tab_strip->GetWebContentsAt(1)->GetURL()); | 496 tab_strip->GetWebContentsAt(1)->GetURL()); |
| 499 } | 497 } |
| 500 | 498 |
| 501 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) { | 499 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) { |
| 502 StartupBrowserCreator browser_creator; | 500 StartupBrowserCreator browser_creator; |
| 503 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html")); | 501 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html")); |
| 504 | 502 |
| 505 // The welcome page should not be shown, even if | 503 // The welcome page should not be shown, even if |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 ASSERT_EQ(1, tab_strip->count()); | 1336 ASSERT_EQ(1, tab_strip->count()); |
| 1339 EXPECT_EQ("title1.html", | 1337 EXPECT_EQ("title1.html", |
| 1340 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1338 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1341 } | 1339 } |
| 1342 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1340 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1343 | 1341 |
| 1344 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1342 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
| 1345 // defined(ENABLE_CONFIGURATION_POLICY) | 1343 // defined(ENABLE_CONFIGURATION_POLICY) |
| 1346 | 1344 |
| 1347 #endif // !defined(OS_CHROMEOS) | 1345 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |