| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GTK_CONSTRAINED_WINDOW_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ | 6 #define CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
| 10 | 10 // TODO(msw): remove this file once all includes have been updated. |
| 11 #include "app/gtk_signal.h" | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/task.h" | |
| 14 #include "chrome/browser/gtk/owned_widget_gtk.h" | |
| 15 #include "chrome/browser/tab_contents/constrained_window.h" | |
| 16 | |
| 17 class TabContents; | |
| 18 typedef struct _GdkColor GdkColor; | |
| 19 #if defined(TOUCH_UI) | |
| 20 class TabContentsViewViews; | |
| 21 #else | |
| 22 class TabContentsViewGtk; | |
| 23 #endif | |
| 24 | |
| 25 class ConstrainedWindowGtkDelegate { | |
| 26 public: | |
| 27 // Returns the widget that will be put in the constrained window's container. | |
| 28 virtual GtkWidget* GetWidgetRoot() = 0; | |
| 29 | |
| 30 // Tells the delegate to either delete itself or set up a task to delete | |
| 31 // itself later. | |
| 32 virtual void DeleteDelegate() = 0; | |
| 33 | |
| 34 virtual bool GetBackgroundColor(GdkColor* color); | |
| 35 | |
| 36 protected: | |
| 37 virtual ~ConstrainedWindowGtkDelegate(); | |
| 38 }; | |
| 39 | |
| 40 // Constrained window implementation for the GTK port. Unlike the Win32 system, | |
| 41 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just | |
| 42 // centers the dialog. It is thus an order of magnitude simpler. | |
| 43 class ConstrainedWindowGtk : public ConstrainedWindow { | |
| 44 public: | |
| 45 #if defined(TOUCH_UI) | |
| 46 typedef TabContentsViewViews TabContentsViewType; | |
| 47 #else | |
| 48 typedef TabContentsViewGtk TabContentsViewType; | |
| 49 #endif | |
| 50 | |
| 51 virtual ~ConstrainedWindowGtk(); | |
| 52 | |
| 53 // Overridden from ConstrainedWindow: | |
| 54 virtual void ShowConstrainedWindow(); | |
| 55 virtual void CloseConstrainedWindow(); | |
| 56 | |
| 57 // Returns the TabContents that constrains this Constrained Window. | |
| 58 TabContents* owner() const { return owner_; } | |
| 59 | |
| 60 // Returns the toplevel widget that displays this "window". | |
| 61 GtkWidget* widget() { return border_.get(); } | |
| 62 | |
| 63 // Returns the View that we collaborate with to position ourselves. | |
| 64 TabContentsViewType* ContainingView(); | |
| 65 | |
| 66 private: | |
| 67 friend class ConstrainedWindow; | |
| 68 | |
| 69 ConstrainedWindowGtk(TabContents* owner, | |
| 70 ConstrainedWindowGtkDelegate* delegate); | |
| 71 | |
| 72 // Handler for Escape. | |
| 73 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | |
| 74 GdkEventKey*); | |
| 75 | |
| 76 // The TabContents that owns and constrains this ConstrainedWindow. | |
| 77 TabContents* owner_; | |
| 78 | |
| 79 // The top level widget container that exports to our TabContentsView. | |
| 80 OwnedWidgetGtk border_; | |
| 81 | |
| 82 // Delegate that provides the contents of this constrained window. | |
| 83 ConstrainedWindowGtkDelegate* delegate_; | |
| 84 | |
| 85 // Stores if |ShowConstrainedWindow()| has been called. | |
| 86 bool visible_; | |
| 87 | |
| 88 ScopedRunnableMethodFactory<ConstrainedWindowGtk> factory_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | |
| 91 }; | |
| 92 | 11 |
| 93 #endif // CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
| OLD | NEW |