| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace base { | 22 namespace base { |
| 23 class CommandLine; | 23 class CommandLine; |
| 24 class FilePath; | 24 class FilePath; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 class WebContents; | 28 class WebContents; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace internals { | 31 namespace internals { |
| 32 |
| 32 GURL GetWelcomePageURL(); | 33 GURL GetWelcomePageURL(); |
| 33 } | 34 |
| 35 // On Windows 10 and higher, the welcome page is shown once following each OS |
| 36 // upgrade, even when not in first-run. When this is true, the welcome page |
| 37 // precedes the NTP in the startup tabs, and the sync promo is not shown. |
| 38 bool ShowWelcomePageAfterFirstRun(); |
| 39 |
| 40 } // namespace internals |
| 34 | 41 |
| 35 // Assists launching the application and appending the initial tabs for a | 42 // Assists launching the application and appending the initial tabs for a |
| 36 // browser window. | 43 // browser window. |
| 37 class StartupBrowserCreatorImpl { | 44 class StartupBrowserCreatorImpl { |
| 38 public: | 45 public: |
| 39 // There are two ctors. The first one implies a NULL browser_creator object | 46 // There are two ctors. The first one implies a NULL browser_creator object |
| 40 // and thus no access to distribution-specific first-run behaviors. The | 47 // and thus no access to distribution-specific first-run behaviors. The |
| 41 // second one is always called when the browser starts even if it is not | 48 // second one is always called when the browser starts even if it is not |
| 42 // the first run. |is_first_run| indicates that this is a new profile. | 49 // the first run. |is_first_run| indicates that this is a new profile. |
| 43 StartupBrowserCreatorImpl(const base::FilePath& cur_dir, | 50 StartupBrowserCreatorImpl(const base::FilePath& cur_dir, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 // browser. | 79 // browser. |
| 73 Browser* OpenTabsInBrowser(Browser* browser, | 80 Browser* OpenTabsInBrowser(Browser* browser, |
| 74 bool process_startup, | 81 bool process_startup, |
| 75 const StartupTabs& tabs, | 82 const StartupTabs& tabs, |
| 76 chrome::HostDesktopType desktop_type); | 83 chrome::HostDesktopType desktop_type); |
| 77 | 84 |
| 78 private: | 85 private: |
| 79 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); | 86 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); |
| 80 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); | 87 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); |
| 81 | 88 |
| 89 enum class WelcomeRunType { |
| 90 NONE, // Do not inject the welcome page for this run. |
| 91 FIRST_RUN_FIRST, // Inject the welcome page as the first first-run tab. |
| 92 FIRST_RUN_LAST, // Inject the welcome page as the last first-run tab. |
| 93 ANY_RUN_FIRST, // Inject the welcome page as the first tab. |
| 94 }; |
| 95 |
| 82 // If the process was launched with the web application command line flags, | 96 // If the process was launched with the web application command line flags, |
| 83 // e.g. --app=http://www.google.com/ or --app_id=... return true. | 97 // e.g. --app=http://www.google.com/ or --app_id=... return true. |
| 84 // In this case |app_url| or |app_id| are populated if they're non-null. | 98 // In this case |app_url| or |app_id| are populated if they're non-null. |
| 85 bool IsAppLaunch(std::string* app_url, std::string* app_id); | 99 bool IsAppLaunch(std::string* app_url, std::string* app_id); |
| 86 | 100 |
| 87 // If IsAppLaunch is true, tries to open an application window. | 101 // If IsAppLaunch is true, tries to open an application window. |
| 88 // If the app is specified to start in a tab, or IsAppLaunch is false, | 102 // If the app is specified to start in a tab, or IsAppLaunch is false, |
| 89 // returns false to specify default processing. |out_app_contents| is an | 103 // returns false to specify default processing. |out_app_contents| is an |
| 90 // optional argument to receive the created WebContents for the app. | 104 // optional argument to receive the created WebContents for the app. |
| 91 bool OpenApplicationWindow(Profile* profile, | 105 bool OpenApplicationWindow(Profile* profile, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); | 148 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); |
| 135 | 149 |
| 136 // Adds any startup infobars to the selected tab of the given browser. | 150 // Adds any startup infobars to the selected tab of the given browser. |
| 137 void AddInfoBarsIfNecessary( | 151 void AddInfoBarsIfNecessary( |
| 138 Browser* browser, | 152 Browser* browser, |
| 139 chrome::startup::IsProcessStartup is_process_startup); | 153 chrome::startup::IsProcessStartup is_process_startup); |
| 140 | 154 |
| 141 // Adds additional startup URLs to the specified vector. | 155 // Adds additional startup URLs to the specified vector. |
| 142 void AddStartupURLs(std::vector<GURL>* startup_urls) const; | 156 void AddStartupURLs(std::vector<GURL>* startup_urls) const; |
| 143 | 157 |
| 144 // Checks whether the Preferences backup is invalid and notifies user in | 158 // Initializes |welcome_run_type_| for this launch. |
| 145 // that case. | 159 void InitializeWelcomeRunType(const std::vector<GURL>& urls_to_open); |
| 146 void CheckPreferencesBackup(Profile* profile); | 160 |
| 161 // Records that the welcome page was shown. |
| 162 void RecordWelcomeRunComplete() const; |
| 147 | 163 |
| 148 const base::FilePath cur_dir_; | 164 const base::FilePath cur_dir_; |
| 149 const base::CommandLine& command_line_; | 165 const base::CommandLine& command_line_; |
| 150 Profile* profile_; | 166 Profile* profile_; |
| 151 StartupBrowserCreator* browser_creator_; | 167 StartupBrowserCreator* browser_creator_; |
| 152 bool is_first_run_; | 168 bool is_first_run_; |
| 169 WelcomeRunType welcome_run_type_; |
| 153 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); | 170 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); |
| 154 }; | 171 }; |
| 155 | 172 |
| 156 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 173 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| OLD | NEW |