Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_view.h
blob439dda4fbcfc7d7c905008f63404d1bea5a75865
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_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "content/common/content_export.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/native_widget_types.h"
17 namespace content {
18 class RenderViewHost;
19 class RenderWidgetHost;
20 class RenderWidgetHostViewBase;
21 struct DropData;
23 // The WebContentsView is an interface that is implemented by the platform-
24 // dependent web contents views. The WebContents uses this interface to talk to
25 // them.
26 class WebContentsView {
27 public:
28 virtual ~WebContentsView() {}
30 // Returns the native widget that contains the contents of the tab.
31 virtual gfx::NativeView GetNativeView() const = 0;
33 // Returns the native widget with the main content of the tab (i.e. the main
34 // render view host, though there may be many popups in the tab as children of
35 // the container).
36 virtual gfx::NativeView GetContentNativeView() const = 0;
38 // Returns the outermost native view. This will be used as the parent for
39 // dialog boxes.
40 virtual gfx::NativeWindow GetTopLevelNativeWindow() const = 0;
42 // Computes the rectangle for the native widget that contains the contents of
43 // the tab in the screen coordinate system.
44 virtual void GetContainerBounds(gfx::Rect* out) const = 0;
46 // TODO(brettw) this is a hack. It's used in two places at the time of this
47 // writing: (1) when render view hosts switch, we need to size the replaced
48 // one to be correct, since it wouldn't have known about sizes that happened
49 // while it was hidden; (2) in constrained windows.
51 // (1) will be fixed once interstitials are cleaned up. (2) seems like it
52 // should be cleaned up or done some other way, since this works for normal
53 // WebContents without the special code.
54 virtual void SizeContents(const gfx::Size& size) = 0;
56 // Sets focus to the native widget for this tab.
57 virtual void Focus() = 0;
59 // Sets focus to the appropriate element when the WebContents is shown the
60 // first time.
61 virtual void SetInitialFocus() = 0;
63 // Stores the currently focused view.
64 virtual void StoreFocus() = 0;
66 // Restores focus to the last focus view. If StoreFocus has not yet been
67 // invoked, SetInitialFocus is invoked.
68 virtual void RestoreFocus() = 0;
70 // Returns the current drop data, if any.
71 virtual DropData* GetDropData() const = 0;
73 // Get the bounds of the View, relative to the parent.
74 virtual gfx::Rect GetViewBounds() const = 0;
76 virtual void CreateView(
77 const gfx::Size& initial_size, gfx::NativeView context) = 0;
79 // Sets up the View that holds the rendered web page, receives messages for
80 // it and contains page plugins. The host view should be sized to the current
81 // size of the WebContents.
83 // |is_guest_view_hack| is temporary hack and will be removed once
84 // RenderWidgetHostViewGuest is not dependent on platform view.
85 // TODO(lazyboy): Remove |is_guest_view_hack| once http://crbug.com/330264 is
86 // fixed.
87 virtual RenderWidgetHostViewBase* CreateViewForWidget(
88 RenderWidgetHost* render_widget_host, bool is_guest_view_hack) = 0;
90 // Creates a new View that holds a popup and receives messages for it.
91 virtual RenderWidgetHostViewBase* CreateViewForPopupWidget(
92 RenderWidgetHost* render_widget_host) = 0;
94 // Sets the page title for the native widgets corresponding to the view. This
95 // is not strictly necessary and isn't expected to be displayed anywhere, but
96 // can aid certain debugging tools such as Spy++ on Windows where you are
97 // trying to find a specific window.
98 virtual void SetPageTitle(const base::string16& title) = 0;
100 // Invoked when the WebContents is notified that the RenderView has been
101 // fully created.
102 virtual void RenderViewCreated(RenderViewHost* host) = 0;
104 // Invoked when the WebContents is notified that the RenderView has been
105 // swapped in.
106 virtual void RenderViewSwappedIn(RenderViewHost* host) = 0;
108 // Invoked to enable/disable overscroll gesture navigation.
109 virtual void SetOverscrollControllerEnabled(bool enabled) = 0;
111 #if defined(OS_MACOSX)
112 // Allowing other views disables optimizations which assume that only a single
113 // WebContents is present.
114 virtual void SetAllowOtherViews(bool allow) = 0;
116 // Returns true if other views are allowed, false otherwise.
117 virtual bool GetAllowOtherViews() const = 0;
119 // If we close the tab while a UI control is in an event-tracking
120 // loop, the control may message freed objects and crash.
121 // WebContents::Close() calls IsEventTracking(), and if it returns
122 // true CloseTabAfterEventTracking() is called and the close is not
123 // completed.
124 virtual bool IsEventTracking() const = 0;
125 virtual void CloseTabAfterEventTracking() = 0;
126 #endif
129 } // namespace content
131 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_