| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/ui/constrained_window.h" | 9 #include "chrome/browser/ui/constrained_window.h" |
| 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 13 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 class WebContents; | 18 class WebContents; |
| 17 } | 19 } |
| 18 namespace views { | 20 namespace views { |
| 19 namespace internal { | 21 namespace internal { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 /////////////////////////////////////////////////////////////////////////////// | 54 /////////////////////////////////////////////////////////////////////////////// |
| 53 // ConstrainedWindowViews | 55 // ConstrainedWindowViews |
| 54 // | 56 // |
| 55 // A ConstrainedWindow implementation that implements a Constrained Window as | 57 // A ConstrainedWindow implementation that implements a Constrained Window as |
| 56 // a child HWND with a custom window frame. The ConstrainedWindowViews owns | 58 // a child HWND with a custom window frame. The ConstrainedWindowViews owns |
| 57 // itself and will be deleted soon after being closed. | 59 // itself and will be deleted soon after being closed. |
| 58 // | 60 // |
| 59 class ConstrainedWindowViews : public views::Widget, | 61 class ConstrainedWindowViews : public views::Widget, |
| 60 public ConstrainedWindow, | 62 public ConstrainedWindow, |
| 61 public NativeConstrainedWindowDelegate, | 63 public NativeConstrainedWindowDelegate, |
| 62 public content::WebContentsObserver { | 64 public content::WebContentsObserver, |
| 65 public content::NotificationObserver { |
| 63 public: | 66 public: |
| 67 // Types of insets to use with chrome style frame. |
| 68 enum ChromeStyleClientInsets { |
| 69 DEFAULT_INSETS, |
| 70 NO_INSETS, |
| 71 }; |
| 72 |
| 64 ConstrainedWindowViews(content::WebContents* web_contents, | 73 ConstrainedWindowViews(content::WebContents* web_contents, |
| 65 views::WidgetDelegate* widget_delegate, | 74 views::WidgetDelegate* widget_delegate, |
| 66 bool enable_chrome_style); | 75 bool enable_chrome_style, |
| 76 ChromeStyleClientInsets chrome_style_client_insets); |
| 67 virtual ~ConstrainedWindowViews(); | 77 virtual ~ConstrainedWindowViews(); |
| 68 | 78 |
| 69 // Returns the WebContents that constrains this Constrained Window. | 79 // Returns the WebContents that constrains this Constrained Window. |
| 70 content::WebContents* owner() const { return web_contents_; } | 80 content::WebContents* owner() const { return web_contents_; } |
| 71 | 81 |
| 72 // Overridden from ConstrainedWindow: | 82 // Overridden from ConstrainedWindow: |
| 73 virtual void ShowConstrainedWindow() OVERRIDE; | 83 virtual void ShowConstrainedWindow() OVERRIDE; |
| 74 virtual void CloseConstrainedWindow() OVERRIDE; | 84 virtual void CloseConstrainedWindow() OVERRIDE; |
| 75 virtual void FocusConstrainedWindow() OVERRIDE; | 85 virtual void FocusConstrainedWindow() OVERRIDE; |
| 76 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 86 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 77 | 87 |
| 78 // Overridden from views::Widget: | 88 // Overridden from views::Widget: |
| 79 void CenterWindow(const gfx::Size& size); | 89 void CenterWindow(const gfx::Size& size); |
| 80 | 90 |
| 91 // Default insets for the dialog: |
| 92 static gfx::Insets GetDefaultInsets(); |
| 93 |
| 81 private: | 94 private: |
| 82 void NotifyTabHelperWillClose(); | 95 void NotifyTabHelperWillClose(); |
| 83 | 96 |
| 84 // Overridden from views::Widget: | 97 // Overridden from views::Widget: |
| 85 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 98 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
| 86 | 99 |
| 87 // Overridden from NativeConstrainedWindowDelegate: | 100 // Overridden from NativeConstrainedWindowDelegate: |
| 88 virtual void OnNativeConstrainedWindowDestroyed() OVERRIDE; | 101 virtual void OnNativeConstrainedWindowDestroyed() OVERRIDE; |
| 89 virtual void OnNativeConstrainedWindowMouseActivate() OVERRIDE; | 102 virtual void OnNativeConstrainedWindowMouseActivate() OVERRIDE; |
| 90 virtual views::internal::NativeWidgetDelegate* | 103 virtual views::internal::NativeWidgetDelegate* |
| 91 AsNativeWidgetDelegate() OVERRIDE; | 104 AsNativeWidgetDelegate() OVERRIDE; |
| 92 virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE; | 105 virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE; |
| 93 | 106 |
| 94 // Set the top of the window to overlap the browser chrome. | |
| 95 void PositionChromeStyleWindow(); | |
| 96 | |
| 97 // Overridden from content::WebContentsObserver: | 107 // Overridden from content::WebContentsObserver: |
| 98 virtual void WebContentsDestroyed(content::WebContents* web_contents) | 108 virtual void WebContentsDestroyed(content::WebContents* web_contents) |
| 99 OVERRIDE; | 109 OVERRIDE; |
| 100 | 110 |
| 111 // Overridden from content::NotificationObserver: |
| 112 virtual void Observe(int type, |
| 113 const content::NotificationSource& source, |
| 114 const content::NotificationDetails& details) OVERRIDE; |
| 115 |
| 116 // Set the top of the window to overlap the browser chrome. |
| 117 void PositionChromeStyleWindow(const gfx::Size& size); |
| 118 |
| 119 content::NotificationRegistrar registrar_; |
| 101 content::WebContents* web_contents_; | 120 content::WebContents* web_contents_; |
| 102 | 121 |
| 103 NativeConstrainedWindow* native_constrained_window_; | |
| 104 | |
| 105 // TODO(wittman): remove once all constrained window dialogs are moved | 122 // TODO(wittman): remove once all constrained window dialogs are moved |
| 106 // over to Chrome style. | 123 // over to Chrome style. |
| 107 const bool enable_chrome_style_; | 124 const bool enable_chrome_style_; |
| 108 | 125 |
| 126 // Client insets to use when |enable_chrome_style_| is true. |
| 127 ChromeStyleClientInsets chrome_style_client_insets_; |
| 128 |
| 129 NativeConstrainedWindow* native_constrained_window_; |
| 130 |
| 109 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews); | 131 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews); |
| 110 }; | 132 }; |
| 111 | 133 |
| 112 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ | 134 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ |
| OLD | NEW |