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

Side by Side Diff: apps/shell_window.h

Issue 26751003: Factor out [min|max]_size into ShellWindow::SizeConstraints (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | apps/shell_window.cc » ('j') | apps/shell_window.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef APPS_SHELL_WINDOW_H_ 5 #ifndef APPS_SHELL_WINDOW_H_
6 #define APPS_SHELL_WINDOW_H_ 6 #define APPS_SHELL_WINDOW_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/extensions/extension_icon_image.h" 10 #include "chrome/browser/extensions/extension_icon_image.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). 83 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only).
84 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate 84 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate
85 // with v1 apps. 85 // with v1 apps.
86 }; 86 };
87 87
88 enum Frame { 88 enum Frame {
89 FRAME_CHROME, // Chrome-style window frame. 89 FRAME_CHROME, // Chrome-style window frame.
90 FRAME_NONE, // Frameless window. 90 FRAME_NONE, // Frameless window.
91 }; 91 };
92 92
93 class SizeConstraints {
94 public:
95 // The value SizeConstraints uses to represent an unbounded width or height.
96 static const int kUnboundedSize = 0;
97
98 SizeConstraints();
99 SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size);
100 ~SizeConstraints();
101
102 // Returns the bounds with its size clamped to the min/max size.
103 gfx::Size ClampSize(gfx::Size size) const;
104
105 // When gfx::Size is used as a min/max size, a zero represents an unbounded
106 // component. This method checks whether either component is specified.
107 // Note we can't use gfx::Size::IsEmpty as it returns true if either width
108 // or height is zero.
109 bool HasMinimumSize() const;
110 bool HasMaximumSize() const;
111
112 // This returns true if all components are specified, and min and max are
113 // equal.
114 bool HasFixedSize() const;
115
116 gfx::Size GetMaximumSize() const;
117 gfx::Size GetMinimumSize() const;
118
119 private:
120 gfx::Size minimum_size_;
121 gfx::Size maximum_size_;
122 };
123
93 struct CreateParams { 124 struct CreateParams {
94 CreateParams(); 125 CreateParams();
95 ~CreateParams(); 126 ~CreateParams();
96 127
97 WindowType window_type; 128 WindowType window_type;
98 Frame frame; 129 Frame frame;
99 bool transparent_background; // Only supported on ash. 130 bool transparent_background; // Only supported on ash.
100 131
101 // Specify the initial content bounds of the window (excluding any window 132 // Specify the initial content bounds of the window (excluding any window
102 // decorations). INT_MIN designates 'unspecified' for the position 133 // decorations). INT_MIN designates 'unspecified' for the position
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 347
317 // Helper method to adjust the cached bounds so that we can make sure it can 348 // Helper method to adjust the cached bounds so that we can make sure it can
318 // be visible on the screen. See http://crbug.com/145752 . 349 // be visible on the screen. See http://crbug.com/145752 .
319 void AdjustBoundsToBeVisibleOnScreen( 350 void AdjustBoundsToBeVisibleOnScreen(
320 const gfx::Rect& cached_bounds, 351 const gfx::Rect& cached_bounds,
321 const gfx::Rect& cached_screen_bounds, 352 const gfx::Rect& cached_screen_bounds,
322 const gfx::Rect& current_screen_bounds, 353 const gfx::Rect& current_screen_bounds,
323 const gfx::Size& minimum_size, 354 const gfx::Size& minimum_size,
324 gfx::Rect* bounds) const; 355 gfx::Rect* bounds) const;
325 356
357 // Loads the appropriate default or cached window bounds and constraints them
tapted 2013/10/15 03:33:04 nit: constraints -> constrains (or clamps)
jackhou1 2013/10/15 05:07:13 Done.
358 // based on screen size and minimum/maximum size. Returns a new CreateParams
359 // that should be used to create the window.
360 CreateParams LoadDefaultsAndConstrain(CreateParams params) const;
361
326 // Load the app's image, firing a load state change when loaded. 362 // Load the app's image, firing a load state change when loaded.
327 void UpdateExtensionAppIcon(); 363 void UpdateExtensionAppIcon();
328 364
329 // extensions::ExtensionKeybindingRegistry::Delegate implementation. 365 // extensions::ExtensionKeybindingRegistry::Delegate implementation.
330 virtual extensions::ActiveTabPermissionGranter* 366 virtual extensions::ActiveTabPermissionGranter*
331 GetActiveTabPermissionGranter() OVERRIDE; 367 GetActiveTabPermissionGranter() OVERRIDE;
332 368
333 // web_modal::WebContentsModalDialogManagerDelegate implementation. 369 // web_modal::WebContentsModalDialogManagerDelegate implementation.
334 virtual web_modal::WebContentsModalDialogHost* 370 virtual web_modal::WebContentsModalDialogHost*
335 GetWebContentsModalDialogHost() OVERRIDE; 371 GetWebContentsModalDialogHost() OVERRIDE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 417
382 // The window content is visible. 418 // The window content is visible.
383 bool is_content_visible_; 419 bool is_content_visible_;
384 420
385 DISALLOW_COPY_AND_ASSIGN(ShellWindow); 421 DISALLOW_COPY_AND_ASSIGN(ShellWindow);
386 }; 422 };
387 423
388 } // namespace apps 424 } // namespace apps
389 425
390 #endif // APPS_SHELL_WINDOW_H_ 426 #endif // APPS_SHELL_WINDOW_H_
OLDNEW
« no previous file with comments | « no previous file | apps/shell_window.cc » ('j') | apps/shell_window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698