| 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/web_contents_modal_dialog.h" | 9 #include "chrome/browser/ui/web_contents_modal_dialog.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class WebContents; | 15 class WebContents; |
| 16 } | 16 } |
| 17 namespace views { | 17 namespace views { |
| 18 namespace internal { | 18 namespace internal { |
| 19 class NativeWidgetDelegate; | 19 class NativeWidgetDelegate; |
| 20 } | 20 } |
| 21 class NativeWidget; | 21 class NativeWidget; |
| 22 class NonClientFrameView; | 22 class NonClientFrameView; |
| 23 class WidgetDelegate; | 23 class WidgetDelegate; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class NativeConstrainedWindowDelegate { | |
| 27 public: | |
| 28 virtual ~NativeConstrainedWindowDelegate() {} | |
| 29 | |
| 30 // Called after the NativeConstrainedWindow has been destroyed and is about to | |
| 31 // be deleted. | |
| 32 virtual void OnNativeConstrainedWindowDestroyed() = 0; | |
| 33 | |
| 34 // Called when the NativeConstrainedWindow is clicked on when inactive. | |
| 35 virtual void OnNativeConstrainedWindowMouseActivate() = 0; | |
| 36 | |
| 37 virtual views::internal::NativeWidgetDelegate* AsNativeWidgetDelegate() = 0; | |
| 38 }; | |
| 39 | |
| 40 class NativeConstrainedWindow { | |
| 41 public: | |
| 42 virtual ~NativeConstrainedWindow() {} | |
| 43 | |
| 44 // Creates a platform-specific implementation of NativeConstrainedWindow. | |
| 45 static NativeConstrainedWindow* CreateNativeConstrainedWindow( | |
| 46 NativeConstrainedWindowDelegate* delegate); | |
| 47 | |
| 48 virtual views::NativeWidget* AsNativeWidget() = 0; | |
| 49 }; | |
| 50 | |
| 51 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 52 // ConstrainedWindowViews | 27 // ConstrainedWindowViews |
| 53 // | 28 // |
| 54 // A WebContentsModalDialog implementation that implements the dialog as a | 29 // A WebContentsModalDialog implementation that implements the dialog as a |
| 55 // child HWND with a custom window frame. The ConstrainedWindowViews owns | 30 // child HWND with a custom window frame. The ConstrainedWindowViews owns |
| 56 // itself and will be deleted soon after being closed. | 31 // itself and will be deleted soon after being closed. |
| 57 // | 32 // |
| 58 class ConstrainedWindowViews : public views::Widget, | 33 class ConstrainedWindowViews : public views::Widget, |
| 59 public WebContentsModalDialog, | 34 public WebContentsModalDialog { |
| 60 public NativeConstrainedWindowDelegate { | |
| 61 public: | 35 public: |
| 62 ConstrainedWindowViews(content::WebContents* web_contents, | 36 ConstrainedWindowViews(gfx::NativeView parent, |
| 37 bool off_the_record, |
| 63 views::WidgetDelegate* widget_delegate); | 38 views::WidgetDelegate* widget_delegate); |
| 64 virtual ~ConstrainedWindowViews(); | 39 virtual ~ConstrainedWindowViews(); |
| 65 | 40 |
| 66 // Returns the WebContents that constrains this Constrained Window. | |
| 67 content::WebContents* owner() const { return web_contents_; } | |
| 68 | |
| 69 // Overridden from WebContentsModalDialog: | 41 // Overridden from WebContentsModalDialog: |
| 70 virtual void ShowWebContentsModalDialog() OVERRIDE; | 42 virtual void ShowWebContentsModalDialog() OVERRIDE; |
| 71 virtual void CloseWebContentsModalDialog() OVERRIDE; | 43 virtual void CloseWebContentsModalDialog() OVERRIDE; |
| 72 virtual void FocusWebContentsModalDialog() OVERRIDE; | 44 virtual void FocusWebContentsModalDialog() OVERRIDE; |
| 73 virtual void PulseWebContentsModalDialog() OVERRIDE; | 45 virtual void PulseWebContentsModalDialog() OVERRIDE; |
| 74 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 46 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 75 | 47 |
| 76 // Default insets for the dialog: | 48 // Factory function for the class (temporary). |
| 77 static gfx::Insets GetDefaultInsets(); | 49 static ConstrainedWindowViews* Create(content::WebContents* web_contents, |
| 50 views::WidgetDelegate* widget_delegate); |
| 78 | 51 |
| 79 private: | 52 private: |
| 80 // Overridden from views::Widget: | 53 // Overridden from views::Widget: |
| 81 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 54 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
| 82 | 55 |
| 83 // Overridden from NativeConstrainedWindowDelegate: | 56 bool off_the_record_; |
| 84 virtual void OnNativeConstrainedWindowDestroyed() OVERRIDE; | |
| 85 virtual void OnNativeConstrainedWindowMouseActivate() OVERRIDE; | |
| 86 virtual views::internal::NativeWidgetDelegate* | |
| 87 AsNativeWidgetDelegate() OVERRIDE; | |
| 88 virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE; | |
| 89 | |
| 90 content::WebContents* web_contents_; | |
| 91 | |
| 92 NativeConstrainedWindow* native_constrained_window_; | |
| 93 | 57 |
| 94 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews); | 58 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews); |
| 95 }; | 59 }; |
| 96 | 60 |
| 97 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ | 61 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ |
| OLD | NEW |