Chromium Code Reviews| 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 "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 // Only use the set of urls specified in preferences if nothing was | 752 // Only use the set of urls specified in preferences if nothing was |
| 753 // specified on the command line. Filter out any urls that are to be | 753 // specified on the command line. Filter out any urls that are to be |
| 754 // restored by virtue of having been previously pinned. | 754 // restored by virtue of having been previously pinned. |
| 755 AddUniqueURLs(pref.urls, &tabs); | 755 AddUniqueURLs(pref.urls, &tabs); |
| 756 } else if (pref.type == SessionStartupPref::HOMEPAGE) { | 756 } else if (pref.type == SessionStartupPref::HOMEPAGE) { |
| 757 // If 'homepage' selected, either by the user or by a policy, we should | 757 // If 'homepage' selected, either by the user or by a policy, we should |
| 758 // have migrated them to another value. | 758 // have migrated them to another value. |
| 759 NOTREACHED() << "SessionStartupPref has deprecated type HOMEPAGE"; | 759 NOTREACHED() << "SessionStartupPref has deprecated type HOMEPAGE"; |
| 760 } | 760 } |
| 761 | 761 |
| 762 PrefService* prefs = profile_->GetPrefs(); | |
| 762 if (pref.type != SessionStartupPref::LAST && | 763 if (pref.type != SessionStartupPref::LAST && |
| 763 SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_)) { | 764 SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_) && |
|
Bernhard Bauer
2013/04/03 16:41:23
This method is supposed to tell a caller whether t
Sergiu
2013/04/03 17:45:54
Makes total sense, moved it to sync_promo_ui.cc.
| |
| 765 !prefs->GetBoolean(prefs::kProfileIsManaged)) { | |
| 764 AddSyncPromoTab(profile_, &tabs); | 766 AddSyncPromoTab(profile_, &tabs); |
| 765 } | 767 } |
| 766 | 768 |
| 767 if (tabs.empty()) | 769 if (tabs.empty()) |
| 768 return NULL; | 770 return NULL; |
| 769 | 771 |
| 770 Browser* browser = OpenTabsInBrowser(NULL, true, tabs); | 772 Browser* browser = OpenTabsInBrowser(NULL, true, tabs); |
| 771 return browser; | 773 return browser; |
| 772 } | 774 } |
| 773 | 775 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 chrome::ShowDefaultBrowserPrompt(profile_, | 920 chrome::ShowDefaultBrowserPrompt(profile_, |
| 919 browser->host_desktop_type()); | 921 browser->host_desktop_type()); |
| 920 } | 922 } |
| 921 } | 923 } |
| 922 } | 924 } |
| 923 } | 925 } |
| 924 | 926 |
| 925 | 927 |
| 926 void StartupBrowserCreatorImpl::AddStartupURLs( | 928 void StartupBrowserCreatorImpl::AddStartupURLs( |
| 927 std::vector<GURL>* startup_urls) const { | 929 std::vector<GURL>* startup_urls) const { |
| 930 PrefService* prefs = profile_->GetPrefs(); | |
| 931 bool has_reset_local_passphrase_switch = | |
| 932 command_line_.HasSwitch(switches::kResetLocalPassphrase); | |
| 933 if ((is_first_run_ || has_reset_local_passphrase_switch) && | |
| 934 prefs->GetBoolean(prefs::kProfileIsManaged)) { | |
| 935 startup_urls->insert(startup_urls->begin(), | |
| 936 GURL(std::string(chrome::kChromeUISettingsURL) + | |
| 937 chrome::kManagedUserSettingsSubPage)); | |
| 938 if (has_reset_local_passphrase_switch) { | |
| 939 prefs->SetString(prefs::kManagedModeLocalPassphrase, ""); | |
| 940 prefs->SetString(prefs::kManagedModeLocalSalt, ""); | |
| 941 } else { | |
| 942 // If this is the first run then show only the managed user settings | |
|
Bernhard Bauer
2013/04/03 16:41:23
Wait, is this actually necessary? If we have set a
Sergiu
2013/04/03 17:45:54
That is true, we can do without the else branch. R
| |
| 943 // page. | |
| 944 return; | |
| 945 } | |
| 946 } | |
| 947 | |
| 928 // If we have urls specified by the first run master preferences use them | 948 // If we have urls specified by the first run master preferences use them |
| 929 // and nothing else. | 949 // and nothing else. |
| 930 if (browser_creator_ && startup_urls->empty()) { | 950 if (browser_creator_ && startup_urls->empty()) { |
| 931 if (!browser_creator_->first_run_tabs_.empty()) { | 951 if (!browser_creator_->first_run_tabs_.empty()) { |
| 932 std::vector<GURL>::iterator it = | 952 std::vector<GURL>::iterator it = |
| 933 browser_creator_->first_run_tabs_.begin(); | 953 browser_creator_->first_run_tabs_.begin(); |
| 934 while (it != browser_creator_->first_run_tabs_.end()) { | 954 while (it != browser_creator_->first_run_tabs_.end()) { |
| 935 // Replace magic names for the actual urls. | 955 // Replace magic names for the actual urls. |
| 936 if (it->host() == "new_tab_page") { | 956 if (it->host() == "new_tab_page") { |
| 937 startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); | 957 startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); |
| 938 } else if (it->host() == "welcome_page") { | 958 } else if (it->host() == "welcome_page") { |
| 939 startup_urls->push_back(internals::GetWelcomePageURL()); | 959 startup_urls->push_back(internals::GetWelcomePageURL()); |
| 940 } else { | 960 } else { |
| 941 startup_urls->push_back(*it); | 961 startup_urls->push_back(*it); |
| 942 } | 962 } |
| 943 ++it; | 963 ++it; |
| 944 } | 964 } |
| 945 browser_creator_->first_run_tabs_.clear(); | 965 browser_creator_->first_run_tabs_.clear(); |
| 946 } | 966 } |
| 947 } | 967 } |
| 948 | 968 |
| 949 // Otherwise open at least the new tab page (and the welcome page, if this | 969 // Otherwise open at least the new tab page (and the welcome page, if this |
| 950 // is the first time the browser is being started), or the set of URLs | 970 // is the first time the browser is being started), or the set of URLs |
| 951 // specified on the command line. | 971 // specified on the command line. |
| 952 if (startup_urls->empty()) { | 972 if (startup_urls->empty()) { |
| 953 startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); | 973 startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); |
| 954 if (first_run::ShouldShowWelcomePage()) | 974 if (first_run::ShouldShowWelcomePage()) |
| 955 startup_urls->push_back(internals::GetWelcomePageURL()); | 975 startup_urls->push_back(internals::GetWelcomePageURL()); |
| 956 } | 976 } |
| 957 | |
| 958 PrefService* prefs = profile_->GetPrefs(); | |
| 959 bool has_reset_local_passphrase_switch = | |
| 960 command_line_.HasSwitch(switches::kResetLocalPassphrase); | |
| 961 if ((is_first_run_ || has_reset_local_passphrase_switch) && | |
| 962 prefs->GetBoolean(prefs::kProfileIsManaged)) { | |
| 963 startup_urls->insert(startup_urls->begin(), | |
| 964 GURL(std::string(chrome::kChromeUISettingsURL) + | |
| 965 chrome::kManagedUserSettingsSubPage)); | |
| 966 if (has_reset_local_passphrase_switch) { | |
| 967 prefs->SetString(prefs::kManagedModeLocalPassphrase, ""); | |
| 968 prefs->SetString(prefs::kManagedModeLocalSalt, ""); | |
| 969 } | |
| 970 } | |
| 971 } | 977 } |
| 972 | 978 |
| 973 #if !defined(OS_WIN) || defined(USE_AURA) | 979 #if !defined(OS_WIN) || defined(USE_AURA) |
| 974 // static | 980 // static |
| 975 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( | 981 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( |
| 976 Profile* profile, | 982 Profile* profile, |
| 977 const std::vector<GURL>& startup_urls) { | 983 const std::vector<GURL>& startup_urls) { |
| 978 return false; | 984 return false; |
| 979 } | 985 } |
| 980 #endif | 986 #endif |
| OLD | NEW |