OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 13 #include "gfx/size.h" |
| 14 #include "views/view.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 |
| 24 namespace gfx { |
| 25 class Point; |
| 26 } // namespace gfx |
| 27 |
| 28 namespace views { |
| 29 class NativeViewHost; |
| 30 } // namespace views |
| 31 |
| 32 // Views-specific implementation of the TabContentsView for the touch UI. |
| 33 class TabContentsViewViews : public TabContentsView, public views::View { |
| 34 public: |
| 35 // The corresponding TabContents is passed in the constructor, and manages our |
| 36 // lifetime. This doesn't need to be the case, but is this way currently |
| 37 // because that's what was easiest when they were split. |
| 38 explicit TabContentsViewViews(TabContents* tab_contents); |
| 39 virtual ~TabContentsViewViews(); |
| 40 |
| 41 // Unlike Windows, ConstrainedWindows need to collaborate with the |
| 42 // TabContentsViewViews to position the dialogs. |
| 43 void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window); |
| 44 void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); |
| 45 |
| 46 // TabContentsView implementation |
| 47 virtual void CreateView(const gfx::Size& initial_size); |
| 48 virtual RenderWidgetHostView* CreateViewForWidget( |
| 49 RenderWidgetHost* render_widget_host); |
| 50 virtual gfx::NativeView GetNativeView() const; |
| 51 virtual gfx::NativeView GetContentNativeView() const; |
| 52 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; |
| 53 virtual void GetContainerBounds(gfx::Rect* out) const; |
| 54 virtual void SetPageTitle(const std::wstring& title); |
| 55 virtual void OnTabCrashed(); |
| 56 virtual void SizeContents(const gfx::Size& size); |
| 57 virtual void Focus(); |
| 58 virtual void SetInitialFocus(); |
| 59 virtual void StoreFocus(); |
| 60 virtual void RestoreFocus(); |
| 61 |
| 62 // views::View implementation |
| 63 virtual void Paint(gfx::Canvas* canvas); |
| 64 |
| 65 // Backend implementation of RenderViewHostDelegate::View. |
| 66 virtual void ShowContextMenu(const ContextMenuParams& params); |
| 67 virtual void ShowPopupMenu(const gfx::Rect& bounds, |
| 68 int item_height, |
| 69 double item_font_size, |
| 70 int selected_item, |
| 71 const std::vector<WebMenuItem>& items, |
| 72 bool right_aligned); |
| 73 virtual void StartDragging(const WebDropData& drop_data, |
| 74 WebKit::WebDragOperationsMask ops_allowed, |
| 75 const SkBitmap& image, |
| 76 const gfx::Point& image_offset); |
| 77 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); |
| 78 virtual void GotFocus(); |
| 79 virtual void TakeFocus(bool reverse); |
| 80 virtual void VisibilityChanged(views::View *, bool is_visible); |
| 81 |
| 82 private: |
| 83 // Signal handlers ----------------------------------------------------------- |
| 84 |
| 85 // Handles notifying the TabContents and other operations when the window was |
| 86 // shown or hidden. |
| 87 void WasHidden(); |
| 88 void WasShown(); |
| 89 |
| 90 // Handles resizing of the contents. This will notify the RenderWidgetHostView |
| 91 // of the change, reposition popups, and the find in page bar. |
| 92 void WasSized(const gfx::Size& size); |
| 93 |
| 94 // For any floating views (ConstrainedDialogs) this function centers them |
| 95 // within this view. It's called whem a ConstrainedDialog is attached and |
| 96 // when this view is resized. |
| 97 void SetFloatingPosition(const gfx::Size& size); |
| 98 |
| 99 // Used to render the sad tab. This will be non-NULL only when the sad tab is |
| 100 // visible. |
| 101 SadTabView* sad_tab_; |
| 102 |
| 103 // Whether to ignore the next CHAR keyboard event. |
| 104 bool ignore_next_char_event_; |
| 105 |
| 106 // The id used in the ViewStorage to store the last focused view. |
| 107 int last_focused_view_storage_id_; |
| 108 |
| 109 // The context menu. Callbacks are asynchronous so we need to keep it around. |
| 110 scoped_ptr<RenderViewContextMenuViews> context_menu_; |
| 111 |
| 112 // Handle drags from this TabContentsView. |
| 113 // TODO(anicolao): figure out what's needed for drag'n'drop |
| 114 |
| 115 // The event for the last mouse down we handled. We need this for drags. |
| 116 GdkEventButton last_mouse_down_; |
| 117 |
| 118 // Current size. See comment in WidgetGtk as to why this is cached. |
| 119 gfx::Size size_; |
| 120 |
| 121 // Each individual UI for constrained dialogs currently displayed. The |
| 122 // objects in this vector are owned by the TabContents, not the view. |
| 123 std::vector<ConstrainedWindowGtk*> constrained_windows_; |
| 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(TabContentsViewViews); |
| 126 }; |
| 127 |
| 128 #endif // CHROME_BROWSER_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
OLD | NEW |