| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "content/browser/tab_contents/tab_contents_view.h" | |
| 13 #include "ui/gfx/size.h" | |
| 14 #include "views/widget/widget_gtk.h" | |
| 15 | |
| 16 class ConstrainedWindowGtk; | |
| 17 typedef struct _GtkFloatingContainer GtkFloatingContainer; | |
| 18 class RenderViewContextMenuViews; | |
| 19 class SadTabView; | |
| 20 class SkBitmap; | |
| 21 class TabContentsDragSource; | |
| 22 class WebDragDestGtk; | |
| 23 namespace gfx { | |
| 24 class Point; | |
| 25 } | |
| 26 namespace views { | |
| 27 class NativeViewHost; | |
| 28 } | |
| 29 | |
| 30 // Gtk-specific implementation of the TabContentsView for the views-based front | |
| 31 // end. It is a WidgetGtk that contains all of the contents of the tab and | |
| 32 // associated child views. | |
| 33 class TabContentsViewGtk : public TabContentsView, | |
| 34 public views::WidgetGtk { | |
| 35 public: | |
| 36 // The corresponding TabContents is passed in the constructor, and manages our | |
| 37 // lifetime. This doesn't need to be the case, but is this way currently | |
| 38 // because that's what was easiest when they were split. | |
| 39 explicit TabContentsViewGtk(TabContents* tab_contents); | |
| 40 virtual ~TabContentsViewGtk(); | |
| 41 | |
| 42 // Unlike Windows, ConstrainedWindows need to collaborate with the | |
| 43 // TabContentsViewGtk to position the dialogs. | |
| 44 void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window); | |
| 45 void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); | |
| 46 | |
| 47 gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event); | |
| 48 | |
| 49 // TabContentsView implementation -------------------------------------------- | |
| 50 | |
| 51 virtual void CreateView(const gfx::Size& initial_size); | |
| 52 virtual RenderWidgetHostView* CreateViewForWidget( | |
| 53 RenderWidgetHost* render_widget_host); | |
| 54 virtual gfx::NativeView GetNativeView() const; | |
| 55 virtual gfx::NativeView GetContentNativeView() const; | |
| 56 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; | |
| 57 virtual void GetContainerBounds(gfx::Rect* out) const; | |
| 58 virtual void SetPageTitle(const std::wstring& title); | |
| 59 virtual void OnTabCrashed(base::TerminationStatus status, | |
| 60 int error_code); | |
| 61 virtual void SizeContents(const gfx::Size& size); | |
| 62 virtual void Focus(); | |
| 63 virtual void SetInitialFocus(); | |
| 64 virtual void StoreFocus(); | |
| 65 virtual void RestoreFocus(); | |
| 66 virtual void GetViewBounds(gfx::Rect* out) const; | |
| 67 | |
| 68 // Backend implementation of RenderViewHostDelegate::View. | |
| 69 virtual void ShowContextMenu(const ContextMenuParams& params); | |
| 70 virtual void ShowPopupMenu(const gfx::Rect& bounds, | |
| 71 int item_height, | |
| 72 double item_font_size, | |
| 73 int selected_item, | |
| 74 const std::vector<WebMenuItem>& items, | |
| 75 bool right_aligned); | |
| 76 virtual void StartDragging(const WebDropData& drop_data, | |
| 77 WebKit::WebDragOperationsMask ops_allowed, | |
| 78 const SkBitmap& image, | |
| 79 const gfx::Point& image_offset); | |
| 80 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); | |
| 81 virtual void GotFocus(); | |
| 82 virtual void TakeFocus(bool reverse); | |
| 83 | |
| 84 private: | |
| 85 // Signal handlers ----------------------------------------------------------- | |
| 86 | |
| 87 // Overridden from views::WidgetGtk: | |
| 88 virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); | |
| 89 virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); | |
| 90 virtual gboolean OnPaint(GtkWidget* widget, GdkEventExpose* event); | |
| 91 virtual void OnShow(GtkWidget* widget); | |
| 92 virtual void OnHide(GtkWidget* widget); | |
| 93 | |
| 94 // Handles notifying the TabContents and other operations when the window was | |
| 95 // shown or hidden. | |
| 96 void WasHidden(); | |
| 97 void WasShown(); | |
| 98 | |
| 99 // Handles resizing of the contents. This will notify the RenderWidgetHostView | |
| 100 // of the change, reposition popups, and the find in page bar. | |
| 101 void WasSized(const gfx::Size& size); | |
| 102 | |
| 103 // For any floating views (ConstrainedDialogs) this function centers them | |
| 104 // within this view. It's called whem a ConstrainedDialog is attached and | |
| 105 // when this view is resized. | |
| 106 void SetFloatingPosition(const gfx::Size& size); | |
| 107 | |
| 108 // --------------------------------------------------------------------------- | |
| 109 | |
| 110 // Used to render the sad tab. This will be non-NULL only when the sad tab is | |
| 111 // visible. | |
| 112 SadTabView* sad_tab_; | |
| 113 | |
| 114 // Whether to ignore the next CHAR keyboard event. | |
| 115 bool ignore_next_char_event_; | |
| 116 | |
| 117 // The id used in the ViewStorage to store the last focused view. | |
| 118 int last_focused_view_storage_id_; | |
| 119 | |
| 120 // The context menu. Callbacks are asynchronous so we need to keep it around. | |
| 121 scoped_ptr<RenderViewContextMenuViews> context_menu_; | |
| 122 | |
| 123 // Handles drags from this TabContentsView. | |
| 124 scoped_ptr<TabContentsDragSource> drag_source_; | |
| 125 | |
| 126 // The event for the last mouse down we handled. We need this for drags. | |
| 127 GdkEventButton last_mouse_down_; | |
| 128 | |
| 129 // The helper object that handles drag destination related interactions with | |
| 130 // GTK. | |
| 131 scoped_ptr<WebDragDestGtk> drag_dest_; | |
| 132 | |
| 133 // Current size. See comment in WidgetGtk as to why this is cached. | |
| 134 gfx::Size size_; | |
| 135 | |
| 136 // Each individual UI for constrained dialogs currently displayed. The | |
| 137 // objects in this vector are owned by the TabContents, not the view. | |
| 138 std::vector<ConstrainedWindowGtk*> constrained_windows_; | |
| 139 | |
| 140 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk); | |
| 141 }; | |
| 142 | |
| 143 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ | |
| OLD | NEW |