| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/ui/constrained_window.h" | 14 #include "chrome/browser/ui/constrained_window.h" |
| 15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
| 16 #include "ui/base/gtk/owned_widget_gtk.h" | 16 #include "ui/base/gtk/owned_widget_gtk.h" |
| 17 | 17 |
| 18 class TabContents; | 18 class TabContents; |
| 19 typedef TabContents TabContentsWrapper; | |
| 20 typedef struct _GdkColor GdkColor; | 19 typedef struct _GdkColor GdkColor; |
| 21 class ChromeWebContentsViewDelegateGtk; | 20 class ChromeWebContentsViewDelegateGtk; |
| 22 | 21 |
| 23 class ConstrainedWindowGtkDelegate { | 22 class ConstrainedWindowGtkDelegate { |
| 24 public: | 23 public: |
| 25 // Returns the widget that will be put in the constrained window's container. | 24 // Returns the widget that will be put in the constrained window's container. |
| 26 virtual GtkWidget* GetWidgetRoot() = 0; | 25 virtual GtkWidget* GetWidgetRoot() = 0; |
| 27 | 26 |
| 28 // Returns the widget that should get focus when ConstrainedWindow is focused. | 27 // Returns the widget that should get focus when ConstrainedWindow is focused. |
| 29 virtual GtkWidget* GetFocusWidget() = 0; | 28 virtual GtkWidget* GetFocusWidget() = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 virtual ~ConstrainedWindowGtkDelegate(); | 40 virtual ~ConstrainedWindowGtkDelegate(); |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 // Constrained window implementation for the GTK port. Unlike the Win32 system, | 43 // Constrained window implementation for the GTK port. Unlike the Win32 system, |
| 45 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just | 44 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just |
| 46 // centers the dialog. It is thus an order of magnitude simpler. | 45 // centers the dialog. It is thus an order of magnitude simpler. |
| 47 class ConstrainedWindowGtk : public ConstrainedWindow { | 46 class ConstrainedWindowGtk : public ConstrainedWindow { |
| 48 public: | 47 public: |
| 49 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; | 48 typedef ChromeWebContentsViewDelegateGtk TabContentsViewType; |
| 50 | 49 |
| 51 ConstrainedWindowGtk(TabContentsWrapper* wrapper, | 50 ConstrainedWindowGtk(TabContents* tab_contents, |
| 52 ConstrainedWindowGtkDelegate* delegate); | 51 ConstrainedWindowGtkDelegate* delegate); |
| 53 virtual ~ConstrainedWindowGtk(); | 52 virtual ~ConstrainedWindowGtk(); |
| 54 | 53 |
| 55 // Overridden from ConstrainedWindow: | 54 // Overridden from ConstrainedWindow: |
| 56 virtual void ShowConstrainedWindow() OVERRIDE; | 55 virtual void ShowConstrainedWindow() OVERRIDE; |
| 57 virtual void CloseConstrainedWindow() OVERRIDE; | 56 virtual void CloseConstrainedWindow() OVERRIDE; |
| 58 virtual void FocusConstrainedWindow() OVERRIDE; | 57 virtual void FocusConstrainedWindow() OVERRIDE; |
| 59 | 58 |
| 60 // Returns the TabContentsWrapper that constrains this Constrained Window. | 59 // Returns the TabContents that constrains this Constrained Window. |
| 61 TabContentsWrapper* owner() const { return wrapper_; } | 60 TabContents* owner() const { return tab_contents_; } |
| 62 | 61 |
| 63 // Returns the toplevel widget that displays this "window". | 62 // Returns the toplevel widget that displays this "window". |
| 64 GtkWidget* widget() { return border_.get(); } | 63 GtkWidget* widget() { return border_.get(); } |
| 65 | 64 |
| 66 // Returns the View that we collaborate with to position ourselves. | 65 // Returns the View that we collaborate with to position ourselves. |
| 67 TabContentsViewType* ContainingView(); | 66 TabContentsViewType* ContainingView(); |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 friend class ConstrainedWindow; | 69 friend class ConstrainedWindow; |
| 71 | 70 |
| 72 // Signal callbacks. | 71 // Signal callbacks. |
| 73 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | 72 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, |
| 74 GdkEventKey*); | 73 GdkEventKey*); |
| 75 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, | 74 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, void, OnHierarchyChanged, |
| 76 GtkWidget*); | 75 GtkWidget*); |
| 77 | 76 |
| 78 // The TabContentsWrapper that owns and constrains this ConstrainedWindow. | 77 // The TabContents that owns and constrains this ConstrainedWindow. |
| 79 TabContentsWrapper* wrapper_; | 78 TabContents* tab_contents_; |
| 80 | 79 |
| 81 // The top level widget container that exports to our WebContentsView. | 80 // The top level widget container that exports to our WebContentsView. |
| 82 ui::OwnedWidgetGtk border_; | 81 ui::OwnedWidgetGtk border_; |
| 83 | 82 |
| 84 // Delegate that provides the contents of this constrained window. | 83 // Delegate that provides the contents of this constrained window. |
| 85 ConstrainedWindowGtkDelegate* delegate_; | 84 ConstrainedWindowGtkDelegate* delegate_; |
| 86 | 85 |
| 87 // Stores if |ShowConstrainedWindow()| has been called. | 86 // Stores if |ShowConstrainedWindow()| has been called. |
| 88 bool visible_; | 87 bool visible_; |
| 89 | 88 |
| 90 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; | 89 base::WeakPtrFactory<ConstrainedWindowGtk> weak_factory_; |
| 91 | 90 |
| 92 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | 91 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ | 94 #endif // CHROME_BROWSER_UI_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| OLD | NEW |