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 54d468b826f90f25d1ea29eb5efde8edd6f1cce8..9e71e9acbbcb1d720d763c4344abfe135a079ced 100644 |
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc |
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc |
@@ -18,6 +18,7 @@ |
#include "base/command_line.h" |
#include "base/compiler_specific.h" |
#include "base/environment.h" |
+#include "base/feature_list.h" |
#include "base/lazy_instance.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/metrics/statistics_recorder.h" |
@@ -39,6 +40,7 @@ |
#include "chrome/browser/extensions/launch_util.h" |
#include "chrome/browser/extensions/pack_extension_job.h" |
#include "chrome/browser/first_run/first_run.h" |
+#include "chrome/browser/first_run/first_run_features.h" |
#include "chrome/browser/infobars/infobar_service.h" |
#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/prefs/session_startup_pref.h" |
@@ -499,6 +501,13 @@ bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { |
void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
bool process_startup, |
const std::vector<GURL>& urls_to_open) { |
+ if (base::FeatureList::IsEnabled(features::kUseConsolidatedFirstRun)) { |
+ ProcessLaunchURLsUsingConsolidatedFlow(process_startup, urls_to_open); |
+ return; |
+ } |
+ // TODO(tmartino): Remainder of this function is deprecated. Remove when |
+ // kUseConsolidatedFirstRun is on by default. |
+ |
// Don't open any browser windows if we're starting up in "background mode". |
if (process_startup && command_line_.HasSwitch(switches::kNoStartupWindow)) |
return; |
@@ -506,15 +515,6 @@ void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
// Determine whether or not this launch must include the welcome page. |
InitializeWelcomeRunType(urls_to_open); |
-// TODO(tapted): Move this to startup_browser_creator_win.cc after refactor. |
-#if defined(OS_WIN) |
- if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
- // See if there are apps for this profile that should be launched on startup |
- // due to a switch from Metro mode. |
- app_metro_launch::HandleAppLaunchForMetroRestart(profile_); |
- } |
-#endif |
- |
if (process_startup && ProcessStartupURLs(urls_to_open)) { |
// ProcessStartupURLs processed the urls, nothing else to do. |
return; |
@@ -566,6 +566,70 @@ void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
AddInfoBarsIfNecessary(browser, is_process_startup); |
} |
+void StartupBrowserCreatorImpl::ProcessLaunchURLsUsingConsolidatedFlow( |
+ bool process_startup, |
+ const std::vector<GURL>& urls_to_open) { |
+ std::vector<GURL> adjusted_urls(urls_to_open); |
+ |
+ // Don't open any browser windows if we're starting up in "background mode". |
grt (UTC plus 2)
2016/08/23 10:36:02
nit: i'm in the "no personal pronouns" camp (https
tmartino
2016/09/08 21:33:17
Done.
|
+ if (process_startup && command_line_.HasSwitch(switches::kNoStartupWindow)) |
+ return; |
+ |
+ // If Master Prefs contains any first run tabs, use only those. |
grt (UTC plus 2)
2016/08/23 10:36:02
in the old logic, URLs on the command-line suppres
tmartino
2016/09/08 21:33:16
Good catch; done.
|
+ std::vector<GURL> tabs_to_insert; |
+ if (browser_creator_) { |
grt (UTC plus 2)
2016/08/23 10:36:02
&& !browser_creator_->first_run_tabs_.empty()
tmartino
2016/09/08 21:33:16
Ack, see thread about ProcessMasterPrefsTabs in fi
|
+ tabs_to_insert = |
grt (UTC plus 2)
2016/08/23 10:36:02
if you're assuming that first_run_tabs_ will never
grt (UTC plus 2)
2016/08/23 10:36:02
also add:
DCHECK(process_startup);
to document
tmartino
2016/09/08 21:33:16
Note that this logic has been moved to startup_tab
grt (UTC plus 2)
2016/09/09 11:40:29
when i wrote that, i must have been thinking "how
tmartino
2016/09/10 00:19:40
Two things of note:
1. IsChromeFirstRun uses a cac
|
+ first_run::ProcessMasterPrefsTabs(browser_creator_->first_run_tabs_); |
+ browser_creator_->first_run_tabs_.clear(); |
+ } |
+ // Otherwise, use the standard Onboarding logic to determine which, if any, |
+ // tabs need to be surfaced. |
+ if (tabs_to_insert.empty()) { |
+ first_run::FirstRunSystemStatus status = |
+ first_run::GetFirstRunSystemStatus(); |
+ tabs_to_insert = first_run::GetOnboardingTabs(status); |
+ } |
+ |
grt (UTC plus 2)
2016/08/23 10:36:02
is it intentional that the NTP is no longer opened
tmartino
2016/09/08 21:33:16
No, good catch. Thanks.
|
+ // If this profile is marked for a reset prompt, put this before all other |
+ // tabs. |
+ if (ProfileHasResetTrigger()) { |
+ tabs_to_insert.insert(tabs_to_insert.begin(), |
+ internals::GetTriggeredResetSettingsURL()); |
+ } |
+ |
+ // TODO(tmartino): Function for processing pinned tabs. |
+ |
+ // Prepend the resulting list of tabs to those passed in. |
+ if (!tabs_to_insert.empty()) { |
+ adjusted_urls.insert(adjusted_urls.begin(), tabs_to_insert.begin(), |
+ tabs_to_insert.end()); |
+ } |
+ |
+ // TODO(tmartino): If this is not process startup, we need to restore |
+ // asynchronously and return here. |
+ |
+ // See if we can or should restore an old session synchronously. |
+ Browser* browser = MaybeRestoreSession(process_startup, adjusted_urls); |
grt (UTC plus 2)
2016/08/23 10:36:02
can you break this function into two: one that com
|
+ |
+ // Otherwise, open. |
+ if (!browser) { |
grt (UTC plus 2)
2016/08/23 10:36:02
nit: omit braces
tmartino
2016/09/08 21:33:16
N/A
|
+ browser = OpenURLsInBrowser(browser, process_startup, adjusted_urls); |
+ } |
+ |
+ // Finally, add info bars. |
+ chrome::startup::IsProcessStartup is_process_startup = |
+ process_startup ? chrome::startup::IS_PROCESS_STARTUP |
+ : chrome::startup::IS_NOT_PROCESS_STARTUP; |
+ AddInfoBarsIfNecessary(browser, is_process_startup); |
+} |
+ |
+Browser* StartupBrowserCreatorImpl::MaybeRestoreSession( |
+ bool process_startup, |
+ const std::vector<GURL>& urls) { |
+ // TODO(tmartino): Move session restore logic into this function. |
+ return NULL; |
grt (UTC plus 2)
2016/08/23 10:36:02
nit: nullptr
tmartino
2016/09/08 21:33:17
Done (throughout)
|
+} |
+ |
bool StartupBrowserCreatorImpl::ProcessStartupURLs( |
const std::vector<GURL>& urls_to_open) { |
VLOG(1) << "StartupBrowserCreatorImpl::ProcessStartupURLs"; |
@@ -648,6 +712,9 @@ bool StartupBrowserCreatorImpl::ProcessStartupURLs( |
Browser* StartupBrowserCreatorImpl::ProcessSpecifiedURLs( |
const std::vector<GURL>& urls_to_open) { |
+ // TODO(tmartino): Deprecated, remove this once UseConsolidatedFirstRun is |
+ // enabled. |
+ |
SessionStartupPref pref = |
StartupBrowserCreator::GetSessionStartupPref(command_line_, profile_); |
StartupTabs tabs; |
@@ -826,8 +893,8 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( |
void StartupBrowserCreatorImpl::AddStartupURLs( |
std::vector<GURL>* startup_urls) const { |
- // TODO(atwilson): Simplify the logic that decides which tabs to open on |
- // start-up and make it more consistent. http://crbug.com/248883 |
+ // TODO(tmartino): Deprecated, remove this once UseConsolidatedFirstRun is |
+ // enabled. |
// If we have urls specified by the first run master preferences use them |
// and nothing else. |
@@ -893,6 +960,9 @@ void StartupBrowserCreatorImpl::AddStartupURLs( |
void StartupBrowserCreatorImpl::AddSpecialURLs( |
std::vector<GURL>* url_list) const { |
+ // TODO(tmartino): Deprecated, remove this once UseConsolidatedFirstRun is |
+ // enabled. |
+ |
// Optionally include the welcome page. |
if (welcome_run_type_ == WelcomeRunType::FIRST_TAB) |
url_list->insert(url_list->begin(), internals::GetWelcomePageURL()); |
@@ -910,6 +980,9 @@ void StartupBrowserCreatorImpl::AddSpecialURLs( |
// will be NONE for all systems except for Windows 10+, where it will be |
// ANY_RUN_FIRST if this is the first somewhat normal launch since an OS |
// upgrade. |
+ |
+// TODO(tmartino): Deprecated, remove this once UseConsolidatedFirstRun is |
+// enabled. |
void StartupBrowserCreatorImpl::InitializeWelcomeRunType( |
const std::vector<GURL>& urls_to_open) { |
DCHECK_EQ(static_cast<int>(WelcomeRunType::NONE), |