Chromium Code Reviews| Index: chrome/browser/browser_init.cc |
| =================================================================== |
| --- chrome/browser/browser_init.cc (revision 42688) |
| +++ chrome/browser/browser_init.cc (working copy) |
| @@ -28,6 +28,7 @@ |
| #include "chrome/browser/search_engines/template_url_model.h" |
| #include "chrome/browser/session_startup_pref.h" |
| #include "chrome/browser/sessions/session_restore.h" |
| +#include "chrome/browser/sessions/session_service.h" |
| #include "chrome/browser/shell_integration.h" |
| #include "chrome/browser/tabs/pinned_tab_codec.h" |
| #include "chrome/browser/tab_contents/infobar_delegate.h" |
| @@ -489,7 +490,6 @@ |
| std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_); |
| RecordLaunchModeHistogram(urls_to_open.empty()? |
| LM_TO_BE_DECIDED : LM_WITH_URLS); |
| - |
| // TODO(viettrungluu): Temporary: Display a EULA before allowing the user to |
| // actually enable Flash, unless they've already accepted it. Process this |
| // in the same way as command-line URLs. |
| @@ -506,17 +506,8 @@ |
| } |
| } |
| - if (!process_startup || !OpenStartupURLs(urls_to_open)) { |
| - // Add the home page and any special first run URLs. |
| - Browser* browser = NULL; |
| - if (urls_to_open.empty()) |
| - AddStartupURLs(&urls_to_open); |
| - else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) |
| - browser = BrowserList::GetLastActive(); |
| + ProcessLaunchURLs(process_startup, urls_to_open); |
| - OpenURLsInBrowser(browser, process_startup, urls_to_open); |
| - } |
| - |
| // If this is an app launch, but we didn't open an app window, it may |
| // be an app tab. |
| std::string app_id; |
| @@ -628,8 +619,37 @@ |
| return false; |
| } |
| -bool BrowserInit::LaunchWithProfile::OpenStartupURLs( |
| +void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( |
| + bool process_startup, |
| const std::vector<GURL>& urls_to_open) { |
| + if (process_startup && ProcessStartupURLs(urls_to_open)) { |
| + // ProcessStartupURLs processed the urls, nothing else to do. |
| + return; |
| + } |
| + |
| + if (!process_startup && |
| + (profile_->GetSessionService() && |
| + profile_->GetSessionService()->RestoreIfNecessary(urls_to_open))) { |
| + // We're already running and session restore wanted to run. This can happen |
| + // at various point, such as if there is only an app window running and the |
|
brettw
2010/03/26 00:33:32
grammar: point -> points
|
| + // user double clicked the chrome icon. Return so we don't open the urls. |
| + return; |
| + } |
| + |
| + // Session restore didn't occur, open the urls. |
| + |
| + Browser* browser = NULL; |
| + std::vector<GURL> adjust_urls = urls_to_open; |
| + if (adjust_urls.empty()) |
| + AddStartupURLs(&adjust_urls); |
| + else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) |
| + browser = BrowserList::GetLastActive(); |
| + |
| + OpenURLsInBrowser(browser, process_startup, adjust_urls); |
| +} |
| + |
| +bool BrowserInit::LaunchWithProfile::ProcessStartupURLs( |
| + const std::vector<GURL>& urls_to_open) { |
| SessionStartupPref pref = GetSessionStartupPref(command_line_, profile_); |
| if (command_line_.HasSwitch(switches::kTestingChannelID) && |
| !command_line_.HasSwitch(switches::kRestoreLastSession) && |