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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). | 85 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). |
86 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate | 86 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate |
87 // with v1 apps. | 87 // with v1 apps. |
88 }; | 88 }; |
89 | 89 |
90 enum Frame { | 90 enum Frame { |
91 FRAME_CHROME, // Chrome-style window frame. | 91 FRAME_CHROME, // Chrome-style window frame. |
92 FRAME_NONE, // Frameless window. | 92 FRAME_NONE, // Frameless window. |
93 }; | 93 }; |
94 | 94 |
| 95 enum FullscreenType { |
| 96 // Normal fullscreen. Primarily used by the app.window api. The window takes |
| 97 // up the entire screen and the window header (title bar and window |
| 98 // controls) is hidden. |
| 99 FULLSCREEN_TYPE_WINDOW, |
| 100 |
| 101 // Fullscreen entered by HTML requestFullscreen(). The HTML element on which |
| 102 // requestFullscreen() was called takes up the entire screen and the widnow |
| 103 // header is hidden. |
| 104 FULLSCREEN_TYPE_TAB, |
| 105 |
| 106 // Combination of "window" fullscreen and fullscreen entered by HTML |
| 107 // requestFullscreen(). |
| 108 FULLSCREEN_TYPE_WINDOW_AND_TAB, |
| 109 |
| 110 // Fullscreen entered by hitting <F4> on ChromeOS. The window header slides |
| 111 // onscreen as an overlay when the mouse is hovered at the top of the |
| 112 // screen. |
| 113 FULLSCREEN_TYPE_IMMERSIVE, |
| 114 |
| 115 // Not fullscreen. |
| 116 FULLSCREEN_TYPE_NONE |
| 117 }; |
| 118 |
95 class SizeConstraints { | 119 class SizeConstraints { |
96 public: | 120 public: |
97 // The value SizeConstraints uses to represent an unbounded width or height. | 121 // The value SizeConstraints uses to represent an unbounded width or height. |
98 // This is an enum so that it can be declared inline here. | 122 // This is an enum so that it can be declared inline here. |
99 enum { kUnboundedSize = 0 }; | 123 enum { kUnboundedSize = 0 }; |
100 | 124 |
101 SizeConstraints(); | 125 SizeConstraints(); |
102 SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size); | 126 SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size); |
103 ~SizeConstraints(); | 127 ~SizeConstraints(); |
104 | 128 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // callback. Also called externally for v1 apps using Ash Panels. | 301 // callback. Also called externally for v1 apps using Ash Panels. |
278 void UpdateAppIcon(const gfx::Image& image); | 302 void UpdateAppIcon(const gfx::Image& image); |
279 | 303 |
280 // Transitions window into fullscreen, maximized, minimized or restores based | 304 // Transitions window into fullscreen, maximized, minimized or restores based |
281 // on chrome.app.window API. | 305 // on chrome.app.window API. |
282 void Fullscreen(); | 306 void Fullscreen(); |
283 void Maximize(); | 307 void Maximize(); |
284 void Minimize(); | 308 void Minimize(); |
285 void Restore(); | 309 void Restore(); |
286 | 310 |
| 311 // Transitions into immersive fullscreen if immersive fullscreen is supported |
| 312 // and to "window" fullscreen otherwise. See FULLSCREEN_TYPE_IMMERSIVE for |
| 313 // more details. |
| 314 void ImmersiveFullscreen(); |
| 315 |
287 // Set the minimum and maximum size that this window is allowed to be. | 316 // Set the minimum and maximum size that this window is allowed to be. |
288 void SetMinimumSize(const gfx::Size& min_size); | 317 void SetMinimumSize(const gfx::Size& min_size); |
289 void SetMaximumSize(const gfx::Size& max_size); | 318 void SetMaximumSize(const gfx::Size& max_size); |
290 | 319 |
291 enum ShowType { | 320 enum ShowType { |
292 SHOW_ACTIVE, | 321 SHOW_ACTIVE, |
293 SHOW_INACTIVE | 322 SHOW_INACTIVE |
294 }; | 323 }; |
295 | 324 |
296 // Shows the window if its contents have been painted; otherwise flags the | 325 // 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. | 326 // window to be shown as soon as its contents are painted for the first time. |
298 void Show(ShowType show_type); | 327 void Show(ShowType show_type); |
299 | 328 |
300 // Hides the window. If the window was previously flagged to be shown on | 329 // Hides the window. If the window was previously flagged to be shown on |
301 // first paint, it will be unflagged. | 330 // first paint, it will be unflagged. |
302 void Hide(); | 331 void Hide(); |
303 | 332 |
304 ShellWindowContents* shell_window_contents_for_test() { | 333 ShellWindowContents* shell_window_contents_for_test() { |
305 return shell_window_contents_.get(); | 334 return shell_window_contents_.get(); |
306 } | 335 } |
307 | 336 |
308 // Get the size constraints. | 337 // Get the size constraints. |
309 const SizeConstraints& size_constraints() const { | 338 const SizeConstraints& size_constraints() const { |
310 return size_constraints_; | 339 return size_constraints_; |
311 } | 340 } |
312 | 341 |
| 342 // Get the fullscreen type. |
| 343 FullscreenType fullscreen_type() const { |
| 344 return fullscreen_type_; |
| 345 } |
| 346 |
313 protected: | 347 protected: |
314 virtual ~ShellWindow(); | 348 virtual ~ShellWindow(); |
315 | 349 |
316 private: | 350 private: |
317 // PlatformAppBrowserTest needs access to web_contents() | 351 // PlatformAppBrowserTest needs access to web_contents() |
318 friend class extensions::PlatformAppBrowserTest; | 352 friend class extensions::PlatformAppBrowserTest; |
319 | 353 |
320 // content::WebContentsDelegate implementation. | 354 // content::WebContentsDelegate implementation. |
321 virtual void CloseContents(content::WebContents* contents) OVERRIDE; | 355 virtual void CloseContents(content::WebContents* contents) OVERRIDE; |
322 virtual bool ShouldSuppressDialogs() OVERRIDE; | 356 virtual bool ShouldSuppressDialogs() OVERRIDE; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 471 |
438 // An object to load the app's icon as an extension resource. | 472 // An object to load the app's icon as an extension resource. |
439 scoped_ptr<extensions::IconImage> app_icon_image_; | 473 scoped_ptr<extensions::IconImage> app_icon_image_; |
440 | 474 |
441 scoped_ptr<NativeAppWindow> native_app_window_; | 475 scoped_ptr<NativeAppWindow> native_app_window_; |
442 scoped_ptr<ShellWindowContents> shell_window_contents_; | 476 scoped_ptr<ShellWindowContents> shell_window_contents_; |
443 scoped_ptr<Delegate> delegate_; | 477 scoped_ptr<Delegate> delegate_; |
444 | 478 |
445 base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; | 479 base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; |
446 | 480 |
447 // Fullscreen entered by app.window api. | 481 // The fullscreen type. |
448 bool fullscreen_for_window_api_; | 482 FullscreenType fullscreen_type_; |
449 // Fullscreen entered by HTML requestFullscreen. | |
450 bool fullscreen_for_tab_; | |
451 | 483 |
452 // Size constraints on the window. | 484 // Size constraints on the window. |
453 SizeConstraints size_constraints_; | 485 SizeConstraints size_constraints_; |
454 | 486 |
455 // Show has been called, so the window should be shown once the first visually | 487 // Show has been called, so the window should be shown once the first visually |
456 // non-empty paint occurs. | 488 // non-empty paint occurs. |
457 bool show_on_first_paint_; | 489 bool show_on_first_paint_; |
458 | 490 |
459 // The first visually non-empty paint has completed. | 491 // The first visually non-empty paint has completed. |
460 bool first_paint_complete_; | 492 bool first_paint_complete_; |
461 | 493 |
462 // Whether the delayed Show() call was for an active or inactive window. | 494 // Whether the delayed Show() call was for an active or inactive window. |
463 ShowType delayed_show_type_; | 495 ShowType delayed_show_type_; |
464 | 496 |
465 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 497 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
466 }; | 498 }; |
467 | 499 |
468 } // namespace apps | 500 } // namespace apps |
469 | 501 |
470 #endif // APPS_SHELL_WINDOW_H_ | 502 #endif // APPS_SHELL_WINDOW_H_ |
OLD | NEW |