Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc

Issue 25449002: Add chrome.app.window.[get|set][Min|Max][Width|Height] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
diff --git a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
index ad3b81642622e3c67554a7bd2440dc1c46ead90c..ea09a83ab1e831a6e06820cadca17d9a31cc6714 100644
--- a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
+++ b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
@@ -16,17 +16,22 @@
#include "extensions/common/switches.h"
#include "third_party/skia/include/core/SkRegion.h"
-namespace SetBounds = extensions::api::app_current_window_internal::SetBounds;
-namespace SetIcon = extensions::api::app_current_window_internal::SetIcon;
-namespace SetInputRegion =
- extensions::api::app_current_window_internal::SetInputRegion;
-namespace SetAlwaysOnTop =
- extensions::api::app_current_window_internal::SetAlwaysOnTop;
+namespace app_current_window_internal =
+ extensions::api::app_current_window_internal;
+
+namespace SetBounds = app_current_window_internal::SetBounds;
+namespace SetMinWidth = app_current_window_internal::SetMinWidth;
+namespace SetMinHeight = app_current_window_internal::SetMinHeight;
+namespace SetMaxWidth = app_current_window_internal::SetMaxWidth;
+namespace SetMaxHeight = app_current_window_internal::SetMaxHeight;
+namespace SetIcon = app_current_window_internal::SetIcon;
+namespace SetInputRegion = app_current_window_internal::SetInputRegion;
+namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop;
using apps::ShellWindow;
-using extensions::api::app_current_window_internal::Bounds;
-using extensions::api::app_current_window_internal::Region;
-using extensions::api::app_current_window_internal::RegionRect;
+using app_current_window_internal::Bounds;
+using app_current_window_internal::Region;
+using app_current_window_internal::RegionRect;
namespace extensions {
@@ -39,6 +44,8 @@ const char kNoAssociatedShellWindow[] =
const char kDevChannelOnly[] =
"This function is currently only available in the Dev channel.";
+const int kUnboundedSize = apps::ShellWindow::SizeConstraints::kUnboundedSize;
+
} // namespace
bool AppCurrentWindowInternalExtensionFunction::RunImpl() {
@@ -132,6 +139,50 @@ bool AppCurrentWindowInternalSetBoundsFunction::RunWithWindow(
return true;
}
+bool AppCurrentWindowInternalSetMinWidthFunction::RunWithWindow(
+ ShellWindow* window) {
+ scoped_ptr<SetMinWidth::Params> params(SetMinWidth::Params::Create(*args_));
+ CHECK(params.get());
+ gfx::Size min_size = window->size_constraints().GetMinimumSize();
+ min_size.set_width(params->min_width.get() ?
+ *(params->min_width) : kUnboundedSize);
+ window->SetMinimumSize(min_size);
+ return true;
+}
+
+bool AppCurrentWindowInternalSetMinHeightFunction::RunWithWindow(
+ ShellWindow* window) {
+ scoped_ptr<SetMinHeight::Params> params(SetMinHeight::Params::Create(*args_));
+ CHECK(params.get());
+ gfx::Size min_size = window->size_constraints().GetMinimumSize();
+ min_size.set_height(params->min_height.get() ?
+ *(params->min_height) : kUnboundedSize);
+ window->SetMinimumSize(min_size);
+ return true;
+}
+
+bool AppCurrentWindowInternalSetMaxWidthFunction::RunWithWindow(
+ ShellWindow* window) {
+ scoped_ptr<SetMaxWidth::Params> params(SetMaxWidth::Params::Create(*args_));
+ CHECK(params.get());
+ gfx::Size max_size = window->size_constraints().GetMaximumSize();
+ max_size.set_width(params->max_width.get() ?
+ *(params->max_width) : kUnboundedSize);
+ window->SetMaximumSize(max_size);
+ return true;
+}
+
+bool AppCurrentWindowInternalSetMaxHeightFunction::RunWithWindow(
+ ShellWindow* window) {
+ scoped_ptr<SetMaxHeight::Params> params(SetMaxHeight::Params::Create(*args_));
+ CHECK(params.get());
+ gfx::Size max_size = window->size_constraints().GetMaximumSize();
+ max_size.set_height(params->max_height.get() ?
+ *(params->max_height) : kUnboundedSize);
+ window->SetMaximumSize(max_size);
+ return true;
+}
+
bool AppCurrentWindowInternalSetIconFunction::RunWithWindow(
ShellWindow* window) {
if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV &&

Powered by Google App Engine
This is Rietveld 408576698