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