diff options
| author | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-01 07:23:20 +0000 |
|---|---|---|
| committer | jeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-01 07:23:20 +0000 |
| commit | f8c3aead7e7812724f1c21bb697464aca0edd89b (patch) | |
| tree | 3ff4e4f79bffde7294991cb71c28ba7d3ef21c8e /chrome | |
| parent | 6bba4d94f16790cdd0a0ef66b8d5d5c87ae51c2b (diff) | |
| download | chromium_src-f8c3aead7e7812724f1c21bb697464aca0edd89b.zip chromium_src-f8c3aead7e7812724f1c21bb697464aca0edd89b.tar.gz chromium_src-f8c3aead7e7812724f1c21bb697464aca0edd89b.tar.bz2 | |
Allow platform apps to specify a maximum size for the shell container.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/9452008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124380 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
7 files changed, 75 insertions, 6 deletions
diff --git a/chrome/browser/ui/views/extensions/shell_window_views.cc b/chrome/browser/ui/views/extensions/shell_window_views.cc index a53733f..524a37e 100644 --- a/chrome/browser/ui/views/extensions/shell_window_views.cc +++ b/chrome/browser/ui/views/extensions/shell_window_views.cc @@ -40,13 +40,16 @@ class ShellWindowFrameView : public views::NonClientFrameView { virtual void ResetWindowControls() OVERRIDE {} virtual void UpdateWindowIcon() OVERRIDE {} virtual gfx::Size GetMinimumSize() OVERRIDE; + virtual gfx::Size GetMaximumSize() OVERRIDE; void set_min_size(gfx::Size size) { min_size_ = size; } + void set_max_size(gfx::Size size) { max_size_ = size; } private: DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView); gfx::Size min_size_; + gfx::Size max_size_; }; ShellWindowFrameView::ShellWindowFrameView(): min_size_() { @@ -100,6 +103,9 @@ gfx::Size ShellWindowFrameView::GetMinimumSize() { return min_size_; } +gfx::Size ShellWindowFrameView::GetMaximumSize() { + return max_size_; +} ShellWindowViews::ShellWindowViews(ExtensionHost* host) : ShellWindow(host) { @@ -150,9 +156,12 @@ views::View* ShellWindowViews::GetContentsView() { views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView() { ShellWindowFrameView* frame_view = new ShellWindowFrameView(); - gfx::Size size(host_->extension()->launch_min_width(), - host_->extension()->launch_min_height()); - frame_view->set_min_size(size); + gfx::Size min_size(host_->extension()->launch_min_width(), + host_->extension()->launch_min_height()); + gfx::Size max_size(host_->extension()->launch_max_width(), + host_->extension()->launch_max_height()); + frame_view->set_min_size(min_size); + frame_view->set_max_size(max_size); return frame_view; } diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 04eb7df..dd9fb92 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -1250,6 +1250,18 @@ bool Extension::LoadLaunchContainer(string16* error) { can_specify_size_range, error)) return false; + if (!ReadLaunchDimension(manifest_, + keys::kLaunchMaxWidth, + &launch_max_width_, + can_specify_size_range, + error)) + return false; + if (!ReadLaunchDimension(manifest_, + keys::kLaunchMaxHeight, + &launch_max_height_, + can_specify_size_range, + error)) + return false; if (launch_container() == extension_misc::LAUNCH_SHELL) { if (!manifest_->Get(keys::kLaunchWidth, &temp)) { @@ -1264,6 +1276,18 @@ bool Extension::LoadLaunchContainer(string16* error) { keys::kLaunchHeight); return false; } + if (launch_max_width_ > 0 && launch_max_width_ < launch_min_width_) { + *error = ExtensionErrorUtils::FormatErrorMessageUTF16( + errors::kInvalidLaunchValue, + keys::kLaunchMaxWidth); + return false; + } + if (launch_max_height_ > 0 && launch_max_height_ < launch_min_height_) { + *error = ExtensionErrorUtils::FormatErrorMessageUTF16( + errors::kInvalidLaunchValue, + keys::kLaunchMaxHeight); + return false; + } } return true; @@ -1511,6 +1535,8 @@ Extension::Extension(const FilePath& path, launch_height_(0), launch_min_width_(0), launch_min_height_(0), + launch_max_width_(0), + launch_max_height_(0), wants_file_access_(false), creation_flags_(0) { DCHECK(path.empty() || path.IsAbsolute()); diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index fd224f2..0f789eb 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -611,13 +611,21 @@ class Extension : public base::RefCountedThreadSafe<Extension> { return launch_container_; } int launch_width() const { - return std::max(launch_min_width_, launch_width_); + return std::max(launch_min_width_, + launch_max_width_ ? + std::min(launch_max_width_, launch_width_) : + launch_width_); } int launch_height() const { - return std::max(launch_min_height_, launch_height_); + return std::max(launch_min_height_, + launch_max_height_ ? + std::min(launch_max_height_, launch_height_) : + launch_height_); } int launch_min_width() const { return launch_min_width_; } int launch_min_height() const { return launch_min_height_; } + int launch_max_width() const { return launch_max_width_; } + int launch_max_height() const { return launch_max_height_; } // Theme-related. bool is_theme() const; @@ -914,9 +922,12 @@ class Extension : public base::RefCountedThreadSafe<Extension> { int launch_width_; int launch_height_; - // The minimum size of the container. Only respected for the shell container. + // The minimum and maximum size of the container. Only respected for the + // shell container. int launch_min_width_; int launch_min_height_; + int launch_max_width_; + int launch_max_height_; // The Omnibox keyword for this extension, or empty if there is none. std::string omnibox_keyword_; diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index 38ece13..c50c2e5 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -58,6 +58,8 @@ const char kLaunchContainer[] = "app.launch.container"; const char kLaunchHeight[] = "app.launch.height"; const char kLaunchLocalPath[] = "app.launch.local_path"; const char kLaunchWebURL[] = "app.launch.web_url"; +const char kLaunchMaxHeight[] = "app.launch.max_height"; +const char kLaunchMaxWidth[] = "app.launch.max_width"; const char kLaunchMinHeight[] = "app.launch.min_height"; const char kLaunchMinWidth[] = "app.launch.min_width"; const char kLaunchWidth[] = "app.launch.width"; diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index 0b14672..ca87caa 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -59,6 +59,8 @@ namespace extension_manifest_keys { extern const char kLaunchContainer[]; extern const char kLaunchHeight[]; extern const char kLaunchLocalPath[]; + extern const char kLaunchMaxHeight[]; + extern const char kLaunchMaxWidth[]; extern const char kLaunchMinHeight[]; extern const char kLaunchMinWidth[]; extern const char kLaunchWebURL[]; diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index bf6cc87..e1d108f 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -458,6 +458,10 @@ TEST_F(ExtensionManifestTest, AppLaunchContainer) { ExtensionErrorUtils::FormatErrorMessage( errors::kInvalidLaunchValue, keys::kLaunchWidth)); + LoadAndExpectError("launch_container_invalid_size_constraints.json", + ExtensionErrorUtils::FormatErrorMessage( + errors::kInvalidLaunchValue, + keys::kLaunchMaxWidth)); } TEST_F(ExtensionManifestTest, PlatformAppLaunchContainer) { diff --git a/chrome/test/data/extensions/manifest_tests/launch_container_invalid_size_constraints.json b/chrome/test/data/extensions/manifest_tests/launch_container_invalid_size_constraints.json new file mode 100644 index 0000000..f310552 --- /dev/null +++ b/chrome/test/data/extensions/manifest_tests/launch_container_invalid_size_constraints.json @@ -0,0 +1,15 @@ +{ + "name": "test", + "version": "1", + "platform_app": true, + "app": { + "launch": { + "container": "shell", + "local_path": "hot.html", + "width": 250, + "height": 250, + "min_width": 100, + "max_width": 50 + } + } +} |
