Update broken references to image assets
[chromium-blink-merge.git] / content / public / browser / render_widget_host_view.h
blobd503fa9db67e32353e9932062ca3125609789823
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_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "content/common/content_export.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkColor.h"
14 #include "third_party/skia/include/core/SkRegion.h"
15 #include "third_party/WebKit/public/web/WebInputEvent.h"
16 #include "ui/gfx/native_widget_types.h"
18 class GURL;
20 namespace gfx {
21 class Rect;
22 class Size;
25 namespace ui {
26 class TextInputClient;
29 namespace content {
31 class RenderWidgetHost;
32 class RenderWidgetHostViewFrameSubscriber;
34 // RenderWidgetHostView is an interface implemented by an object that acts as
35 // the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
36 // associated RenderProcessHost own the "Model" in this case which is the
37 // child renderer process. The View is responsible for receiving events from
38 // the surrounding environment and passing them to the RenderWidgetHost, and
39 // for actually displaying the content of the RenderWidgetHost when it
40 // changes.
42 // RenderWidgetHostView Class Hierarchy:
43 // RenderWidgetHostView - Public interface.
44 // RenderWidgetHostViewBase - Common implementation between platforms.
45 // RenderWidgetHostViewAura, ... - Platform specific implementations.
46 class CONTENT_EXPORT RenderWidgetHostView {
47 public:
48 virtual ~RenderWidgetHostView() {}
50 // Initialize this object for use as a drawing area. |parent_view| may be
51 // left as nullptr on platforms where a parent view is not required to
52 // initialize a child window.
53 virtual void InitAsChild(gfx::NativeView parent_view) = 0;
55 // Returns the associated RenderWidgetHost.
56 virtual RenderWidgetHost* GetRenderWidgetHost() const = 0;
58 // Tells the View to size itself to the specified size.
59 virtual void SetSize(const gfx::Size& size) = 0;
61 // Tells the View to size and move itself to the specified size and point in
62 // screen space.
63 virtual void SetBounds(const gfx::Rect& rect) = 0;
65 // Retrieves the last known scroll position.
66 virtual gfx::Vector2dF GetLastScrollOffset() const = 0;
68 // Retrieves the native view used to contain plugins and identify the
69 // renderer in IPC messages.
70 virtual gfx::NativeView GetNativeView() const = 0;
71 virtual gfx::NativeViewId GetNativeViewId() const = 0;
72 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0;
74 // Returns a ui::TextInputClient to support text input or nullptr if this RWHV
75 // doesn't support text input.
76 // Note: Not all the platforms use ui::InputMethod and ui::TextInputClient for
77 // text input. Some platforms (Mac and Android for example) use their own
78 // text input system.
79 virtual ui::TextInputClient* GetTextInputClient() = 0;
81 // Set focus to the associated View component.
82 virtual void Focus() = 0;
83 // Returns true if the View currently has the focus.
84 virtual bool HasFocus() const = 0;
85 // Returns true is the current display surface is available.
86 virtual bool IsSurfaceAvailableForCopy() const = 0;
88 // Shows/hides the view. These must always be called together in pairs.
89 // It is not legal to call Hide() multiple times in a row.
90 virtual void Show() = 0;
91 virtual void Hide() = 0;
93 // Whether the view is showing.
94 virtual bool IsShowing() = 0;
96 // Indicates if the view is currently occluded (e.g, not visible because it's
97 // covered up by other windows), and as a result the view's renderer may be
98 // suspended. If Show() is called on a view then its state should be re-set to
99 // being un-occluded (an explicit WasUnOccluded call will not be made for
100 // that). These calls are not necessarily made in pairs.
101 virtual void WasUnOccluded() = 0;
102 virtual void WasOccluded() = 0;
104 // Retrieve the bounds of the View, in screen coordinates.
105 virtual gfx::Rect GetViewBounds() const = 0;
107 // Returns true if the View's context menu is showing.
108 virtual bool IsShowingContextMenu() const = 0;
110 // Tells the View whether the context menu is showing.
111 virtual void SetShowingContextMenu(bool showing) = 0;
113 // Returns the currently selected text.
114 virtual base::string16 GetSelectedText() const = 0;
116 // Subclasses should override this method to set the background color. |color|
117 // could be transparent or opaque.
118 virtual void SetBackgroundColor(SkColor color) = 0;
119 // Convenience method to fill the background layer with the default color by
120 // calling |SetBackgroundColor|.
121 virtual void SetBackgroundColorToDefault() = 0;
122 virtual bool GetBackgroundOpaque() = 0;
124 // Return value indicates whether the mouse is locked successfully or not.
125 virtual bool LockMouse() = 0;
126 virtual void UnlockMouse() = 0;
127 // Returns true if the mouse pointer is currently locked.
128 virtual bool IsMouseLocked() = 0;
130 // Retrives the size of the viewport for the visible region. May be smaller
131 // than the view size if a portion of the view is obstructed (e.g. by a
132 // virtual keyboard).
133 virtual gfx::Size GetVisibleViewportSize() const = 0;
135 // Set insets for the visible region of the root window. Used to compute the
136 // visible viewport.
137 virtual void SetInsets(const gfx::Insets& insets) = 0;
139 // Begin subscribing for presentation events and captured frames.
140 // |subscriber| is now owned by this object, it will be called only on the
141 // UI thread.
142 virtual void BeginFrameSubscription(
143 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) = 0;
145 // End subscribing for frame presentation events. FrameSubscriber will be
146 // deleted after this call.
147 virtual void EndFrameSubscription() = 0;
149 #if defined(OS_MACOSX)
150 // Set the view's active state (i.e., tint state of controls).
151 virtual void SetActive(bool active) = 0;
153 // Notifies the view that its enclosing window has changed visibility
154 // (minimized/unminimized, app hidden/unhidden, etc).
155 // TODO(stuartmorgan): This is a temporary plugin-specific workaround for
156 // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding
157 // message and renderer-side handling) can be removed in favor of using
158 // WasHidden/WasShown.
159 virtual void SetWindowVisibility(bool visible) = 0;
161 // Informs the view that its containing window's frame changed.
162 virtual void WindowFrameChanged() = 0;
164 // Brings up the dictionary showing a definition for the selected text.
165 virtual void ShowDefinitionForSelection() = 0;
167 // Returns |true| if Mac OS X text to speech is supported.
168 virtual bool SupportsSpeech() const = 0;
169 // Tells the view to speak the currently selected text.
170 virtual void SpeakSelection() = 0;
171 // Returns |true| if text is currently being spoken by Mac OS X.
172 virtual bool IsSpeaking() const = 0;
173 // Stops speaking, if it is currently in progress.
174 virtual void StopSpeaking() = 0;
175 #endif // defined(OS_MACOSX)
178 } // namespace content
180 #endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_