summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--chrome/common/extensions/extension.cc18
-rw-r--r--chrome/common/extensions/extension.h6
-rw-r--r--chrome/common/extensions/extension_constants.cc3
-rw-r--r--chrome/common/extensions/extension_constants.h2
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc9
-rwxr-xr-xchrome/test/data/extensions/manifest_tests/launch_fullscreen.json9
-rwxr-xr-xchrome/test/data/extensions/manifest_tests/launch_fullscreen_invalid.json9
11 files changed, 124 insertions, 36 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);
}
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 80a489b..8dc62d2 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -696,11 +696,26 @@ bool Extension::LoadLaunchContainer(const DictionaryValue* manifest,
return true;
}
+bool Extension::LoadLaunchFullscreen(const DictionaryValue* manifest,
+ std::string* error) {
+ Value* temp = NULL;
+ if (!manifest->Get(keys::kLaunchFullscreen, &temp))
+ return true;
+
+ if (!temp->GetAsBoolean(&launch_fullscreen_)) {
+ *error = errors::kInvalidLaunchFullscreen;
+ return false;
+ }
+
+ return true;
+}
+
Extension::Extension(const FilePath& path)
: converted_from_user_script_(false),
is_theme_(false),
web_content_enabled_(false),
launch_container_(LAUNCH_TAB),
+ launch_fullscreen_(false),
background_page_ready_(false),
being_upgraded_(false) {
DCHECK(path.IsAbsolute());
@@ -1433,7 +1448,8 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
!LoadWebOrigin(manifest_value_.get(), error) ||
!LoadWebPaths(manifest_value_.get(), error) ||
!LoadLaunchURL(manifest_value_.get(), error) ||
- !LoadLaunchContainer(manifest_value_.get(), error)) {
+ !LoadLaunchContainer(manifest_value_.get(), error) ||
+ !LoadLaunchFullscreen(manifest_value_.get(), error)) {
return false;
}
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index f8dcd9b..2cf2f85 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -321,6 +321,7 @@ class Extension {
const std::string& launch_local_path() const { return launch_local_path_; }
const std::string& launch_web_url() const { return launch_web_url_; }
LaunchContainer launch_container() const { return launch_container_; }
+ bool launch_fullscreen() const { return launch_fullscreen_; }
// Gets the fully resolved absolute launch URL.
GURL GetFullLaunchURL() const;
@@ -375,6 +376,8 @@ class Extension {
bool LoadWebOrigin(const DictionaryValue* manifest, std::string* error);
bool LoadWebPaths(const DictionaryValue* manifest, std::string* error);
bool LoadLaunchContainer(const DictionaryValue* manifest, std::string* error);
+ bool LoadLaunchFullscreen(const DictionaryValue* manifest,
+ std::string* error);
bool LoadLaunchURL(const DictionaryValue* manifest, std::string* error);
// Helper method to load an ExtensionAction from the page_action or
@@ -503,6 +506,9 @@ class Extension {
// The type of container to launch into.
LaunchContainer launch_container_;
+ // Launch full screen by default.
+ bool launch_fullscreen_;
+
// Cached images for this extension. This maps from the relative_path of the
// resource to the cached image.
ImageCache image_cache_;
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 0afb1255..1db05cb 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -20,6 +20,7 @@ const wchar_t* kIcons = L"icons";
const wchar_t* kJs = L"js";
const wchar_t* kLaunch = L"launch";
const wchar_t* kLaunchContainer = L"launch.container";
+const wchar_t* kLaunchFullscreen = L"launch.fullscreen";
const wchar_t* kLaunchLocalPath = L"launch.local_path";
const wchar_t* kLaunchWebURL = L"launch.web_url";
const wchar_t* kMatches = L"matches";
@@ -112,6 +113,8 @@ const char* kInvalidJsList =
"Required value 'content_scripts[*].js' is invalid.";
const char* kInvalidLaunchContainer =
"Invalid value for 'launch.container'.";
+const char* kInvalidLaunchFullscreen =
+ "Invalid value for 'launch.fullscreen'.";
const char* kInvalidLaunchLocalPath =
"Invalid value for 'launch.local_path'.";
const char* kInvalidLaunchWebURL =
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index 7fb1113..1b1e798 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -23,6 +23,7 @@ namespace extension_manifest_keys {
extern const wchar_t* kIncludeGlobs;
extern const wchar_t* kLaunch;
extern const wchar_t* kLaunchContainer;
+ extern const wchar_t* kLaunchFullscreen;
extern const wchar_t* kLaunchLocalPath;
extern const wchar_t* kLaunchWebURL;
extern const wchar_t* kJs;
@@ -98,6 +99,7 @@ namespace extension_manifest_errors {
extern const char* kInvalidJsList;
extern const char* kInvalidKey;
extern const char* kInvalidLaunchContainer;
+ extern const char* kInvalidLaunchFullscreen;
extern const char* kInvalidLaunchLocalPath;
extern const char* kInvalidLaunchWebURL;
extern const char* kInvalidManifest;
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index e5c0777..66f8991 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -61,7 +61,8 @@ class ManifestTest : public testing::Test {
EXPECT_FALSE(extension.get()) <<
"Expected failure loading extension '" << name <<
"', but didn't get one.";
- EXPECT_TRUE(MatchPatternASCII(error, expected_error));
+ EXPECT_TRUE(MatchPatternASCII(error, expected_error)) << name <<
+ " expected '" << expected_error << "' but got '" << error << "'";
}
bool enable_apps_;
@@ -81,6 +82,7 @@ TEST_F(ManifestTest, ValidApp) {
EXPECT_EQ("mail/", extension->web_extent().paths()[0]);
EXPECT_EQ("foobar/", extension->web_extent().paths()[1]);
EXPECT_EQ(Extension::LAUNCH_WINDOW, extension->launch_container());
+ EXPECT_EQ(false, extension->launch_fullscreen());
EXPECT_EQ("mail/", extension->launch_web_url());
}
@@ -130,12 +132,17 @@ TEST_F(ManifestTest, AppLaunchContainer) {
extension.reset(LoadAndExpectSuccess("launch_default.json"));
EXPECT_EQ(Extension::LAUNCH_TAB, extension->launch_container());
+ extension.reset(LoadAndExpectSuccess("launch_fullscreen.json"));
+ EXPECT_EQ(true, extension->launch_fullscreen());
+
LoadAndExpectError("launch_container_invalid_type.json",
errors::kInvalidLaunchContainer);
LoadAndExpectError("launch_container_invalid_value.json",
errors::kInvalidLaunchContainer);
LoadAndExpectError("launch_container_without_launch_url.json",
errors::kLaunchContainerWithoutURL);
+ LoadAndExpectError("launch_fullscreen_invalid.json",
+ errors::kInvalidLaunchFullscreen);
}
TEST_F(ManifestTest, AppLaunchURL) {
diff --git a/chrome/test/data/extensions/manifest_tests/launch_fullscreen.json b/chrome/test/data/extensions/manifest_tests/launch_fullscreen.json
new file mode 100755
index 0000000..f2bb685
--- /dev/null
+++ b/chrome/test/data/extensions/manifest_tests/launch_fullscreen.json
@@ -0,0 +1,9 @@
+{
+ "name": "test",
+ "version": "1",
+ "launch": {
+ "container": "window",
+ "fullscreen": true,
+ "local_path": "bar.html"
+ }
+}
diff --git a/chrome/test/data/extensions/manifest_tests/launch_fullscreen_invalid.json b/chrome/test/data/extensions/manifest_tests/launch_fullscreen_invalid.json
new file mode 100755
index 0000000..01100ff
--- /dev/null
+++ b/chrome/test/data/extensions/manifest_tests/launch_fullscreen_invalid.json
@@ -0,0 +1,9 @@
+{
+ "name": "test",
+ "version": "1",
+ "launch": {
+ "container": "window",
+ "fullscreen": "true",
+ "local_path": "bar.html"
+ }
+}