Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / web_contents / web_contents_view.h
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_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "content/common/content_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
16
17 namespace content {
18 class RenderViewHost;
19 class RenderWidgetHost;
20 class RenderWidgetHostViewBase;
21 struct DropData;
22
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() {}
29
30   // Returns the native widget that contains the contents of the tab.
31   virtual gfx::NativeView GetNativeView() const = 0;
32
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;
37
38   // Returns the outermost native view. This will be used as the parent for
39   // dialog boxes.
40   virtual gfx::NativeWindow GetTopLevelNativeWindow() const = 0;
41
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;
45
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.
50   //
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;
55
56   // Sets focus to the native widget for this tab.
57   virtual void Focus() = 0;
58
59   // Sets focus to the appropriate element when the WebContents is shown the
60   // first time.
61   virtual void SetInitialFocus() = 0;
62
63   // Stores the currently focused view.
64   virtual void StoreFocus() = 0;
65
66   // Restores focus to the last focus view. If StoreFocus has not yet been
67   // invoked, SetInitialFocus is invoked.
68   virtual void RestoreFocus() = 0;
69
70   // Returns the current drop data, if any.
71   virtual DropData* GetDropData() const = 0;
72
73   // Get the bounds of the View, relative to the parent.
74   virtual gfx::Rect GetViewBounds() const = 0;
75
76   virtual void CreateView(
77       const gfx::Size& initial_size, gfx::NativeView context) = 0;
78
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.
82   //
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;
89
90   // Creates a new View that holds a popup and receives messages for it.
91   virtual RenderWidgetHostViewBase* CreateViewForPopupWidget(
92       RenderWidgetHost* render_widget_host) = 0;
93
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;
99
100   // Invoked when the WebContents is notified that the RenderView has been
101   // fully created.
102   virtual void RenderViewCreated(RenderViewHost* host) = 0;
103
104   // Invoked when the WebContents is notified that the RenderView has been
105   // swapped in.
106   virtual void RenderViewSwappedIn(RenderViewHost* host) = 0;
107
108   // Invoked to enable/disable overscroll gesture navigation.
109   virtual void SetOverscrollControllerEnabled(bool enabled) = 0;
110
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;
115
116   // Returns true if other views are allowed, false otherwise.
117   virtual bool GetAllowOtherViews() const = 0;
118
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
127 };
128
129 }  // namespace content
130
131 #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_H_