Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/tab_contents/tab_contents_view_gtk.h

Issue 10031044: TabContents -> WebContentsImpl, part 5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (fixed) Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
6 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
7 #pragma once
8
9 #include <gtk/gtk.h>
10
11 #include <vector>
12
13 #include "base/memory/scoped_ptr.h"
14 #include "content/browser/tab_contents/tab_contents_view_helper.h"
15 #include "content/common/content_export.h"
16 #include "content/public/browser/web_contents_view.h"
17 #include "ui/base/gtk/focus_store_gtk.h"
18 #include "ui/base/gtk/gtk_signal.h"
19 #include "ui/base/gtk/owned_widget_gtk.h"
20
21 namespace content {
22
23 class WebContentsViewDelegate;
24 class WebDragDestDelegate;
25 class WebDragDestGtk;
26 class WebDragSourceGtk;
27
28 class CONTENT_EXPORT TabContentsViewGtk : public WebContentsView {
29 public:
30 // The corresponding TabContents is passed in the constructor, and manages
31 // our lifetime. This doesn't need to be the case, but is this way currently
32 // because that's what was easiest when they were split. We optionally take
33 // |wrapper| which creates an intermediary widget layer for features from the
34 // Embedding layer that lives with the WebContentsView.
35 TabContentsViewGtk(WebContentsImpl* web_contents,
36 WebContentsViewDelegate* delegate);
37 virtual ~TabContentsViewGtk();
38
39 WebContentsViewDelegate* delegate() const { return delegate_.get(); }
40 WebContents* web_contents();
41
42 // WebContentsView implementation --------------------------------------------
43
44 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
45 virtual content::RenderWidgetHostView* CreateViewForWidget(
46 content::RenderWidgetHost* render_widget_host) OVERRIDE;
47
48 virtual gfx::NativeView GetNativeView() const OVERRIDE;
49 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
50 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
51 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
52 virtual void SetPageTitle(const string16& title) OVERRIDE;
53 virtual void OnTabCrashed(base::TerminationStatus status,
54 int error_code) OVERRIDE;
55 virtual void SizeContents(const gfx::Size& size) OVERRIDE;
56 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE;
57 virtual void Focus() OVERRIDE;
58 virtual void SetInitialFocus() OVERRIDE;
59 virtual void StoreFocus() OVERRIDE;
60 virtual void RestoreFocus() OVERRIDE;
61 virtual bool IsDoingDrag() const OVERRIDE;
62 virtual void CancelDragAndCloseTab() OVERRIDE;
63 virtual bool IsEventTracking() const OVERRIDE;
64 virtual void CloseTabAfterEventTracking() OVERRIDE;
65 virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE;
66
67 // Backend implementation of RenderViewHostDelegate::View.
68 virtual void CreateNewWindow(
69 int route_id,
70 const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
71 virtual void CreateNewWidget(int route_id,
72 WebKit::WebPopupType popup_type) OVERRIDE;
73 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
74 virtual void ShowCreatedWindow(int route_id,
75 WindowOpenDisposition disposition,
76 const gfx::Rect& initial_pos,
77 bool user_gesture) OVERRIDE;
78 virtual void ShowCreatedWidget(int route_id,
79 const gfx::Rect& initial_pos) OVERRIDE;
80 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
81 virtual void ShowContextMenu(
82 const content::ContextMenuParams& params) OVERRIDE;
83 virtual void ShowPopupMenu(const gfx::Rect& bounds,
84 int item_height,
85 double item_font_size,
86 int selected_item,
87 const std::vector<WebMenuItem>& items,
88 bool right_aligned) OVERRIDE;
89 virtual void StartDragging(const WebDropData& drop_data,
90 WebKit::WebDragOperationsMask allowed_ops,
91 const SkBitmap& image,
92 const gfx::Point& image_offset) OVERRIDE;
93 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
94 virtual void GotFocus() OVERRIDE;
95 virtual void TakeFocus(bool reverse) OVERRIDE;
96
97 private:
98 // Insert the given widget into the content area. Should only be used for
99 // web pages and the like (including interstitials and sad tab). Note that
100 // this will be perfectly happy to insert overlapping render views, so care
101 // should be taken that the correct one is hidden/shown.
102 void InsertIntoContentArea(GtkWidget* widget);
103
104 // Handle focus traversal on the render widget native view. Can be overridden
105 // by subclasses.
106 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, gboolean, OnFocus, GtkDirectionType);
107
108 // Used to adjust the size of its children when the size of |expanded_| is
109 // changed.
110 CHROMEGTK_CALLBACK_2(TabContentsViewGtk, void, OnChildSizeRequest,
111 GtkWidget*, GtkRequisition*);
112
113 // Used to propagate the size change of |expanded_| to our RWHV to resize the
114 // renderer content.
115 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSizeAllocate,
116 GtkAllocation*);
117
118 // The WebContentsImpl whose contents we display.
119 WebContentsImpl* tab_contents_;
120
121 // Common implementations of some WebContentsView methods.
122 TabContentsViewHelper tab_contents_view_helper_;
123
124 // This container holds the tab's web page views. It is a GtkExpandedContainer
125 // so that we can control the size of the web pages.
126 ui::OwnedWidgetGtk expanded_;
127
128 ui::FocusStoreGtk focus_store_;
129
130 // The helper object that handles drag destination related interactions with
131 // GTK.
132 scoped_ptr<WebDragDestGtk> drag_dest_;
133
134 // Object responsible for handling drags from the page for us.
135 scoped_ptr<WebDragSourceGtk> drag_source_;
136
137 // Our optional views wrapper. If non-NULL, we return this widget as our
138 // GetNativeView() and insert |expanded_| as its child in the GtkWidget
139 // hierarchy.
140 scoped_ptr<WebContentsViewDelegate> delegate_;
141
142 // The size we want the tab contents view to be. We keep this in a separate
143 // variable because resizing in GTK+ is async.
144 gfx::Size requested_size_;
145
146 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
147 };
148
149 } // namespace content
150
151 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698