summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 18:45:59 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 18:45:59 +0000
commit970078f631430843b84c72352195c02580908636 (patch)
treed7fc2340236b1f4ab87335358c4976c01745cd37 /chrome/common/extensions
parentd3cee19d4b6e16dd4ee1d42d8d4f888d944fe587 (diff)
downloadchromium_src-970078f631430843b84c72352195c02580908636.zip
chromium_src-970078f631430843b84c72352195c02580908636.tar.gz
chromium_src-970078f631430843b84c72352195c02580908636.tar.bz2
Added app.launch.width and app.launch.height keys to app manifest.
This allows panels and window container types to specify initial dimensions when launching. BUG=46501 TEST=add app.launch.width/height to an app manifest with container==panel/window Review URL: http://codereview.chromium.org/2814016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/extension.cc30
-rw-r--r--chrome/common/extensions/extension.h7
-rw-r--r--chrome/common/extensions/extension_constants.cc10
-rw-r--r--chrome/common/extensions/extension_constants.h6
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc14
5 files changed, 67 insertions, 0 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index d2b3d3b..7118853 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -679,6 +679,34 @@ bool Extension::LoadLaunchContainer(const DictionaryValue* manifest,
return false;
}
+ // Validate the container width if present.
+ if (manifest->Get(keys::kLaunchWidth, &temp)) {
+ if (launch_container_ != LAUNCH_PANEL &&
+ launch_container_ != LAUNCH_WINDOW) {
+ *error = errors::kInvalidLaunchWidthContainer;
+ return false;
+ }
+ if (!temp->GetAsInteger(&launch_width_) || launch_width_ < 0) {
+ launch_width_ = 0;
+ *error = errors::kInvalidLaunchWidth;
+ return false;
+ }
+ }
+
+ // Validate container height if present.
+ if (manifest->Get(keys::kLaunchHeight, &temp)) {
+ if (launch_container_ != LAUNCH_PANEL &&
+ launch_container_ != LAUNCH_WINDOW) {
+ *error = errors::kInvalidLaunchHeightContainer;
+ return false;
+ }
+ if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) {
+ launch_height_ = 0;
+ *error = errors::kInvalidLaunchHeight;
+ return false;
+ }
+ }
+
return true;
}
@@ -702,6 +730,8 @@ Extension::Extension(const FilePath& path)
is_app_(false),
launch_container_(LAUNCH_TAB),
launch_fullscreen_(false),
+ launch_width_(0),
+ launch_height_(0),
background_page_ready_(false),
being_upgraded_(false) {
DCHECK(path.IsAbsolute());
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 107d014..a6a5e78 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -335,6 +335,8 @@ class Extension {
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_; }
+ int launch_width() const { return launch_width_; }
+ int launch_height() const { return launch_height_; }
// Gets the fully resolved absolute launch URL.
GURL GetFullLaunchURL() const;
@@ -520,6 +522,11 @@ class Extension {
// Launch full screen by default.
bool launch_fullscreen_;
+ // The default size of the container when launching. Only respected for
+ // containers like panels and windows.
+ int launch_width_;
+ int launch_height_;
+
// 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 be58611..b854dfb 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -22,8 +22,10 @@ const wchar_t* kJs = L"js";
const wchar_t* kLaunch = L"app.launch";
const wchar_t* kLaunchContainer = L"app.launch.container";
const wchar_t* kLaunchFullscreen = L"app.launch.fullscreen";
+const wchar_t* kLaunchHeight = L"app.launch.height";
const wchar_t* kLaunchLocalPath = L"app.launch.local_path";
const wchar_t* kLaunchWebURL = L"app.launch.web_url";
+const wchar_t* kLaunchWidth = L"app.launch.width";
const wchar_t* kMatches = L"matches";
const wchar_t* kMinimumChromeVersion = L"minimum_chrome_version";
const wchar_t* kIncludeGlobs = L"include_globs";
@@ -116,10 +118,18 @@ const char* kInvalidLaunchContainer =
"Invalid value for 'app.launch.container'.";
const char* kInvalidLaunchFullscreen =
"Invalid value for 'app.launch.fullscreen'.";
+const char* kInvalidLaunchHeight =
+ "Invalid value for 'app.launch.height'.";
+const char* kInvalidLaunchHeightContainer =
+ "Invalid container type for 'app.launch.height'.";
const char* kInvalidLaunchLocalPath =
"Invalid value for 'app.launch.local_path'.";
const char* kInvalidLaunchWebURL =
"Invalid value for 'app.launch.web_url'.";
+const char* kInvalidLaunchWidth =
+ "Invalid value for 'app.launch.width'.";
+const char* kInvalidLaunchWidthContainer =
+ "Invalid container type for 'app.launch.width'.";
const char* kInvalidKey =
"Value 'key' is missing or invalid.";
const char* kInvalidManifest =
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index c515c72..510ccd7 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -25,7 +25,9 @@ namespace extension_manifest_keys {
extern const wchar_t* kLaunch;
extern const wchar_t* kLaunchContainer;
extern const wchar_t* kLaunchFullscreen;
+ extern const wchar_t* kLaunchHeight;
extern const wchar_t* kLaunchLocalPath;
+ extern const wchar_t* kLaunchWidth;
extern const wchar_t* kLaunchWebURL;
extern const wchar_t* kJs;
extern const wchar_t* kMatches;
@@ -101,8 +103,12 @@ namespace extension_manifest_errors {
extern const char* kInvalidKey;
extern const char* kInvalidLaunchContainer;
extern const char* kInvalidLaunchFullscreen;
+ extern const char* kInvalidLaunchHeight;
+ extern const char* kInvalidLaunchHeightContainer;
extern const char* kInvalidLaunchLocalPath;
extern const char* kInvalidLaunchWebURL;
+ extern const char* kInvalidLaunchWidth;
+ extern const char* kInvalidLaunchWidthContainer;
extern const char* kInvalidManifest;
extern const char* kInvalidMatchCount;
extern const char* kInvalidMatch;
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index cc0047e..21f38537 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -136,6 +136,12 @@ TEST_F(ManifestTest, AppLaunchContainer) {
extension.reset(LoadAndExpectSuccess("launch_fullscreen.json"));
EXPECT_EQ(true, extension->launch_fullscreen());
+ extension.reset(LoadAndExpectSuccess("launch_width.json"));
+ EXPECT_EQ(640, extension->launch_width());
+
+ extension.reset(LoadAndExpectSuccess("launch_height.json"));
+ EXPECT_EQ(480, extension->launch_height());
+
LoadAndExpectError("launch_container_invalid_type.json",
errors::kInvalidLaunchContainer);
LoadAndExpectError("launch_container_invalid_value.json",
@@ -144,6 +150,14 @@ TEST_F(ManifestTest, AppLaunchContainer) {
errors::kLaunchURLRequired);
LoadAndExpectError("launch_fullscreen_invalid.json",
errors::kInvalidLaunchFullscreen);
+ LoadAndExpectError("launch_width_invalid.json",
+ errors::kInvalidLaunchWidthContainer);
+ LoadAndExpectError("launch_width_negative.json",
+ errors::kInvalidLaunchWidth);
+ LoadAndExpectError("launch_height_invalid.json",
+ errors::kInvalidLaunchHeightContainer);
+ LoadAndExpectError("launch_height_negative.json",
+ errors::kInvalidLaunchHeight);
}
TEST_F(ManifestTest, AppLaunchURL) {