Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_view_gtk.h
blob4a456fcf0b23b66cbee3b804376e4894cd89166f
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.
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_
8 #include <gtk/gtk.h>
10 #include <vector>
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"
21 namespace content {
23 class WebContents;
24 class WebContentsImpl;
25 class WebContentsViewDelegate;
26 class WebDragDestDelegate;
27 class WebDragDestGtk;
28 class WebDragSourceGtk;
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();
43 WebContentsViewDelegate* delegate() const { return delegate_.get(); }
44 WebContents* web_contents();
46 // WebContentsView implementation --------------------------------------------
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;
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 string16& title) OVERRIDE;
70 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
71 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE;
72 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE;
74 // Backend implementation of RenderViewHostDelegateView.
75 virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
76 virtual void ShowPopupMenu(const gfx::Rect& bounds,
77 int item_height,
78 double item_font_size,
79 int selected_item,
80 const std::vector<MenuItem>& items,
81 bool right_aligned,
82 bool allow_multiple_selection) OVERRIDE;
83 virtual void StartDragging(const DropData& drop_data,
84 WebKit::WebDragOperationsMask allowed_ops,
85 const gfx::ImageSkia& image,
86 const gfx::Vector2d& image_offset,
87 const DragEventSourceInfo& event_info) OVERRIDE;
88 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
89 virtual void GotFocus() OVERRIDE;
90 virtual void TakeFocus(bool reverse) OVERRIDE;
92 private:
93 // Insert the given widget into the content area. Should only be used for
94 // web pages and the like (including interstitials and sad tab). Note that
95 // this will be perfectly happy to insert overlapping render views, so care
96 // should be taken that the correct one is hidden/shown.
97 void InsertIntoContentArea(GtkWidget* widget);
99 // Replaces, or updates, the existing WebDragDestGtk with one for |new_host|.
100 // This must be called when swapping in, or creating a swapped in, RVH.
101 void UpdateDragDest(RenderViewHost* new_host);
103 // Handle focus traversal on the render widget native view. Can be overridden
104 // by subclasses.
105 CHROMEGTK_CALLBACK_1(WebContentsViewGtk, gboolean, OnFocus, GtkDirectionType);
107 // Used to adjust the size of its children when the size of |expanded_| is
108 // changed.
109 CHROMEGTK_CALLBACK_2(WebContentsViewGtk, void, OnChildSizeRequest,
110 GtkWidget*, GtkRequisition*);
112 // Used to propagate the size change of |expanded_| to our RWHV to resize the
113 // renderer content.
114 CHROMEGTK_CALLBACK_1(WebContentsViewGtk, void, OnSizeAllocate,
115 GtkAllocation*);
117 // The WebContentsImpl whose contents we display.
118 WebContentsImpl* web_contents_;
120 // This container holds the tab's web page views. It is a GtkExpandedContainer
121 // so that we can control the size of the web pages.
122 ui::OwnedWidgetGtk expanded_;
124 ui::FocusStoreGtk focus_store_;
126 // The helper object that handles drag destination related interactions with
127 // GTK.
128 scoped_ptr<WebDragDestGtk> drag_dest_;
130 // Object responsible for handling drags from the page for us.
131 scoped_ptr<WebDragSourceGtk> drag_source_;
133 // Our optional views wrapper. If non-NULL, we return this widget as our
134 // GetNativeView() and insert |expanded_| as its child in the GtkWidget
135 // hierarchy.
136 scoped_ptr<WebContentsViewDelegate> delegate_;
138 // The size we want the view to be. We keep this in a separate variable
139 // because resizing in GTK+ is async.
140 gfx::Size requested_size_;
142 DISALLOW_COPY_AND_ASSIGN(WebContentsViewGtk);
145 } // namespace content
147 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GTK_H_