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 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/ui/startup/startup_tab.h" | 14 #include "chrome/browser/ui/startup/startup_tab.h" |
| 15 #include "chrome/browser/ui/startup/startup_tab_provider.h" | |
| 15 #include "chrome/browser/ui/startup/startup_types.h" | 16 #include "chrome/browser/ui/startup/startup_types.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 class Browser; | 19 class Browser; |
| 19 class Profile; | 20 class Profile; |
| 20 class StartupBrowserCreator; | 21 class StartupBrowserCreator; |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class CommandLine; | 24 class CommandLine; |
| 24 class FilePath; | 25 class FilePath; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 61 |
| 61 // Convenience for OpenTabsInBrowser that converts |urls| into a set of | 62 // Convenience for OpenTabsInBrowser that converts |urls| into a set of |
| 62 // Tabs. | 63 // Tabs. |
| 63 Browser* OpenURLsInBrowser(Browser* browser, | 64 Browser* OpenURLsInBrowser(Browser* browser, |
| 64 bool process_startup, | 65 bool process_startup, |
| 65 const std::vector<GURL>& urls); | 66 const std::vector<GURL>& urls); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); | 69 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); |
| 69 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); | 70 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); |
| 71 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, DetermineStartupTabs); | |
| 72 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, | |
| 73 DetermineStartupTabs_IncognitoOrCrash); | |
| 74 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, | |
| 75 DetermineStartupTabs_MasterPrefs); | |
| 76 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, | |
| 77 DetermineStartupTabs_CommandLine); | |
| 78 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, | |
| 79 DetermineStartupTabs_NewTabPage); | |
| 70 | 80 |
| 71 enum class WelcomeRunType { | 81 enum class WelcomeRunType { |
| 72 NONE, // Do not inject the welcome page for this run. | 82 NONE, // Do not inject the welcome page for this run. |
| 73 FIRST_TAB, // Inject the welcome page as the first tab. | 83 FIRST_TAB, // Inject the welcome page as the first tab. |
| 74 FIRST_RUN_LAST_TAB, // Inject the welcome page as the last first-run tab. | 84 FIRST_RUN_LAST_TAB, // Inject the welcome page as the last first-run tab. |
| 75 }; | 85 }; |
| 76 | 86 |
| 77 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null | 87 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null |
| 78 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed | 88 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed |
| 79 // browser is created and the tabs are added to it. The browser the tabs | 89 // browser is created and the tabs are added to it. The browser the tabs |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 99 | 109 |
| 100 // Invoked from Launch to handle processing of urls. This may do any of the | 110 // Invoked from Launch to handle processing of urls. This may do any of the |
| 101 // following: | 111 // following: |
| 102 // . Invoke ProcessStartupURLs if |process_startup| is true. | 112 // . Invoke ProcessStartupURLs if |process_startup| is true. |
| 103 // . If |process_startup| is false, restore the last session if necessary, | 113 // . If |process_startup| is false, restore the last session if necessary, |
| 104 // or invoke ProcessSpecifiedURLs. | 114 // or invoke ProcessSpecifiedURLs. |
| 105 // . Open the urls directly. | 115 // . Open the urls directly. |
| 106 void ProcessLaunchURLs(bool process_startup, | 116 void ProcessLaunchURLs(bool process_startup, |
| 107 const std::vector<GURL>& urls_to_open); | 117 const std::vector<GURL>& urls_to_open); |
| 108 | 118 |
| 119 // Determines the URLs to be shown at startup by way of various policies | |
| 120 // (onboarding, pinned tabs, etc.), determines whether a session restore | |
| 121 // is necessary, and opens the URLs in a new or restored browser accordingly. | |
| 122 // This method is a refactoring of ProcessLaunchURLs above, and will replace | |
| 123 // that code path entirely once kUseConsolidatedStartupFlow is on by default. | |
|
Peter Kasting
2016/09/29 07:23:34
Nit: For this last sentence, consider instead putt
| |
| 124 void ProcessLaunchUrlsUsingConsolidatedFlow( | |
| 125 bool process_startup, | |
| 126 const std::vector<GURL>& cmd_line_urls); | |
| 127 | |
| 128 // Returns the tabs to be shown on startup, based on the policy functions in | |
| 129 // the given StartupTabProvider, the given tabs passed by the command line, | |
| 130 // and the interactions between those policies. | |
| 131 StartupTabs DetermineStartupTabs(const StartupTabProvider& provider, | |
| 132 const StartupTabs& cmd_line_tabs, | |
| 133 bool is_incognito, | |
| 134 bool is_post_crash_launch); | |
| 135 | |
| 136 // Opens the given tabs in a new browser. | |
|
Peter Kasting
2016/09/29 07:23:34
Nit: It's not clear from this comment how this is
| |
| 137 // TODO(tmartino): Add the ability to restore a session, and an additional | |
| 138 // argument which indicates which behavior (new or restored) should be used. | |
| 139 Browser* RestoreOrCreateBrowser(bool process_startup, | |
| 140 const StartupTabs& tabs); | |
| 141 | |
| 109 // Does the following: | 142 // Does the following: |
| 110 // . If the user's startup pref is to restore the last session (or the | 143 // . If the user's startup pref is to restore the last session (or the |
| 111 // command line flag is present to force using last session), it is | 144 // command line flag is present to force using last session), it is |
| 112 // restored. | 145 // restored. |
| 113 // . Otherwise invoke ProcessSpecifiedURLs | 146 // . Otherwise invoke ProcessSpecifiedURLs |
| 114 // If a browser was created, true is returned. Otherwise returns false and | 147 // If a browser was created, true is returned. Otherwise returns false and |
| 115 // the caller must create a new browser. | 148 // the caller must create a new browser. |
| 116 bool ProcessStartupURLs(const std::vector<GURL>& urls_to_open); | 149 bool ProcessStartupURLs(const std::vector<GURL>& urls_to_open); |
| 117 | 150 |
| 118 // Invoked from either ProcessLaunchURLs or ProcessStartupURLs to handle | 151 // Invoked from either ProcessLaunchURLs or ProcessStartupURLs to handle |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 const base::FilePath cur_dir_; | 191 const base::FilePath cur_dir_; |
| 159 const base::CommandLine& command_line_; | 192 const base::CommandLine& command_line_; |
| 160 Profile* profile_; | 193 Profile* profile_; |
| 161 StartupBrowserCreator* browser_creator_; | 194 StartupBrowserCreator* browser_creator_; |
| 162 bool is_first_run_; | 195 bool is_first_run_; |
| 163 WelcomeRunType welcome_run_type_; | 196 WelcomeRunType welcome_run_type_; |
| 164 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); | 197 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); |
| 165 }; | 198 }; |
| 166 | 199 |
| 167 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 200 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| OLD | NEW |