Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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::Rect ClampBounds(const gfx::Rect& bounds) 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 minimum_size() const; | |
| 117 gfx::Size maximum_size() 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 
| 326 // Load the app's image, firing a load state change when loaded. | 357 // Load the app's image, firing a load state change when loaded. | 
| 327 void UpdateExtensionAppIcon(); | 358 void UpdateExtensionAppIcon(); | 
| 328 | 359 | 
| 360 // Loads the appropriate default or cached window bounds and constraints them | |
| 361 // based on screen size and minimum/maximum size. Returns a new CreateParams | |
| 362 // that should be used to create the window. | |
| 363 CreateParams LoadDefaultsAndConstrain( | |
| 
 
tapted
2013/10/14 05:13:43
Hm.. the non-overrides are already mixed in with a
 
jackhou1
2013/10/14 23:45:32
Done.
 
 | |
| 364 const CreateParams& create_params) const; | |
| 365 | |
| 329 // extensions::ExtensionKeybindingRegistry::Delegate implementation. | 366 // extensions::ExtensionKeybindingRegistry::Delegate implementation. | 
| 330 virtual extensions::ActiveTabPermissionGranter* | 367 virtual extensions::ActiveTabPermissionGranter* | 
| 331 GetActiveTabPermissionGranter() OVERRIDE; | 368 GetActiveTabPermissionGranter() OVERRIDE; | 
| 332 | 369 | 
| 333 // web_modal::WebContentsModalDialogManagerDelegate implementation. | 370 // web_modal::WebContentsModalDialogManagerDelegate implementation. | 
| 334 virtual web_modal::WebContentsModalDialogHost* | 371 virtual web_modal::WebContentsModalDialogHost* | 
| 335 GetWebContentsModalDialogHost() OVERRIDE; | 372 GetWebContentsModalDialogHost() OVERRIDE; | 
| 336 | 373 | 
| 337 // Callback from web_contents()->DownloadFavicon. | 374 // Callback from web_contents()->DownloadFavicon. | 
| 338 void DidDownloadFavicon(int id, | 375 void DidDownloadFavicon(int id, | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; | 412 base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; | 
| 376 | 413 | 
| 377 // Fullscreen entered by app.window api. | 414 // Fullscreen entered by app.window api. | 
| 378 bool fullscreen_for_window_api_; | 415 bool fullscreen_for_window_api_; | 
| 379 // Fullscreen entered by HTML requestFullscreen. | 416 // Fullscreen entered by HTML requestFullscreen. | 
| 380 bool fullscreen_for_tab_; | 417 bool fullscreen_for_tab_; | 
| 381 | 418 | 
| 382 // The window content is visible. | 419 // The window content is visible. | 
| 383 bool is_content_visible_; | 420 bool is_content_visible_; | 
| 384 | 421 | 
| 422 // Size constraints on the window. | |
| 423 SizeConstraints size_constraints_; | |
| 
 
tapted
2013/10/14 05:13:43
maybe move this to the next CL
 
jackhou1
2013/10/14 23:45:32
Done.
 
 | |
| 424 | |
| 385 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 425 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 
| 386 }; | 426 }; | 
| 387 | 427 | 
| 388 } // namespace apps | 428 } // namespace apps | 
| 389 | 429 | 
| 390 #endif // APPS_SHELL_WINDOW_H_ | 430 #endif // APPS_SHELL_WINDOW_H_ | 
| OLD | NEW |