diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 16:34:39 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 16:34:39 +0000 |
commit | 24bf202c6a8d5b4a481f75fb3eeaba3b218bca30 (patch) | |
tree | 6fb9108785edbf0493223dd6fd4a061202acebd0 /chrome/browser/browser.cc | |
parent | 62b0919a6e9100dd79baa307840ffc8b0496735f (diff) | |
download | chromium_src-24bf202c6a8d5b4a481f75fb3eeaba3b218bca30.zip chromium_src-24bf202c6a8d5b4a481f75fb3eeaba3b218bca30.tar.gz chromium_src-24bf202c6a8d5b4a481f75fb3eeaba3b218bca30.tar.bz2 |
Launch apps directly into NTP
Applications that are configured to be launched in a tab are now opened directly in the NTP, rather than opening a new tab and closing the NTP.
BUG=57476
TEST=Try launching an application from the new tab page. If it's set to open as a tab, a pinned tab, or full-screen, the application should launch directly into the existing new tab page. The new tab page should close when opening an application with panel launch type.
Review URL: http://codereview.chromium.org/3673006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r-- | chrome/browser/browser.cc | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 23ead52..b4afb439 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -485,7 +485,8 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { // this function return an error reason as well so that callers can show // reasonable errors? TabContents* Browser::OpenApplication(Profile* profile, - const std::string& app_id) { + const std::string& app_id, + TabContents* existing_tab) { ExtensionsService* extensions_service = profile->GetExtensionsService(); if (!extensions_service->is_ready()) return NULL; @@ -496,14 +497,16 @@ TabContents* Browser::OpenApplication(Profile* profile, if (!extension) return NULL; - return OpenApplication(profile, extension, extension->launch_container()); + return OpenApplication(profile, extension, extension->launch_container(), + existing_tab); } // static TabContents* Browser::OpenApplication( Profile* profile, Extension* extension, - extension_misc::LaunchContainer container) { + extension_misc::LaunchContainer container, + TabContents* existing_tab) { TabContents* tab = NULL; UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); @@ -516,7 +519,7 @@ TabContents* Browser::OpenApplication( GURL()); break; case extension_misc::LAUNCH_TAB: { - tab = Browser::OpenApplicationTab(profile, extension); + tab = Browser::OpenApplicationTab(profile, extension, existing_tab); break; } default: @@ -580,7 +583,8 @@ TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) { // static TabContents* Browser::OpenApplicationTab(Profile* profile, - Extension* extension) { + Extension* extension, + TabContents* existing_tab) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); TabContents* contents = NULL; if (!browser || browser->type() != Browser::TYPE_NORMAL) @@ -602,7 +606,24 @@ TabContents* Browser::OpenApplicationTab(Profile* profile, AddTabWithURLParams params(extension->GetFullLaunchURL(), PageTransition::START_PAGE); params.add_types = add_type; - contents = browser->AddTabWithURL(¶ms); + + // Launch the application in the existing TabContents, if it was supplied. + if (existing_tab) { + TabStripModel* model = browser->tabstrip_model(); + int tab_index = model->GetIndexOfTabContents(existing_tab); + + existing_tab->OpenURL(extension->GetFullLaunchURL(), existing_tab->GetURL(), + CURRENT_TAB, PageTransition::LINK); + if (params.add_types & TabStripModel::ADD_PINNED) + model->SetTabPinned(tab_index, true); + if (params.add_types & TabStripModel::ADD_SELECTED) + model->SelectTabContentsAt(tab_index, true); + + contents = existing_tab; + } else { + contents = browser->AddTabWithURL(¶ms); + } + if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN) browser->window()->SetFullscreen(true); |