Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_APP_WINDOW_H_ | 5 #ifndef APPS_APP_WINDOW_H_ |
| 6 #define APPS_APP_WINDOW_H_ | 6 #define APPS_APP_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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 109 |
| 110 // Fullscreen entered by the OS. ChromeOS uses this type of fullscreen to | 110 // Fullscreen entered by the OS. ChromeOS uses this type of fullscreen to |
| 111 // enter immersive fullscreen when the user hits the <F4> key. | 111 // enter immersive fullscreen when the user hits the <F4> key. |
| 112 FULLSCREEN_TYPE_OS = 1 << 2, | 112 FULLSCREEN_TYPE_OS = 1 << 2, |
| 113 | 113 |
| 114 // Fullscreen mode that could not be exited by the user. ChromeOS uses | 114 // Fullscreen mode that could not be exited by the user. ChromeOS uses |
| 115 // this type of fullscreen to run an app in kiosk mode. | 115 // this type of fullscreen to run an app in kiosk mode. |
| 116 FULLSCREEN_TYPE_FORCED = 1 << 3, | 116 FULLSCREEN_TYPE_FORCED = 1 << 3, |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 struct BoundsSpecification { | |
| 120 // INT_MIN represents an unspecified position component. | |
| 121 static const int kUnspecifiedPosition; | |
| 122 | |
| 123 BoundsSpecification(); | |
| 124 ~BoundsSpecification(); | |
| 125 | |
| 126 // INT_MIN designates 'unspecified' for the position components, and 0 for | |
|
benwells
2014/03/05 02:33:30
Does INT_MIN mean 0 for size, or does 0 mean unspe
tmdiep
2014/03/05 03:06:47
I'll reword this comment.
INT_MIN means unspecifie
| |
| 127 // the size components. When unspecified, they should be replaced with a | |
| 128 // default value. | |
| 129 gfx::Rect bounds; | |
| 130 | |
| 131 gfx::Size minimum_size; | |
| 132 gfx::Size maximum_size; | |
| 133 | |
| 134 // Reset the bounds fields to their 'unspecified' values. | |
|
tapted
2014/03/05 03:14:03
nit: mention that minimum/maximum size are unchang
| |
| 135 void ResetBounds(); | |
| 136 }; | |
| 137 | |
| 119 struct CreateParams { | 138 struct CreateParams { |
| 120 CreateParams(); | 139 CreateParams(); |
| 121 ~CreateParams(); | 140 ~CreateParams(); |
| 122 | 141 |
| 123 WindowType window_type; | 142 WindowType window_type; |
| 124 Frame frame; | 143 Frame frame; |
| 125 | 144 |
| 126 bool has_frame_color; | 145 bool has_frame_color; |
| 127 SkColor frame_color; | 146 SkColor frame_color; |
| 128 bool transparent_background; // Only supported on ash. | 147 bool transparent_background; // Only supported on ash. |
| 129 | 148 |
| 130 // Specify the initial content bounds of the window (excluding any window | 149 // The initial content/inner bounds specification (excluding any window |
| 131 // decorations). INT_MIN designates 'unspecified' for the position | 150 // decorations). |
| 132 // components, and 0 for the size components. When unspecified, they should | 151 BoundsSpecification content_spec; |
| 133 // be replaced with a default value. | |
| 134 gfx::Rect bounds; | |
| 135 | 152 |
| 136 gfx::Size minimum_size; | 153 // The initial window/outer bounds specification (including window |
| 137 gfx::Size maximum_size; | 154 // decorations). |
| 155 BoundsSpecification window_spec; | |
| 138 | 156 |
| 139 std::string window_key; | 157 std::string window_key; |
| 140 | 158 |
| 141 // The process ID of the process that requested the create. | 159 // The process ID of the process that requested the create. |
| 142 int32 creator_process_id; | 160 int32 creator_process_id; |
| 143 | 161 |
| 144 // Initial state of the window. | 162 // Initial state of the window. |
| 145 ui::WindowShowState state; | 163 ui::WindowShowState state; |
| 146 | 164 |
| 147 // If true, don't show the window after creation. | 165 // If true, don't show the window after creation. |
| 148 bool hidden; | 166 bool hidden; |
| 149 | 167 |
| 150 // If true, the window will be resizable by the user. Defaults to true. | 168 // If true, the window will be resizable by the user. Defaults to true. |
| 151 bool resizable; | 169 bool resizable; |
| 152 | 170 |
| 153 // If true, the window will be focused on creation. Defaults to true. | 171 // If true, the window will be focused on creation. Defaults to true. |
| 154 bool focused; | 172 bool focused; |
| 155 | 173 |
| 156 // If true, the window will stay on top of other windows that are not | 174 // If true, the window will stay on top of other windows that are not |
| 157 // configured to be always on top. Defaults to false. | 175 // configured to be always on top. Defaults to false. |
| 158 bool always_on_top; | 176 bool always_on_top; |
| 177 | |
| 178 // The API enables developers to specify content or window bounds. This | |
| 179 // function combines them into a single, constrained window size. Note that | |
| 180 // until the frame insets are known, the returned value is just an estimate. | |
|
benwells
2014/03/05 02:33:30
I don't understand the comment about frame insets.
tmdiep
2014/03/05 03:06:47
We need the window created first to get the real f
| |
| 181 gfx::Rect GetInitialWindowBounds(const gfx::Insets& frame_insets) const; | |
| 182 | |
| 183 // The API enables developers to specify content or window size constraints. | |
| 184 // These functions combine them so that we can work with one set of | |
| 185 // constraints. | |
| 186 gfx::Size GetContentMinimumSize(const gfx::Insets& frame_insets) const; | |
| 187 gfx::Size GetContentMaximumSize(const gfx::Insets& frame_insets) const; | |
| 188 gfx::Size GetWindowMinimumSize(const gfx::Insets& frame_insets) const; | |
| 189 gfx::Size GetWindowMaximumSize(const gfx::Insets& frame_insets) const; | |
| 159 }; | 190 }; |
| 160 | 191 |
| 161 class Delegate { | 192 class Delegate { |
| 162 public: | 193 public: |
| 163 virtual ~Delegate(); | 194 virtual ~Delegate(); |
| 164 | 195 |
| 165 // General initialization. | 196 // General initialization. |
| 166 virtual void InitWebContents(content::WebContents* web_contents) = 0; | 197 virtual void InitWebContents(content::WebContents* web_contents) = 0; |
| 167 virtual NativeAppWindow* CreateNativeAppWindow( | 198 virtual NativeAppWindow* CreateNativeAppWindow( |
| 168 AppWindow* window, | 199 AppWindow* window, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 void Minimize(); | 313 void Minimize(); |
| 283 void Restore(); | 314 void Restore(); |
| 284 | 315 |
| 285 // Transitions to OS fullscreen. See FULLSCREEN_TYPE_OS for more details. | 316 // Transitions to OS fullscreen. See FULLSCREEN_TYPE_OS for more details. |
| 286 void OSFullscreen(); | 317 void OSFullscreen(); |
| 287 | 318 |
| 288 // Transitions to forced fullscreen. See FULLSCREEN_TYPE_FORCED for more | 319 // Transitions to forced fullscreen. See FULLSCREEN_TYPE_FORCED for more |
| 289 // details. | 320 // details. |
| 290 void ForcedFullscreen(); | 321 void ForcedFullscreen(); |
| 291 | 322 |
| 292 // Set the minimum and maximum size that this window is allowed to be. | 323 // Set the minimum and maximum size of the content bounds. |
| 293 void SetMinimumSize(const gfx::Size& min_size); | 324 void SetContentMinimumSize(const gfx::Size& min_size); |
| 294 void SetMaximumSize(const gfx::Size& max_size); | 325 void SetContentMaximumSize(const gfx::Size& max_size); |
| 295 | 326 |
| 296 enum ShowType { SHOW_ACTIVE, SHOW_INACTIVE }; | 327 enum ShowType { SHOW_ACTIVE, SHOW_INACTIVE }; |
| 297 | 328 |
| 298 // Shows the window if its contents have been painted; otherwise flags the | 329 // Shows the window if its contents have been painted; otherwise flags the |
| 299 // window to be shown as soon as its contents are painted for the first time. | 330 // window to be shown as soon as its contents are painted for the first time. |
| 300 void Show(ShowType show_type); | 331 void Show(ShowType show_type); |
| 301 | 332 |
| 302 // Hides the window. If the window was previously flagged to be shown on | 333 // Hides the window. If the window was previously flagged to be shown on |
| 303 // first paint, it will be unflagged. | 334 // first paint, it will be unflagged. |
| 304 void Hide(); | 335 void Hide(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 OVERRIDE; | 420 OVERRIDE; |
| 390 | 421 |
| 391 // Helper method to add a message to the renderer's DevTools console. | 422 // Helper method to add a message to the renderer's DevTools console. |
| 392 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, | 423 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, |
| 393 const std::string& message); | 424 const std::string& message); |
| 394 | 425 |
| 395 // Saves the window geometry/position/screen bounds. | 426 // Saves the window geometry/position/screen bounds. |
| 396 void SaveWindowPosition(); | 427 void SaveWindowPosition(); |
| 397 | 428 |
| 398 // Helper method to adjust the cached bounds so that we can make sure it can | 429 // Helper method to adjust the cached bounds so that we can make sure it can |
| 399 // be visible on the screen. See http://crbug.com/145752 . | 430 // be visible on the screen. See http://crbug.com/145752. |
| 400 void AdjustBoundsToBeVisibleOnScreen(const gfx::Rect& cached_bounds, | 431 void AdjustBoundsToBeVisibleOnScreen(const gfx::Rect& cached_bounds, |
| 401 const gfx::Rect& cached_screen_bounds, | 432 const gfx::Rect& cached_screen_bounds, |
| 402 const gfx::Rect& current_screen_bounds, | 433 const gfx::Rect& current_screen_bounds, |
| 403 const gfx::Size& minimum_size, | 434 const gfx::Size& minimum_size, |
| 404 gfx::Rect* bounds) const; | 435 gfx::Rect* bounds) const; |
| 405 | 436 |
| 406 // Loads the appropriate default or cached window bounds and constrains them | 437 // Loads the appropriate default or cached window bounds. Returns a new |
| 407 // based on screen size and minimum/maximum size. Returns a new CreateParams | 438 // CreateParams that should be used to create the window. |
| 408 // that should be used to create the window. | 439 CreateParams LoadDefaults(CreateParams params) const; |
| 409 CreateParams LoadDefaultsAndConstrain(CreateParams params) const; | |
| 410 | 440 |
| 411 // Load the app's image, firing a load state change when loaded. | 441 // Load the app's image, firing a load state change when loaded. |
| 412 void UpdateExtensionAppIcon(); | 442 void UpdateExtensionAppIcon(); |
| 413 | 443 |
| 414 // Called when size_constraints is changed. | 444 // Called when size_constraints is changed. |
| 415 void OnSizeConstraintsChanged(); | 445 void OnSizeConstraintsChanged(); |
| 416 | 446 |
| 417 // Set the fullscreen state in the native app window. | 447 // Set the fullscreen state in the native app window. |
| 418 void SetNativeWindowFullscreen(); | 448 void SetNativeWindowFullscreen(); |
| 419 | 449 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 // reinstated when the window exits fullscreen and moves away from the | 537 // reinstated when the window exits fullscreen and moves away from the |
| 508 // taskbar. | 538 // taskbar. |
| 509 bool cached_always_on_top_; | 539 bool cached_always_on_top_; |
| 510 | 540 |
| 511 DISALLOW_COPY_AND_ASSIGN(AppWindow); | 541 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
| 512 }; | 542 }; |
| 513 | 543 |
| 514 } // namespace apps | 544 } // namespace apps |
| 515 | 545 |
| 516 #endif // APPS_APP_WINDOW_H_ | 546 #endif // APPS_APP_WINDOW_H_ |
| OLD | NEW |