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

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

Issue 2457653003: Completing refactor of startup_browser_creator_impl (Closed)
Patch Set: TabsToUrls optimizations 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
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 18 matching lines...) Expand all
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_incognito,
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,
Peter Kasting 2016/10/31 19:24:06 Nit: Here and in DetermineSynchronousRestoreOption
tmartino 2016/11/02 16:34:00 Ack. Made a note to self to look at this when I ma
Peter Kasting 2016/11/02 17:00:46 SGTM
146 bool process_startup,
147 bool is_post_crash_launch);
148
149 // Determines how the launch flow should obtain a Browser.
150 static BrowserOpenBehavior DetermineBrowserOpenBehavior(
Peter Kasting 2016/10/31 19:24:06 Nit: I suggest placing static methods either above
tmartino 2016/11/02 16:34:00 Agreed. Moved them to be the last non-deprecated f
grt (UTC plus 2) 2016/11/03 09:43:34 Minor note: the style guide doesn't dictate where
Peter Kasting 2016/11/03 21:46:42 Yes; there is no style rule on this. The majority
151 const SessionStartupPref& pref,
152 bool process_startup,
153 bool is_post_crash_launch,
154 bool has_restore_switch,
155 bool has_new_window_switch,
156 bool has_cmd_line_tabs);
157
158 // Populates and returns the relevant bitmask options which must be passed
Peter Kasting 2016/10/31 19:24:06 Nit: No need for "Populates and"
tmartino 2016/11/02 16:34:00 Done.
159 // when restoring a session.
160 static uint32_t DetermineSynchronousRestoreOptions(
161 bool has_create_browser_default,
162 bool has_create_browser_switch,
163 bool was_mac_login_or_resume);
164
125 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist 165 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist
126 // in |tabs|. 166 // in |tabs|.
127 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); 167 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs);
128 168
129 // Adds any startup infobars to the selected tab of the given browser. 169 // Adds any startup infobars to the selected tab of the given browser.
130 void AddInfoBarsIfNecessary( 170 void AddInfoBarsIfNecessary(
131 Browser* browser, 171 Browser* browser,
132 chrome::startup::IsProcessStartup is_process_startup); 172 chrome::startup::IsProcessStartup is_process_startup);
133 173
134 // Records Rappor metrics on startup URLs. 174 // Records Rappor metrics on startup URLs.
(...skipping 53 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

Powered by Google App Engine
This is Rietveld 408576698