Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_browser_creator_impl.cc |
| diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc |
| index ecbc5dc81b1829f603ecab69608efbbcdea3efe3..1aa5e1c7d3acac0f8260e18120b9328df5f07ece 100644 |
| --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc |
| +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc |
| @@ -40,6 +40,8 @@ |
| #include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| #include "chrome/browser/prefs/session_startup_pref.h" |
| +#include "chrome/browser/profile_resetter/triggered_profile_resetter.h" |
| +#include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/profiles/profile_io_data.h" |
| #include "chrome/browser/sessions/session_restore.h" |
| @@ -55,6 +57,7 @@ |
| #include "chrome/browser/ui/browser_tabrestore.h" |
| #include "chrome/browser/ui/browser_tabstrip.h" |
| #include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/chrome_pages.h" |
| #include "chrome/browser/ui/extensions/app_launch_params.h" |
| #include "chrome/browser/ui/extensions/application_launch.h" |
| #include "chrome/browser/ui/host_desktop.h" |
| @@ -255,9 +258,12 @@ const Extension* GetPlatformApp(Profile* profile, |
| namespace internals { |
| +GURL GetResetSettingsURL() { |
| + return GURL(chrome::GetSettingsUrl(chrome::kResetProfileSettingsSubPage)); |
| +} |
| + |
| GURL GetWelcomePageURL() { |
| - std::string welcome_url = l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL); |
| - return GURL(welcome_url); |
| + return GURL(l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL)); |
| } |
| } // namespace internals |
| @@ -530,10 +536,7 @@ void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
| // if desired. |
| if (!HasPendingUncleanExit(profile_)) { |
| std::vector<GURL> adjusted_urls(urls_to_open); |
| - if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) { |
| - adjusted_urls.insert(adjusted_urls.begin(), |
| - internals::GetWelcomePageURL()); |
| - } |
| + AddSpecialURLs(&adjusted_urls); |
| if (service->RestoreIfNecessary(adjusted_urls)) |
| return; |
| } |
| @@ -614,12 +617,8 @@ bool StartupBrowserCreatorImpl::ProcessStartupURLs( |
| } |
| #endif |
| - // Optionally include the welcome page. |
| std::vector<GURL> adjusted_urls(urls_to_open); |
| - if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) { |
| - adjusted_urls.insert(adjusted_urls.begin(), |
| - internals::GetWelcomePageURL()); |
| - } |
| + AddSpecialURLs(&adjusted_urls); |
| // The startup code only executes for browsers launched in desktop mode. |
| // i.e. HOST_DESKTOP_TYPE_NATIVE. Ash should never get here. |
| @@ -677,9 +676,10 @@ Browser* StartupBrowserCreatorImpl::ProcessSpecifiedURLs( |
| UrlsToTabs(urls, &tabs); |
| } else if (pref.type == SessionStartupPref::URLS && !pref.urls.empty() && |
| !HasPendingUncleanExit(profile_)) { |
| - // Optionally include the welcome page first. |
| - if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) |
| - UrlsToTabs(std::vector<GURL>(1, internals::GetWelcomePageURL()), &tabs); |
| + std::vector<GURL> extra_urls; |
| + AddSpecialURLs(&extra_urls); |
| + UrlsToTabs(extra_urls, &tabs); |
| + |
| // Only use the set of urls specified in preferences if nothing was |
| // specified on the command line. Filter out any urls that are to be |
| // restored by virtue of having been previously pinned. |
| @@ -861,13 +861,13 @@ void StartupBrowserCreatorImpl::AddStartupURLs( |
| } |
| } |
| - // Otherwise open at least the new tab page (and optionally the welcome page |
| - // at the front or back as indicated by welcome_run_type_), or the set of URLs |
| - // specified on the command line. |
| + // Otherwise open at least the new tab page (and any pages deemed needed by |
| + // AddSpecialURLs()), or the set of URLs specified on the command line. |
| if (startup_urls->empty()) { |
| - if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) |
| - startup_urls->push_back(internals::GetWelcomePageURL()); |
| + AddSpecialURLs(startup_urls); |
| startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); |
| + |
| + // Special case the FIRST_RUN_LAST_TAB case of the welcome page. |
| if (welcome_run_type_ == WelcomeRunType::FIRST_RUN_LAST_TAB) |
| startup_urls->push_back(internals::GetWelcomePageURL()); |
| } |
| @@ -901,6 +901,18 @@ void StartupBrowserCreatorImpl::AddStartupURLs( |
| } |
| } |
| +void StartupBrowserCreatorImpl::AddSpecialURLs( |
| + std::vector<GURL>* url_list) const { |
| + // Optionally include the welcome page. |
| + if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) |
| + url_list->insert(url_list->begin(), internals::GetWelcomePageURL()); |
| + |
| + // If this Profile is marked for a reset prompt, ensure the reset |
| + // settings dialog appears. |
| + if (ProfileHasResetTrigger()) |
| + url_list->insert(url_list->begin(), internals::GetResetSettingsURL()); |
|
engedy
2015/09/14 23:28:56
Just to double-check: if Chrome is allowed to run
robertshield
2015/09/21 04:16:23
That's a good catch, previously it would show up o
|
| +} |
| + |
| // For first-run, the type will be FIRST_RUN_LAST for all systems except for |
| // Windows 10+, where it will be FIRST_RUN_FIRST. For non-first run, the type |
| // will be NONE for all systems except for Windows 10+, where it will be |
| @@ -979,3 +991,16 @@ void StartupBrowserCreatorImpl::RecordRapporOnStartupURLs( |
| "Startup.BrowserLaunchURL", url); |
| } |
| } |
| + |
| +bool StartupBrowserCreatorImpl::ProfileHasResetTrigger() const { |
| +#if defined(OS_WIN) |
| + TriggeredProfileResetter* triggered_profile_resetter = |
| + TriggeredProfileResetterFactory::GetForBrowserContext(profile_); |
| + // TriggeredProfileResetter instance will be nullptr for incognito profiles. |
| + if (!triggered_profile_resetter) |
| + return false; |
| + return triggered_profile_resetter->HasResetTrigger(); |
| +#else |
| + return false; |
| +#endif // defined(OS_WIN) |
| +} |