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

Side by Side Diff: content/browser/web_contents/web_contents_view_gtk.h

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 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_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include <vector>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/content_export.h"
14 #include "content/common/drag_event_source_info.h"
15 #include "content/port/browser/render_view_host_delegate_view.h"
16 #include "content/port/browser/web_contents_view_port.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 WebContents;
24 class WebContentsImpl;
25 class WebContentsViewDelegate;
26 class WebDragDestDelegate;
27 class WebDragDestGtk;
28 class WebDragSourceGtk;
29
30 class CONTENT_EXPORT WebContentsViewGtk
31 : public WebContentsViewPort,
32 public RenderViewHostDelegateView {
33 public:
34 // The corresponding WebContentsImpl is passed in the constructor, and manages
35 // our lifetime. This doesn't need to be the case, but is this way currently
36 // because that's what was easiest when they were split. We optionally take
37 // |wrapper| which creates an intermediary widget layer for features from the
38 // Embedding layer that lives with the WebContentsView.
39 WebContentsViewGtk(WebContentsImpl* web_contents,
40 WebContentsViewDelegate* delegate);
41 virtual ~WebContentsViewGtk();
42
43 WebContentsViewDelegate* delegate() const { return delegate_.get(); }
44 WebContents* web_contents();
45
46 // WebContentsView implementation --------------------------------------------
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 OnTabCrashed(base::TerminationStatus status,
53 int error_code) OVERRIDE;
54 virtual void SizeContents(const gfx::Size& size) OVERRIDE;
55 virtual void Focus() OVERRIDE;
56 virtual void SetInitialFocus() OVERRIDE;
57 virtual void StoreFocus() OVERRIDE;
58 virtual void RestoreFocus() OVERRIDE;
59 virtual DropData* GetDropData() const OVERRIDE;
60 virtual gfx::Rect GetViewBounds() const OVERRIDE;
61
62 // WebContentsViewPort implementation ----------------------------------------
63 virtual void CreateView(
64 const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
65 virtual RenderWidgetHostView* CreateViewForWidget(
66 RenderWidgetHost* render_widget_host) OVERRIDE;
67 virtual RenderWidgetHostView* CreateViewForPopupWidget(
68 RenderWidgetHost* render_widget_host) OVERRIDE;
69 virtual void SetPageTitle(const base::string16& title) OVERRIDE;
70 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
71 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE;
72 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE;
73
74 // Backend implementation of RenderViewHostDelegateView.
75 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
76 const ContextMenuParams& params) OVERRIDE;
77 virtual void StartDragging(const DropData& drop_data,
78 blink::WebDragOperationsMask allowed_ops,
79 const gfx::ImageSkia& image,
80 const gfx::Vector2d& image_offset,
81 const DragEventSourceInfo& event_info) OVERRIDE;
82 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE;
83 virtual void GotFocus() OVERRIDE;
84 virtual void TakeFocus(bool reverse) OVERRIDE;
85
86 private:
87 // Insert the given widget into the content area. Should only be used for
88 // web pages and the like (including interstitials and sad tab). Note that
89 // this will be perfectly happy to insert overlapping render views, so care
90 // should be taken that the correct one is hidden/shown.
91 void InsertIntoContentArea(GtkWidget* widget);
92
93 // Replaces, or updates, the existing WebDragDestGtk with one for |new_host|.
94 // This must be called when swapping in, or creating a swapped in, RVH.
95 void UpdateDragDest(RenderViewHost* new_host);
96
97 // Handle focus traversal on the render widget native view. Can be overridden
98 // by subclasses.
99 CHROMEGTK_CALLBACK_1(WebContentsViewGtk, gboolean, OnFocus, GtkDirectionType);
100
101 // Used to adjust the size of its children when the size of |expanded_| is
102 // changed.
103 CHROMEGTK_CALLBACK_2(WebContentsViewGtk, void, OnChildSizeRequest,
104 GtkWidget*, GtkRequisition*);
105
106 // Used to propagate the size change of |expanded_| to our RWHV to resize the
107 // renderer content.
108 CHROMEGTK_CALLBACK_1(WebContentsViewGtk, void, OnSizeAllocate,
109 GtkAllocation*);
110
111 // The WebContentsImpl whose contents we display.
112 WebContentsImpl* web_contents_;
113
114 // This container holds the tab's web page views. It is a GtkExpandedContainer
115 // so that we can control the size of the web pages.
116 ui::OwnedWidgetGtk expanded_;
117
118 ui::FocusStoreGtk focus_store_;
119
120 // The helper object that handles drag destination related interactions with
121 // GTK.
122 scoped_ptr<WebDragDestGtk> drag_dest_;
123
124 // Object responsible for handling drags from the page for us.
125 scoped_ptr<WebDragSourceGtk> drag_source_;
126
127 // Our optional views wrapper. If non-NULL, we return this widget as our
128 // GetNativeView() and insert |expanded_| as its child in the GtkWidget
129 // hierarchy.
130 scoped_ptr<WebContentsViewDelegate> delegate_;
131
132 // The size we want the view to be. We keep this in a separate variable
133 // because resizing in GTK+ is async.
134 gfx::Size requested_size_;
135
136 DISALLOW_COPY_AND_ASSIGN(WebContentsViewGtk);
137 };
138
139 } // namespace content
140
141 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698