summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 21:21:53 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 21:21:53 +0000
commitbbadaa787f4ec8a7365e499a13bf14aef3a16a06 (patch)
tree1dacfa8d358227743fa92384de27e09aeaeb4783 /chrome/browser
parent5cec0eb314bb4936e29d9138d259a4706aeacf4f (diff)
downloadchromium_src-bbadaa787f4ec8a7365e499a13bf14aef3a16a06.zip
chromium_src-bbadaa787f4ec8a7365e499a13bf14aef3a16a06.tar.gz
chromium_src-bbadaa787f4ec8a7365e499a13bf14aef3a16a06.tar.bz2
fullscreen window app launch container
BUG=42447 TEST=none Review URL: http://codereview.chromium.org/1730013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc63
-rw-r--r--chrome/browser/browser.h27
-rw-r--r--chrome/browser/browser_init.cc4
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc10
4 files changed, 70 insertions, 34 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index fdb213b..d06f748 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -388,43 +388,58 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
// TODO(erikkay): There are multiple reasons why this could fail. Should
// this function return an error reason as well so that callers can show
// reasonable errors?
-bool Browser::OpenApplication(Profile* profile, const std::string& app_id) {
+TabContents* Browser::OpenApplication(Profile* profile,
+ const std::string& app_id) {
ExtensionsService* extensions_service = profile->GetExtensionsService();
if (!extensions_service->is_ready())
- return false;
+ return NULL;
// If the extension with |app_id| could't be found, most likely because it
// was uninstalled.
- Extension* extension_app =
- extensions_service->GetExtensionById(app_id, false);
- if (!extension_app)
- return false;
+ Extension* extension = extensions_service->GetExtensionById(app_id, false);
+ if (!extension)
+ return NULL;
- // TODO(erikkay): Support refocus.
- Extension::LaunchContainer launch_container =
- extension_app->launch_container();
- switch (launch_container) {
+ return OpenApplication(profile, extension, extension->launch_container());
+}
+
+TabContents* Browser::OpenApplication(Profile* profile,
+ Extension* extension,
+ Extension::LaunchContainer container) {
+ TabContents* tab = NULL;
+ switch (container) {
case Extension::LAUNCH_WINDOW:
case Extension::LAUNCH_PANEL:
- Browser::OpenApplicationWindow(profile, extension_app);
+ tab = Browser::OpenApplicationWindow(profile, extension, container,
+ GURL());
break;
case Extension::LAUNCH_TAB: {
- return Browser::OpenApplicationTab(profile, extension_app);
+ tab = Browser::OpenApplicationTab(profile, extension);
break;
}
default:
NOTREACHED();
- return false;
+ break;
}
- return true;
+ if (tab) {
+ Browser* browser = tab->delegate()->GetBrowser();
+ if (browser && extension && extension->launch_fullscreen())
+ browser->window()->SetFullscreen(true);
+ }
+ return tab;
}
// static
-void Browser::OpenApplicationWindow(Profile* profile, Extension* extension,
- const GURL& url, bool as_panel) {
+TabContents* Browser::OpenApplicationWindow(
+ Profile* profile,
+ Extension* extension,
+ Extension::LaunchContainer container,
+ const GURL& url) {
+ // TODO(erikkay) this can't be correct for extensions
std::wstring app_name = web_app::GenerateApplicationNameFromURL(url);
RegisterAppPrefs(app_name);
+ bool as_panel = extension && (container == Extension::LAUNCH_PANEL);
Browser* browser = Browser::CreateForApp(app_name, extension, profile,
as_panel);
browser->AddTabWithURL(extension ? extension->GetFullLaunchURL() : url,
@@ -435,6 +450,7 @@ void Browser::OpenApplicationWindow(Profile* profile, Extension* extension,
tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
tab_contents->render_view_host()->SyncRendererPrefs();
browser->window()->Show();
+
// TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
// focus explicitly.
tab_contents->view()->SetInitialFocus();
@@ -448,19 +464,22 @@ void Browser::OpenApplicationWindow(Profile* profile, Extension* extension,
// pending web app action.
browser->pending_web_app_action_ = UPDATE_SHORTCUT;
}
+
+ return tab_contents;
}
// static
-void Browser::OpenApplicationWindow(Profile* profile, Extension* extension) {
- OpenApplicationWindow(profile, extension, GURL(),
- (extension->launch_container() == Extension::LAUNCH_PANEL));
+TabContents* Browser::OpenApplicationWindow(Profile* profile,
+ GURL& url) {
+ return OpenApplicationWindow(profile, NULL, Extension::LAUNCH_WINDOW, url);
}
// static
-bool Browser::OpenApplicationTab(Profile* profile, Extension* extension) {
+TabContents* Browser::OpenApplicationTab(Profile* profile,
+ Extension* extension) {
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
if (!browser || browser->type() != Browser::TYPE_NORMAL)
- return false;
+ return NULL;
// TODO(erikkay): This doesn't seem like the right transition in all cases.
PageTransition::Type transition = PageTransition::START_PAGE;
@@ -470,7 +489,7 @@ bool Browser::OpenApplicationTab(Profile* profile, Extension* extension) {
transition, false, NULL);
tab_contents->SetAppExtension(extension);
browser->AddTab(tab_contents, transition);
- return true;
+ return tab_contents;
}
// static
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 8c28147..2604fa3 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -20,6 +20,7 @@
#include "chrome/browser/tab_contents/page_navigator.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/toolbar_model.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/page_zoom.h"
#include "gfx/rect.h"
@@ -208,24 +209,36 @@ class Browser : public TabStripModelDelegate,
static void OpenURLOffTheRecord(Profile* profile, const GURL& url);
// Open an application specified by |app_id| in the appropriate launch
- // container. Returns false if the app_id is invalid or if ExtensionsService
+ // container. Returns NULL if the app_id is invalid or if ExtensionsService
// isn't ready/available.
- static bool OpenApplication(Profile* profile, const std::string& app_id);
+ static TabContents* OpenApplication(Profile* profile,
+ const std::string& app_id);
+
+ // Open |extension| in |container|. Returns the TabContents* that was created
+ // or NULL.
+ static TabContents* OpenApplication(Profile* profile,
+ Extension* extension,
+ Extension::LaunchContainer container);
// Opens a new application window for the specified url. If |as_panel|
// is true, the application will be opened as a Browser::Type::APP_PANEL in
// app panel window, otherwise it will be opened as as either
// Browser::Type::APP a.k.a. "thin frame" (if |extension| is NULL) or
// Browser::Type::EXTENSION_APP (if |extension| is non-NULL).
- static void OpenApplicationWindow(Profile* profile, Extension* extension,
- const GURL& url, bool as_panel);
+ static TabContents* OpenApplicationWindow(
+ Profile* profile,
+ Extension* extension,
+ Extension::LaunchContainer container,
+ const GURL& url);
// Open an application for |extension| in a new application window or panel.
- static void OpenApplicationWindow(Profile* profile, Extension* extension);
+ static TabContents* OpenApplicationWindow(Profile* profile,
+ GURL& url);
// Open an application for |extension| in a new application tab. Returns
- // false if there are no appropriate existing browser windows for |profile|.
- static bool OpenApplicationTab(Profile* profile, Extension* extension);
+ // NULL if there are no appropriate existing browser windows for |profile|.
+ static TabContents* OpenApplicationTab(Profile* profile,
+ Extension* extension);
// Opens a new window and opens the bookmark manager.
static void OpenBookmarkManagerWindow(Profile* profile);
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 8da58f6..93a5ba5 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -583,7 +583,7 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) {
// TODO(rafaelw): Do something reasonable here. Pop up a warning panel?
// Open an URL to the gallery page of the extension id?
if (!app_id.empty())
- return Browser::OpenApplication(profile, app_id);
+ return Browser::OpenApplication(profile, app_id) != NULL;
if (url_string.empty())
return false;
@@ -599,7 +599,7 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) {
ChildProcessSecurityPolicy::GetInstance();
if (policy->IsWebSafeScheme(url.scheme()) ||
url.SchemeIs(chrome::kFileScheme)) {
- Browser::OpenApplicationWindow(profile, NULL, url, false);
+ Browser::OpenApplicationWindow(profile, url);
return true;
}
}
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index 6f48333..7112dad 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -125,16 +125,20 @@ void AppLauncherHandler::HandleLaunchApp(const Value* value) {
return;
}
+ // Override the default launch container.
Extension* extension =
extensions_service_->GetExtensionById(extension_id, false);
DCHECK(extension);
+ Extension::LaunchContainer container;
if (launch_container == "tab")
- Browser::OpenApplicationTab(profile, extension);
+ container = Extension::LAUNCH_TAB;
else if (launch_container == "panel")
- Browser::OpenApplicationWindow(profile, extension, GURL(), true);
+ container = Extension::LAUNCH_PANEL;
else if (launch_container == "window")
- Browser::OpenApplicationWindow(profile, extension, GURL(), false);
+ container = Extension::LAUNCH_WINDOW;
else
NOTREACHED() << "Unexpected launch container: " << launch_container << ".";
+
+ Browser::OpenApplication(profile, extension, container);
}