Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_browser_creator_impl.h |
| diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.h b/chrome/browser/ui/startup/startup_browser_creator_impl.h |
| index 0ce1f3b775307784c001b237b83e5787ffc812f1..4c15f8d69a1a520566ea740545e6aafac2eda29b 100644 |
| --- a/chrome/browser/ui/startup/startup_browser_creator_impl.h |
| +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.h |
| @@ -11,6 +11,7 @@ |
| #include "base/files/file_path.h" |
| #include "base/gtest_prod_util.h" |
| #include "base/macros.h" |
| +#include "chrome/browser/sessions/session_restore.h" |
| #include "chrome/browser/ui/startup/startup_tab.h" |
| #include "chrome/browser/ui/startup/startup_tab_provider.h" |
| #include "chrome/browser/ui/startup/startup_types.h" |
| @@ -73,6 +74,14 @@ class StartupBrowserCreatorImpl { |
| DetermineStartupTabs_CommandLine); |
| FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, |
| DetermineStartupTabs_NewTabPage); |
| + FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, |
| + DetermineBrowserOpenBehavior_Startup); |
| + FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, |
| + DetermineBrowserOpenBehavior_CmdLineTabs); |
| + FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, |
| + DetermineBrowserOpenBehavior_PostCrash); |
| + FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, |
| + DetermineBrowserOpenBehavior_NotStartup); |
| enum class WelcomeRunType { |
| NONE, // Do not inject the welcome page for this run. |
| @@ -80,6 +89,7 @@ class StartupBrowserCreatorImpl { |
| FIRST_RUN_LAST_TAB, // Inject the welcome page as the last first-run tab. |
| }; |
| + // Window behaviors possible when opening Chrome. |
| enum class BrowserOpenBehavior { |
| NEW, // Open in a new browser. |
| SYNCHRONOUS_RESTORE, // Attempt a synchronous session restore. |
| @@ -138,7 +148,7 @@ class StartupBrowserCreatorImpl { |
| // DOM Storage to begin cleanup once it's clear it is not needed anymore. |
| Browser* RestoreOrCreateBrowser(const StartupTabs& tabs, |
| BrowserOpenBehavior behavior, |
| - uint32_t restore_options, |
| + SessionRestore::Behavior restore_options, |
| bool process_startup, |
| bool is_post_crash_launch); |
| @@ -154,18 +164,25 @@ class StartupBrowserCreatorImpl { |
| // Records Rappor metrics on startup URLs. |
| void RecordRapporOnStartupURLs(const std::vector<GURL>& urls_to_open); |
| + // Boolean flags used to indicate state for DetermineBrowserOpenBehavior. |
| + enum BehaviorFlags { |
|
Peter Kasting
2017/02/06 23:26:40
Nit: Technically typedefs and enums belong at the
|
| + PROCESS_STARTUP = (1 << 0), |
| + IS_POST_CRASH_LAUNCH = (1 << 1), |
| + HAS_RESTORE_SWITCH = (1 << 2), |
| + HAS_NEW_WINDOW_SWITCH = (1 << 3), |
| + HAS_CMD_LINE_TABS = (1 << 4), |
| + }; |
| + |
| + typedef uint32_t BrowserOpenBehaviorOptions; |
|
Peter Kasting
2017/02/06 23:26:40
I'm of two minds on this set of flags.
On one han
tmartino
2017/02/06 23:52:19
I originally wrote the tests using the bools appro
Peter Kasting
2017/02/07 00:11:59
OK. I think if you're confident, your instinct sh
|
| + |
| // Determines how the launch flow should obtain a Browser. |
| static BrowserOpenBehavior DetermineBrowserOpenBehavior( |
| const SessionStartupPref& pref, |
| - bool process_startup, |
| - bool is_post_crash_launch, |
| - bool has_restore_switch, |
| - bool has_new_window_switch, |
| - bool has_cmd_line_tabs); |
| + BrowserOpenBehaviorOptions options); |
| // Returns the relevant bitmask options which must be passed when restoring a |
| // session. |
| - static uint32_t DetermineSynchronousRestoreOptions( |
| + static SessionRestore::Behavior DetermineSynchronousRestoreOptions( |
| bool has_create_browser_default, |
| bool has_create_browser_switch, |
| bool was_mac_login_or_resume); |