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

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: 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.
grt (UTC plus 2) 2016/10/28 09:22:12 nit: add a trailing comma
tmartino 2016/10/28 18:34:27 Done
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 // Determines whether an asynchronous session restore is necessary; if so,
132 // kicks one off and returns true.
133 bool MaybeAsyncRestore(const StartupTabs& tabs,
134 bool process_startup,
135 bool is_post_crash_launch);
136
137 // Returns a browser displaying the contents of |tabs|. Based on |behavior|,
138 // this may attempt a session restore or create a new browser. May also allow
139 // DOM Storage to begin cleanup once it's clear it is not needed anymore.
140 Browser* RestoreOrCreateBrowser(const StartupTabs& tabs,
141 BrowserOpenBehavior behavior,
142 uint32_t restore_options,
143 bool process_startup,
144 bool is_post_crash_launch);
145
146 // Determines how the launch flow should obtain a Browser.
147 static BrowserOpenBehavior DetermineBrowserOpenBehavior(
148 const SessionStartupPref& pref,
149 bool process_startup,
150 bool is_post_crash_launch,
151 bool has_restore_switch,
152 bool has_new_window_switch,
153 bool has_cmd_line_tabs);
154
155 // Populates and returns the relevant bitmask options which must be passed
156 // when restoring a session.
157 static uint32_t DetermineSynchronousRestoreOptions(
158 bool has_create_browser_default,
159 bool has_create_browser_switch,
160 bool was_mac_login_or_resume);
161
125 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist 162 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist
126 // in |tabs|. 163 // in |tabs|.
127 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); 164 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs);
128 165
129 // Adds any startup infobars to the selected tab of the given browser. 166 // Adds any startup infobars to the selected tab of the given browser.
130 void AddInfoBarsIfNecessary( 167 void AddInfoBarsIfNecessary(
131 Browser* browser, 168 Browser* browser,
132 chrome::startup::IsProcessStartup is_process_startup); 169 chrome::startup::IsProcessStartup is_process_startup);
133 170
134 // Records Rappor metrics on startup URLs. 171 // Records Rappor metrics on startup URLs.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const base::FilePath cur_dir_; 225 const base::FilePath cur_dir_;
189 const base::CommandLine& command_line_; 226 const base::CommandLine& command_line_;
190 Profile* profile_; 227 Profile* profile_;
191 StartupBrowserCreator* browser_creator_; 228 StartupBrowserCreator* browser_creator_;
192 bool is_first_run_; 229 bool is_first_run_;
193 WelcomeRunType welcome_run_type_; 230 WelcomeRunType welcome_run_type_;
194 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); 231 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl);
195 }; 232 };
196 233
197 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ 234 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698