summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 07:31:34 +0000
committerjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 07:31:34 +0000
commit5000cad89977a86c49961c2262cae416313c8b91 (patch)
tree67cf30311fdf13c1b261fe786f5726eb619e88d3 /apps
parent0f698436b9458617a998d84a0b646fcd2c2f8e90 (diff)
downloadchromium_src-5000cad89977a86c49961c2262cae416313c8b91.zip
chromium_src-5000cad89977a86c49961c2262cae416313c8b91.tar.gz
chromium_src-5000cad89977a86c49961c2262cae416313c8b91.tar.bz2
Add Set[Minimum|Maximum]Size to ShellWindow.
These will eventually be used by the corresponding chrome.app.window API methods. This CL also moves min/max size from NativeAppWindow into ShellWindow. NativeAppWindow implementations call ShellWindow::size_constraints to get the current min/max size. BUG=305477 Review URL: https://codereview.chromium.org/26740003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/shell_window.cc31
-rw-r--r--apps/shell_window.h18
-rw-r--r--apps/ui/native_app_window.h4
3 files changed, 53 insertions, 0 deletions
diff --git a/apps/shell_window.cc b/apps/shell_window.cc
index 04aeed2..ce2efa0 100644
--- a/apps/shell_window.cc
+++ b/apps/shell_window.cc
@@ -107,6 +107,14 @@ gfx::Size ShellWindow::SizeConstraints::GetMaximumSize() const {
std::max(maximum_size_.height(), minimum_size_.height()));
}
+void ShellWindow::SizeConstraints::set_minimum_size(const gfx::Size& min_size) {
+ minimum_size_ = min_size;
+}
+
+void ShellWindow::SizeConstraints::set_maximum_size(const gfx::Size& max_size) {
+ maximum_size_ = max_size;
+}
+
ShellWindow::CreateParams::CreateParams()
: window_type(ShellWindow::WINDOW_TYPE_DEFAULT),
frame(ShellWindow::FRAME_CHROME),
@@ -156,6 +164,8 @@ void ShellWindow::Init(const GURL& url,
CreateParams new_params = LoadDefaultsAndConstrain(params);
window_type_ = new_params.window_type;
window_key_ = new_params.window_key;
+ size_constraints_ = SizeConstraints(new_params.minimum_size,
+ new_params.maximum_size);
native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params));
if (!new_params.hidden) {
@@ -419,6 +429,16 @@ void ShellWindow::Restore() {
}
}
+void ShellWindow::SetMinimumSize(const gfx::Size& min_size) {
+ size_constraints_.set_minimum_size(min_size);
+ OnSizeConstraintsChanged();
+}
+
+void ShellWindow::SetMaximumSize(const gfx::Size& max_size) {
+ size_constraints_.set_maximum_size(max_size);
+ OnSizeConstraintsChanged();
+}
+
//------------------------------------------------------------------------------
// Private methods
@@ -466,6 +486,17 @@ void ShellWindow::UpdateExtensionAppIcon() {
app_icon_image_->image_skia().GetRepresentation(1.0f);
}
+void ShellWindow::OnSizeConstraintsChanged() {
+ native_app_window_->UpdateWindowMinMaxSize();
+ gfx::Rect bounds = GetClientBounds();
+ gfx::Size constrained_size = size_constraints_.ClampSize(bounds.size());
+ if (bounds.size() != constrained_size) {
+ bounds.set_size(constrained_size);
+ native_app_window_->SetBounds(bounds);
+ }
+ OnNativeWindowChanged();
+}
+
void ShellWindow::CloseContents(WebContents* contents) {
native_app_window_->Close();
}
diff --git a/apps/shell_window.h b/apps/shell_window.h
index f126429..efc6915 100644
--- a/apps/shell_window.h
+++ b/apps/shell_window.h
@@ -117,6 +117,9 @@ class ShellWindow : public content::NotificationObserver,
gfx::Size GetMaximumSize() const;
gfx::Size GetMinimumSize() const;
+ void set_minimum_size(const gfx::Size& min_size);
+ void set_maximum_size(const gfx::Size& max_size);
+
private:
gfx::Size minimum_size_;
gfx::Size maximum_size_;
@@ -283,10 +286,19 @@ class ShellWindow : public content::NotificationObserver,
void Minimize();
void Restore();
+ // Set the minimum and maximum size that this window is allowed to be.
+ void SetMinimumSize(const gfx::Size& min_size);
+ void SetMaximumSize(const gfx::Size& max_size);
+
ShellWindowContents* shell_window_contents_for_test() {
return shell_window_contents_.get();
}
+ // Get the size constraints.
+ const SizeConstraints& size_constraints() const {
+ return size_constraints_;
+ }
+
protected:
virtual ~ShellWindow();
@@ -367,6 +379,9 @@ class ShellWindow : public content::NotificationObserver,
// Load the app's image, firing a load state change when loaded.
void UpdateExtensionAppIcon();
+ // Called when size_constraints is changed.
+ void OnSizeConstraintsChanged();
+
// extensions::ExtensionKeybindingRegistry::Delegate implementation.
virtual extensions::ActiveTabPermissionGranter*
GetActiveTabPermissionGranter() OVERRIDE;
@@ -423,6 +438,9 @@ class ShellWindow : public content::NotificationObserver,
// The window content is visible.
bool is_content_visible_;
+ // Size constraints on the window.
+ SizeConstraints size_constraints_;
+
DISALLOW_COPY_AND_ASSIGN(ShellWindow);
};
diff --git a/apps/ui/native_app_window.h b/apps/ui/native_app_window.h
index c20e3b1..37fbfbe 100644
--- a/apps/ui/native_app_window.h
+++ b/apps/ui/native_app_window.h
@@ -64,6 +64,10 @@ class NativeAppWindow : public ui::BaseWindow,
virtual void ShowWithApp() = 0;
virtual void HideWithApp() = 0;
+ // Updates the minimum and maximum size of the native window with the current
+ // size constraints.
+ virtual void UpdateWindowMinMaxSize() = 0;
+
virtual ~NativeAppWindow() {}
};