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