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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/first_run/first_run.h" | 12 #include "chrome/browser/first_run/first_run.h" |
13 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "chrome/browser/operation_output.h" |
14 #include "chrome/browser/prefs/session_startup_pref.h" | 15 #include "chrome/browser/prefs/session_startup_pref.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_impl.h" | 17 #include "chrome/browser/profiles/profile_impl.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/sessions/session_restore.h" | 19 #include "chrome/browser/sessions/session_restore.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
21 #include "chrome/browser/ui/browser_iterator.h" | 22 #include "chrome/browser/ui/browser_iterator.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/browser/ui/browser_list_observer.h" | 24 #include "chrome/browser/ui/browser_list_observer.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 SessionStartupPref pref2(SessionStartupPref::URLS); | 586 SessionStartupPref pref2(SessionStartupPref::URLS); |
586 pref2.urls = urls2; | 587 pref2.urls = urls2; |
587 SessionStartupPref::SetStartupPref(other_profile, pref2); | 588 SessionStartupPref::SetStartupPref(other_profile, pref2); |
588 | 589 |
589 // Close the browser. | 590 // Close the browser. |
590 browser()->window()->Close(); | 591 browser()->window()->Close(); |
591 | 592 |
592 // Do a simple non-process-startup browser launch. | 593 // Do a simple non-process-startup browser launch. |
593 CommandLine dummy(CommandLine::NO_PROGRAM); | 594 CommandLine dummy(CommandLine::NO_PROGRAM); |
594 | 595 |
595 int return_code; | |
596 StartupBrowserCreator browser_creator; | 596 StartupBrowserCreator browser_creator; |
597 std::vector<Profile*> last_opened_profiles; | 597 std::vector<Profile*> last_opened_profiles; |
598 last_opened_profiles.push_back(default_profile); | 598 last_opened_profiles.push_back(default_profile); |
599 last_opened_profiles.push_back(other_profile); | 599 last_opened_profiles.push_back(other_profile); |
600 browser_creator.Start(dummy, profile_manager->user_data_dir(), | 600 browser_creator.Start(dummy, profile_manager->user_data_dir(), |
601 default_profile, last_opened_profiles, &return_code); | 601 default_profile, last_opened_profiles, |
| 602 scoped_ptr<OperationOutput>()); |
602 | 603 |
603 // urls1 were opened in a browser for default_profile, and urls2 were opened | 604 // urls1 were opened in a browser for default_profile, and urls2 were opened |
604 // in a browser for other_profile. | 605 // in a browser for other_profile. |
605 Browser* new_browser = NULL; | 606 Browser* new_browser = NULL; |
606 // |browser()| is still around at this point, even though we've closed its | 607 // |browser()| is still around at this point, even though we've closed its |
607 // window. Thus the browser count for default_profile is 2. | 608 // window. Thus the browser count for default_profile is 2. |
608 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, | 609 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, |
609 browser()->host_desktop_type())); | 610 browser()->host_desktop_type())); |
610 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); | 611 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); |
611 ASSERT_TRUE(new_browser); | 612 ASSERT_TRUE(new_browser); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // Set different startup preferences for the 2 profiles. | 655 // Set different startup preferences for the 2 profiles. |
655 SessionStartupPref pref1(SessionStartupPref::URLS); | 656 SessionStartupPref pref1(SessionStartupPref::URLS); |
656 pref1.urls = urls1; | 657 pref1.urls = urls1; |
657 SessionStartupPref::SetStartupPref(profile1, pref1); | 658 SessionStartupPref::SetStartupPref(profile1, pref1); |
658 SessionStartupPref pref2(SessionStartupPref::URLS); | 659 SessionStartupPref pref2(SessionStartupPref::URLS); |
659 pref2.urls = urls2; | 660 pref2.urls = urls2; |
660 SessionStartupPref::SetStartupPref(profile2, pref2); | 661 SessionStartupPref::SetStartupPref(profile2, pref2); |
661 | 662 |
662 // Simulate a launch after a browser update. | 663 // Simulate a launch after a browser update. |
663 CommandLine dummy(CommandLine::NO_PROGRAM); | 664 CommandLine dummy(CommandLine::NO_PROGRAM); |
664 int return_code; | |
665 StartupBrowserCreator browser_creator; | 665 StartupBrowserCreator browser_creator; |
666 std::vector<Profile*> last_opened_profiles; | 666 std::vector<Profile*> last_opened_profiles; |
667 last_opened_profiles.push_back(profile1); | 667 last_opened_profiles.push_back(profile1); |
668 last_opened_profiles.push_back(profile2); | 668 last_opened_profiles.push_back(profile2); |
669 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile1, | 669 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile1, |
670 last_opened_profiles, &return_code); | 670 last_opened_profiles, scoped_ptr<OperationOutput>()); |
671 | 671 |
672 while (SessionRestore::IsRestoring(profile1) || | 672 while (SessionRestore::IsRestoring(profile1) || |
673 SessionRestore::IsRestoring(profile2)) | 673 SessionRestore::IsRestoring(profile2)) |
674 MessageLoop::current()->RunUntilIdle(); | 674 MessageLoop::current()->RunUntilIdle(); |
675 | 675 |
676 // The startup URLs are ignored, and instead the last open sessions are | 676 // The startup URLs are ignored, and instead the last open sessions are |
677 // restored. | 677 // restored. |
678 EXPECT_TRUE(profile1->restored_last_session()); | 678 EXPECT_TRUE(profile1->restored_last_session()); |
679 EXPECT_TRUE(profile2->restored_last_session()); | 679 EXPECT_TRUE(profile2->restored_last_session()); |
680 | 680 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 SessionStartupPref::SetStartupPref(profile_urls, pref_urls); | 742 SessionStartupPref::SetStartupPref(profile_urls, pref_urls); |
743 | 743 |
744 // Close the browser. | 744 // Close the browser. |
745 chrome::HostDesktopType original_desktop_type = | 745 chrome::HostDesktopType original_desktop_type = |
746 browser()->host_desktop_type(); | 746 browser()->host_desktop_type(); |
747 browser()->window()->Close(); | 747 browser()->window()->Close(); |
748 | 748 |
749 // Do a simple non-process-startup browser launch. | 749 // Do a simple non-process-startup browser launch. |
750 CommandLine dummy(CommandLine::NO_PROGRAM); | 750 CommandLine dummy(CommandLine::NO_PROGRAM); |
751 | 751 |
752 int return_code; | |
753 StartupBrowserCreator browser_creator; | 752 StartupBrowserCreator browser_creator; |
754 std::vector<Profile*> last_opened_profiles; | 753 std::vector<Profile*> last_opened_profiles; |
755 last_opened_profiles.push_back(profile_home1); | 754 last_opened_profiles.push_back(profile_home1); |
756 last_opened_profiles.push_back(profile_home2); | 755 last_opened_profiles.push_back(profile_home2); |
757 last_opened_profiles.push_back(profile_last); | 756 last_opened_profiles.push_back(profile_last); |
758 last_opened_profiles.push_back(profile_urls); | 757 last_opened_profiles.push_back(profile_urls); |
759 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, | 758 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, |
760 last_opened_profiles, &return_code); | 759 last_opened_profiles, scoped_ptr<OperationOutput>()); |
761 | 760 |
762 while (SessionRestore::IsRestoring(default_profile) || | 761 while (SessionRestore::IsRestoring(default_profile) || |
763 SessionRestore::IsRestoring(profile_home1) || | 762 SessionRestore::IsRestoring(profile_home1) || |
764 SessionRestore::IsRestoring(profile_home2) || | 763 SessionRestore::IsRestoring(profile_home2) || |
765 SessionRestore::IsRestoring(profile_last) || | 764 SessionRestore::IsRestoring(profile_last) || |
766 SessionRestore::IsRestoring(profile_urls)) | 765 SessionRestore::IsRestoring(profile_urls)) |
767 MessageLoop::current()->RunUntilIdle(); | 766 MessageLoop::current()->RunUntilIdle(); |
768 | 767 |
769 Browser* new_browser = NULL; | 768 Browser* new_browser = NULL; |
770 // The last open profile (the profile_home1 in this case) will always be | 769 // The last open profile (the profile_home1 in this case) will always be |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 browser()->window()->Close(); | 838 browser()->window()->Close(); |
840 static_cast<ProfileImpl*>(profile_home)->last_session_exit_type_ = | 839 static_cast<ProfileImpl*>(profile_home)->last_session_exit_type_ = |
841 Profile::EXIT_CRASHED; | 840 Profile::EXIT_CRASHED; |
842 static_cast<ProfileImpl*>(profile_last)->last_session_exit_type_ = | 841 static_cast<ProfileImpl*>(profile_last)->last_session_exit_type_ = |
843 Profile::EXIT_CRASHED; | 842 Profile::EXIT_CRASHED; |
844 static_cast<ProfileImpl*>(profile_urls)->last_session_exit_type_ = | 843 static_cast<ProfileImpl*>(profile_urls)->last_session_exit_type_ = |
845 Profile::EXIT_CRASHED; | 844 Profile::EXIT_CRASHED; |
846 | 845 |
847 CommandLine dummy(CommandLine::NO_PROGRAM); | 846 CommandLine dummy(CommandLine::NO_PROGRAM); |
848 dummy.AppendSwitchASCII(switches::kTestType, "browser"); | 847 dummy.AppendSwitchASCII(switches::kTestType, "browser"); |
849 int return_code; | |
850 StartupBrowserCreator browser_creator; | 848 StartupBrowserCreator browser_creator; |
851 std::vector<Profile*> last_opened_profiles; | 849 std::vector<Profile*> last_opened_profiles; |
852 last_opened_profiles.push_back(profile_home); | 850 last_opened_profiles.push_back(profile_home); |
853 last_opened_profiles.push_back(profile_last); | 851 last_opened_profiles.push_back(profile_last); |
854 last_opened_profiles.push_back(profile_urls); | 852 last_opened_profiles.push_back(profile_urls); |
855 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home, | 853 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home, |
856 last_opened_profiles, &return_code); | 854 last_opened_profiles, scoped_ptr<OperationOutput>()); |
857 | 855 |
858 // No profiles are getting restored, since they all display the crash info | 856 // No profiles are getting restored, since they all display the crash info |
859 // bar. | 857 // bar. |
860 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); | 858 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); |
861 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); | 859 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); |
862 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); | 860 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); |
863 | 861 |
864 // The profile which normally opens the home page displays the new tab page. | 862 // The profile which normally opens the home page displays the new tab page. |
865 Browser* new_browser = NULL; | 863 Browser* new_browser = NULL; |
866 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, | 864 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 938 |
941 // Managed user should be in elevated state. | 939 // Managed user should be in elevated state. |
942 bool is_elevated = ManagedModeNavigationObserver::FromWebContents( | 940 bool is_elevated = ManagedModeNavigationObserver::FromWebContents( |
943 web_contents)->is_elevated(); | 941 web_contents)->is_elevated(); |
944 EXPECT_TRUE(is_elevated); | 942 EXPECT_TRUE(is_elevated); |
945 } | 943 } |
946 | 944 |
947 #endif // ENABLE_MANAGED_USERS | 945 #endif // ENABLE_MANAGED_USERS |
948 | 946 |
949 #endif // !OS_CHROMEOS | 947 #endif // !OS_CHROMEOS |
OLD | NEW |