diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 15:58:08 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 15:58:08 +0000 |
commit | c9b19949487f406436c9f5cdfdf35ce3bd805d67 (patch) | |
tree | 0de3a25b34c84b1dcdbd84ae7205ca3a514fec7f /chrome/browser/browser_init.cc | |
parent | fdeb7ac65e407aa5334b6f5308f15be3dae70dd6 (diff) | |
download | chromium_src-c9b19949487f406436c9f5cdfdf35ce3bd805d67.zip chromium_src-c9b19949487f406436c9f5cdfdf35ce3bd805d67.tar.gz chromium_src-c9b19949487f406436c9f5cdfdf35ce3bd805d67.tar.bz2 |
Fixes bug where triggering session restore while the browser was
already running would end up creating an extra tab.
BUG=11594
TEST=open chrome with a single tabbed browser, turn on session
restore, navigate to a page with a popup, close the tabbed browser,
create a new window ala control-n (or double click on the desktop),
and make the restored window doesn't end upw
Review URL: http://codereview.chromium.org/1371002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.cc')
-rw-r--r-- | chrome/browser/browser_init.cc | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index b4518d7..56b296f 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -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 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, 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,16 +506,7 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, } } - 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(); - - OpenURLsInBrowser(browser, process_startup, urls_to_open); - } + ProcessLaunchURLs(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. @@ -628,7 +619,36 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) { 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 points, such as if there is only an app window running and the + // 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) && |