| 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 ShowConstrainedWindow() OVERRIDE; | 58 virtual void ShowWebContentsModalDialog() OVERRIDE; |
| 58 virtual void CloseConstrainedWindow() OVERRIDE; | 59 virtual void CloseWebContentsModalDialog() OVERRIDE; |
| 59 virtual void FocusConstrainedWindow() OVERRIDE; | 60 virtual void FocusWebContentsModalDialog() OVERRIDE; |
| 60 | 61 |
| 61 // Called when the result of GetBackgroundColor may have changed. | 62 // Called when the result of GetBackgroundColor may have changed. |
| 62 void BackgroundColorChanged(); | 63 void BackgroundColorChanged(); |
| 63 | 64 |
| 64 // Returns the WebContents that constrains this Constrained Window. | 65 // Returns the WebContents that constrains this Constrained Window. |
| 65 content::WebContents* owner() const { return web_contents_; } | 66 content::WebContents* owner() const { return web_contents_; } |
| 66 | 67 |
| 67 // Returns the toplevel widget that displays this "window". | 68 // Returns the toplevel widget that displays this "window". |
| 68 GtkWidget* widget() { return border_.get(); } | 69 GtkWidget* widget() { return border_.get(); } |
| 69 | 70 |
| 70 // Returns the View that we collaborate with to position ourselves. | 71 // Returns the View that we collaborate with to position ourselves. |
| 71 TabContentsViewType* ContainingView(); | 72 TabContentsViewType* ContainingView(); |
| 72 | 73 |
| 73 private: | 74 private: |
| 74 friend class ConstrainedWindow; | 75 friend class WebContentsModalDialog; |
| 75 | 76 |
| 76 // Signal callbacks. | 77 // Signal callbacks. |
| 77 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | 78 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, |
| 78 GdkEventKey*); | 79 GdkEventKey*); |
| 79 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, | 80 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, |
| 80 GtkWidget*); | 81 GtkWidget*); |
| 81 | 82 |
| 82 // The WebContents that owns and constrains this ConstrainedWindow. | 83 // The WebContents that owns and constrains this WebContentsModalDialog. |
| 83 content::WebContents* web_contents_; | 84 content::WebContents* web_contents_; |
| 84 | 85 |
| 85 // The top level widget container that exports to our WebContentsView. | 86 // The top level widget container that exports to our WebContentsView. |
| 86 ui::OwnedWidgetGtk border_; | 87 ui::OwnedWidgetGtk border_; |
| 87 | 88 |
| 88 // Delegate that provides the contents of this constrained window. | 89 // Delegate that provides the contents of this constrained window. |
| 89 ConstrainedWindowGtkDelegate* delegate_; | 90 ConstrainedWindowGtkDelegate* delegate_; |
| 90 | 91 |
| 91 // Stores if |ShowConstrainedWindow()| has been called. | 92 // Stores if |ShowWebContentsModalDialog()| has been called. |
| 92 bool visible_; | 93 bool visible_; |
| 93 | 94 |
| 94 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; | 95 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | 97 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ | 100 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| OLD | NEW |