| 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/native_web_contents_modal_dialog.h" | 13 #include "chrome/browser/ui/native_web_contents_modal_dialog.h" |
| 14 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
| 15 | 15 |
| 16 typedef struct _GdkColor GdkColor; | 16 typedef struct _GdkColor GdkColor; |
| 17 class ChromeWebContentsViewDelegateGtk; | 17 class ChromeWebContentsViewDelegateGtk; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class WebContents; | 20 class WebContents; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class ConstrainedWindowGtkDelegate { | |
| 24 public: | |
| 25 // Returns the widget that will be put in the constrained window's container. | |
| 26 virtual GtkWidget* GetWidgetRoot() = 0; | |
| 27 | |
| 28 // Returns the widget that should get focus when ConstrainedWindowGtk is | |
| 29 // focused. | |
| 30 virtual GtkWidget* GetFocusWidget() = 0; | |
| 31 | |
| 32 // Tells the delegate to either delete itself or set up a task to delete | |
| 33 // itself later. | |
| 34 virtual void DeleteDelegate() = 0; | |
| 35 | |
| 36 virtual bool GetBackgroundColor(GdkColor* color); | |
| 37 | |
| 38 protected: | |
| 39 virtual ~ConstrainedWindowGtkDelegate(); | |
| 40 }; | |
| 41 | |
| 42 // Web contents modal dialog implementation for the GTK port. Unlike the Win32 | 23 // Web contents modal dialog implementation for the GTK port. Unlike the Win32 |
| 43 // system, ConstrainedWindowGtk doesn't draw draggable fake windows and instead | 24 // system, ConstrainedWindowGtk doesn't draw draggable fake windows and instead |
| 44 // just centers the dialog. It is thus an order of magnitude simpler. | 25 // just centers the dialog. It is thus an order of magnitude simpler. |
| 45 class ConstrainedWindowGtk { | 26 class ConstrainedWindowGtk { |
| 46 public: | 27 public: |
| 47 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; | 28 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; |
| 48 | 29 |
| 49 ConstrainedWindowGtk(content::WebContents* web_contents, | 30 ConstrainedWindowGtk(content::WebContents* web_contents, |
| 50 ConstrainedWindowGtkDelegate* delegate); | 31 GtkWidget* contents, |
| 32 GtkWidget* focus_widget); |
| 51 virtual ~ConstrainedWindowGtk(); | 33 virtual ~ConstrainedWindowGtk(); |
| 52 | 34 |
| 53 void ShowWebContentsModalDialog(); | 35 void ShowWebContentsModalDialog(); |
| 54 void FocusWebContentsModalDialog(); | 36 void FocusWebContentsModalDialog(); |
| 55 void PulseWebContentsModalDialog(); | 37 void PulseWebContentsModalDialog(); |
| 56 NativeWebContentsModalDialog GetNativeDialog(); | 38 NativeWebContentsModalDialog GetNativeDialog(); |
| 57 | 39 |
| 58 // Returns the toplevel widget that displays this "window". | 40 // Returns the toplevel widget that displays this "window". |
| 59 GtkWidget* widget() { return border_; } | 41 GtkWidget* widget() { return border_; } |
| 60 | 42 |
| 61 private: | 43 private: |
| 62 // Returns the View that we collaborate with to position ourselves. | 44 // Returns the View that we collaborate with to position ourselves. |
| 63 TabContentsViewType* ContainingView(); | 45 TabContentsViewType* ContainingView(); |
| 64 | 46 |
| 65 // Signal callbacks. | 47 // Signal callbacks. |
| 66 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | 48 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, |
| 67 GdkEventKey*); | 49 GdkEventKey*); |
| 68 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, | 50 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, |
| 69 GtkWidget*); | 51 GtkWidget*); |
| 70 CHROMEGTK_CALLBACK_0(ConstrainedWindowGtk, void, OnDestroy); | 52 CHROMEGTK_CALLBACK_0(ConstrainedWindowGtk, void, OnDestroy); |
| 71 | 53 |
| 72 // The WebContents that owns and constrains this ConstrainedWindowGtk. | 54 // The WebContents that owns and constrains this ConstrainedWindowGtk. |
| 73 content::WebContents* web_contents_; | 55 content::WebContents* web_contents_; |
| 74 | 56 |
| 75 // The top level widget container that exports to our WebContentsView. | 57 // The top level widget container that exports to our WebContentsView. |
| 76 GtkWidget* border_; | 58 GtkWidget* border_; |
| 77 | 59 |
| 78 // Delegate that provides the contents of this constrained window. | 60 // The widget that should get focus when ConstrainedWindowGtk is focused. |
| 79 ConstrainedWindowGtkDelegate* delegate_; | 61 GtkWidget* focus_widget_; |
| 80 | 62 |
| 81 // Stores if |ShowWebContentsModalDialog()| has been called. | 63 // Stores if |ShowWebContentsModalDialog()| has been called. |
| 82 bool visible_; | 64 bool visible_; |
| 83 | 65 |
| 84 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | 66 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); |
| 85 }; | 67 }; |
| 86 | 68 |
| 87 GtkWidget* CreateWebContentsModalDialogGtk( | 69 GtkWidget* CreateWebContentsModalDialogGtk( |
| 88 content::WebContents* web_contents, | 70 content::WebContents* web_contents, |
| 89 ConstrainedWindowGtkDelegate* delegate); | 71 GtkWidget* contents, |
| 72 GtkWidget* focus_widget); |
| 90 | 73 |
| 91 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ | 74 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| OLD | NEW |