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_GTK_CONSTRAINED_WINDOW_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/ui/constrained_window.h" | 13 #include "chrome/browser/ui/web_contents_modal_dialog.h" |
14 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
15 #include "ui/base/gtk/owned_widget_gtk.h" | 15 #include "ui/base/gtk/owned_widget_gtk.h" |
16 | 16 |
17 typedef struct _GdkColor GdkColor; | 17 typedef struct _GdkColor GdkColor; |
18 class ChromeWebContentsViewDelegateGtk; | 18 class ChromeWebContentsViewDelegateGtk; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class WebContents; | 21 class WebContents; |
22 } | 22 } |
23 | 23 |
24 class ConstrainedWindowGtkDelegate { | 24 class ConstrainedWindowGtkDelegate { |
25 public: | 25 public: |
26 // Returns the widget that will be put in the constrained window's container. | 26 // Returns the widget that will be put in the constrained window's container. |
27 virtual GtkWidget* GetWidgetRoot() = 0; | 27 virtual GtkWidget* GetWidgetRoot() = 0; |
28 | 28 |
29 // Returns the widget that should get focus when ConstrainedWindow is focused. | 29 // Returns the widget that should get focus when WebContentsModalDialog is |
| 30 // focused. |
30 virtual GtkWidget* GetFocusWidget() = 0; | 31 virtual GtkWidget* GetFocusWidget() = 0; |
31 | 32 |
32 // Tells the delegate to either delete itself or set up a task to delete | 33 // Tells the delegate to either delete itself or set up a task to delete |
33 // itself later. | 34 // itself later. |
34 virtual void DeleteDelegate() = 0; | 35 virtual void DeleteDelegate() = 0; |
35 | 36 |
36 virtual bool GetBackgroundColor(GdkColor* color); | 37 virtual bool GetBackgroundColor(GdkColor* color); |
37 | 38 |
38 // Returns true if hosting ConstrainedWindowGtk should apply default padding. | 39 // Returns true if hosting ConstrainedWindowGtk should apply default padding. |
39 virtual bool ShouldHaveBorderPadding() const; | 40 virtual bool ShouldHaveBorderPadding() const; |
40 | 41 |
41 protected: | 42 protected: |
42 virtual ~ConstrainedWindowGtkDelegate(); | 43 virtual ~ConstrainedWindowGtkDelegate(); |
43 }; | 44 }; |
44 | 45 |
45 // Constrained window implementation for the GTK port. Unlike the Win32 system, | 46 // WebContentsModalDialog implementation for the GTK port. Unlike the Win32 |
46 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just | 47 // system, ConstrainedWindowGtk doesn't draw draggable fake windows and instead |
47 // centers the dialog. It is thus an order of magnitude simpler. | 48 // just centers the dialog. It is thus an order of magnitude simpler. |
48 class ConstrainedWindowGtk : public ConstrainedWindow { | 49 class ConstrainedWindowGtk : public WebContentsModalDialog { |
49 public: | 50 public: |
50 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; | 51 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; |
51 | 52 |
52 ConstrainedWindowGtk(content::WebContents* web_contents, | 53 ConstrainedWindowGtk(content::WebContents* web_contents, |
53 ConstrainedWindowGtkDelegate* delegate); | 54 ConstrainedWindowGtkDelegate* delegate); |
54 virtual ~ConstrainedWindowGtk(); | 55 virtual ~ConstrainedWindowGtk(); |
55 | 56 |
56 // Overridden from ConstrainedWindow: | 57 // Overridden from WebContentsModalDialog: |
57 virtual void ShowWebContentsModalDialog() OVERRIDE; | 58 virtual void ShowWebContentsModalDialog() OVERRIDE; |
58 virtual void CloseWebContentsModalDialog() OVERRIDE; | 59 virtual void CloseWebContentsModalDialog() OVERRIDE; |
59 virtual void FocusWebContentsModalDialog() OVERRIDE; | 60 virtual void FocusWebContentsModalDialog() OVERRIDE; |
| 61 virtual void PulseWebContentsModalDialog() OVERRIDE; |
| 62 virtual bool CanShowWebContentsModalDialog() OVERRIDE; |
| 63 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
60 | 64 |
61 // Called when the result of GetBackgroundColor may have changed. | 65 // Called when the result of GetBackgroundColor may have changed. |
62 void BackgroundColorChanged(); | 66 void BackgroundColorChanged(); |
63 | 67 |
64 // Returns the WebContents that constrains this Constrained Window. | 68 // Returns the WebContents that constrains this Constrained Window. |
65 content::WebContents* owner() const { return web_contents_; } | 69 content::WebContents* owner() const { return web_contents_; } |
66 | 70 |
67 // Returns the toplevel widget that displays this "window". | 71 // Returns the toplevel widget that displays this "window". |
68 GtkWidget* widget() { return border_.get(); } | 72 GtkWidget* widget() { return border_.get(); } |
69 | 73 |
70 // Returns the View that we collaborate with to position ourselves. | 74 // Returns the View that we collaborate with to position ourselves. |
71 TabContentsViewType* ContainingView(); | 75 TabContentsViewType* ContainingView(); |
72 | 76 |
73 private: | 77 private: |
74 friend class ConstrainedWindow; | 78 friend class WebContentsModalDialog; |
75 | 79 |
76 // Signal callbacks. | 80 // Signal callbacks. |
77 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | 81 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, |
78 GdkEventKey*); | 82 GdkEventKey*); |
79 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, | 83 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, |
80 GtkWidget*); | 84 GtkWidget*); |
81 | 85 |
82 // The WebContents that owns and constrains this ConstrainedWindow. | 86 // The WebContents that owns and constrains this WebContentsModalDialog. |
83 content::WebContents* web_contents_; | 87 content::WebContents* web_contents_; |
84 | 88 |
85 // The top level widget container that exports to our WebContentsView. | 89 // The top level widget container that exports to our WebContentsView. |
86 ui::OwnedWidgetGtk border_; | 90 ui::OwnedWidgetGtk border_; |
87 | 91 |
88 // Delegate that provides the contents of this constrained window. | 92 // Delegate that provides the contents of this constrained window. |
89 ConstrainedWindowGtkDelegate* delegate_; | 93 ConstrainedWindowGtkDelegate* delegate_; |
90 | 94 |
91 // Stores if |ShowWebContentsModalDialog()| has been called. | 95 // Stores if |ShowWebContentsModalDialog()| has been called. |
92 bool visible_; | 96 bool visible_; |
93 | 97 |
94 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; | 98 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; |
95 | 99 |
96 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | 100 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); |
97 }; | 101 }; |
98 | 102 |
99 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ | 103 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
OLD | NEW |