Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl.h

Issue 2492963003: Completing refactor of startup_browser_creator_impl. This includes: (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 DetermineStartupTabs_CommandLine); 77 DetermineStartupTabs_CommandLine);
78 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest, 78 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorImplTest,
79 DetermineStartupTabs_NewTabPage); 79 DetermineStartupTabs_NewTabPage);
80 80
81 enum class WelcomeRunType { 81 enum class WelcomeRunType {
82 NONE, // Do not inject the welcome page for this run. 82 NONE, // Do not inject the welcome page for this run.
83 FIRST_TAB, // Inject the welcome page as the first tab. 83 FIRST_TAB, // Inject the welcome page as the first tab.
84 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.
85 }; 85 };
86 86
87 enum class BrowserOpenBehavior {
88 NEW, // Open in a new browser.
89 SYNCHRONOUS_RESTORE, // Attempt a synchronous session restore.
90 USE_EXISTING, // Attempt to add to an existing tabbed browser.
91 };
92
87 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null 93 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null
88 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed 94 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed
89 // browser is created and the tabs are added to it. The browser the tabs 95 // browser is created and the tabs are added to it. The browser the tabs
90 // are added to is returned, which is either |browser| or the newly created 96 // are added to is returned, which is either |browser| or the newly created
91 // browser. 97 // browser.
92 Browser* OpenTabsInBrowser(Browser* browser, 98 Browser* OpenTabsInBrowser(Browser* browser,
93 bool process_startup, 99 bool process_startup,
94 const StartupTabs& tabs); 100 const StartupTabs& tabs);
95 101
96 // If the process was launched with the web application command line flags, 102 // If the process was launched with the web application command line flags,
(...skipping 15 matching lines...) Expand all
112 // is necessary, and opens the URLs in a new or restored browser accordingly. 118 // is necessary, and opens the URLs in a new or restored browser accordingly.
113 void ProcessLaunchUrlsUsingConsolidatedFlow( 119 void ProcessLaunchUrlsUsingConsolidatedFlow(
114 bool process_startup, 120 bool process_startup,
115 const std::vector<GURL>& cmd_line_urls); 121 const std::vector<GURL>& cmd_line_urls);
116 122
117 // Returns the tabs to be shown on startup, based on the policy functions in 123 // Returns the tabs to be shown on startup, based on the policy functions in
118 // the given StartupTabProvider, the given tabs passed by the command line, 124 // the given StartupTabProvider, the given tabs passed by the command line,
119 // and the interactions between those policies. 125 // and the interactions between those policies.
120 StartupTabs DetermineStartupTabs(const StartupTabProvider& provider, 126 StartupTabs DetermineStartupTabs(const StartupTabProvider& provider,
121 const StartupTabs& cmd_line_tabs, 127 const StartupTabs& cmd_line_tabs,
122 bool is_incognito, 128 bool is_ephemeral_profile,
123 bool is_post_crash_launch); 129 bool is_post_crash_launch);
124 130
131 // Begins an asynchronous session restore if current state allows it (e.g.,
132 // this is not process startup) and SessionService indicates that one is
133 // necessary. Returns true if restore was initiated, or false if launch
134 // should continue (either synchronously, or asynchronously without
135 // restoring).
136 bool MaybeAsyncRestore(const StartupTabs& tabs,
137 bool process_startup,
138 bool is_post_crash_launch);
139
140 // Returns a browser displaying the contents of |tabs|. Based on |behavior|,
141 // this may attempt a session restore or create a new browser. May also allow
142 // DOM Storage to begin cleanup once it's clear it is not needed anymore.
143 Browser* RestoreOrCreateBrowser(const StartupTabs& tabs,
144 BrowserOpenBehavior behavior,
145 uint32_t restore_options,
146 bool process_startup,
147 bool is_post_crash_launch);
148
125 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist 149 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist
126 // in |tabs|. 150 // in |tabs|.
127 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); 151 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs);
128 152
129 // Adds any startup infobars to the selected tab of the given browser. 153 // Adds any startup infobars to the selected tab of the given browser.
130 void AddInfoBarsIfNecessary( 154 void AddInfoBarsIfNecessary(
131 Browser* browser, 155 Browser* browser,
132 chrome::startup::IsProcessStartup is_process_startup); 156 chrome::startup::IsProcessStartup is_process_startup);
133 157
134 // Records Rappor metrics on startup URLs. 158 // Records Rappor metrics on startup URLs.
135 void RecordRapporOnStartupURLs(const std::vector<GURL>& urls_to_open); 159 void RecordRapporOnStartupURLs(const std::vector<GURL>& urls_to_open);
136 160
161 // Determines how the launch flow should obtain a Browser.
162 static BrowserOpenBehavior DetermineBrowserOpenBehavior(
163 const SessionStartupPref& pref,
164 bool process_startup,
165 bool is_post_crash_launch,
166 bool has_restore_switch,
167 bool has_new_window_switch,
168 bool has_cmd_line_tabs);
169
170 // Returns the relevant bitmask options which must be passed when restoring a
171 // session.
172 static uint32_t DetermineSynchronousRestoreOptions(
173 bool has_create_browser_default,
174 bool has_create_browser_switch,
175 bool was_mac_login_or_resume);
176
137 // TODO(crbug.com/651465): The following functions are deprecated. They will 177 // TODO(crbug.com/651465): The following functions are deprecated. They will
138 // be removed once kUseConsolidatedStartupFlow is enabled by default. 178 // be removed once kUseConsolidatedStartupFlow is enabled by default.
139 179
140 // Invoked from Launch to handle processing of urls. This may do any of the 180 // Invoked from Launch to handle processing of urls. This may do any of the
141 // following: 181 // following:
142 // . Invoke ProcessStartupURLs if |process_startup| is true. 182 // . Invoke ProcessStartupURLs if |process_startup| is true.
143 // . If |process_startup| is false, restore the last session if necessary, 183 // . If |process_startup| is false, restore the last session if necessary,
144 // or invoke ProcessSpecifiedURLs. 184 // or invoke ProcessSpecifiedURLs.
145 // . Open the urls directly. 185 // . Open the urls directly.
146 // Under the kUseConsolidatedStartupFlow feature, this is replaced by 186 // Under the kUseConsolidatedStartupFlow feature, this is replaced by
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const base::FilePath cur_dir_; 228 const base::FilePath cur_dir_;
189 const base::CommandLine& command_line_; 229 const base::CommandLine& command_line_;
190 Profile* profile_; 230 Profile* profile_;
191 StartupBrowserCreator* browser_creator_; 231 StartupBrowserCreator* browser_creator_;
192 bool is_first_run_; 232 bool is_first_run_;
193 WelcomeRunType welcome_run_type_; 233 WelcomeRunType welcome_run_type_;
194 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); 234 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl);
195 }; 235 };
196 236
197 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ 237 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698