render_widget_host_view.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
19258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org// Copyright (c) 2012 The Chromium Authors. All rights reserved.
29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Use of this source code is governed by a BSD-style license that can be
39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// found in the LICENSE file.
49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_
69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_
79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "base/basictypes.h"
99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "base/memory/scoped_ptr.h"
109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "base/strings/string16.h"
119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "content/common/content_export.h"
129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "third_party/skia/include/core/SkBitmap.h"
139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "third_party/skia/include/core/SkRegion.h"
149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "third_party/WebKit/public/web/WebInputEvent.h"
159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include "ui/gfx/native_widget_types.h"
169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass GURL;
189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comnamespace gfx {
209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass Rect;
219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass Size;
229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com}
239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comnamespace ui {
259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass TextInputClient;
269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com}
279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comnamespace content {
299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass RenderWidgetHost;
319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass RenderWidgetHostViewFrameSubscriber;
32245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org
33245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// RenderWidgetHostView is an interface implemented by an object that acts as
34245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
35245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// associated RenderProcessHost own the "Model" in this case which is the
36245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// child renderer process. The View is responsible for receiving events from
37245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// the surrounding environment and passing them to the RenderWidgetHost, and
38245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// for actually displaying the content of the RenderWidgetHost when it
39245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// changes.
40245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org//
41245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org// RenderWidgetHostView Class Hierarchy:
429258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org//   RenderWidgetHostView - Public interface.
439258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org//   RenderWidgetHostViewBase - Common implementation between platforms.
449258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org//   RenderWidgetHostViewAura, ... - Platform specific implementations.
459258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.orgclass CONTENT_EXPORT RenderWidgetHostView {
46245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org public:
47245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org  virtual ~RenderWidgetHostView() {}
48245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org
499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // Initialize this object for use as a drawing area.  |parent_view| may be
509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // left as NULL on platforms where a parent view is not required to initialize
519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // a child window.
529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual void InitAsChild(gfx::NativeView parent_view) = 0;
539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // Returns the associated RenderWidgetHost.
559258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org  virtual RenderWidgetHost* GetRenderWidgetHost() const = 0;
56245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org
579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // Tells the View to size itself to the specified size.
589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual void SetSize(const gfx::Size& size) = 0;
599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com
609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // Tells the View to size and move itself to the specified size and point in
619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // screen space.
629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual void SetBounds(const gfx::Rect& rect) = 0;
63245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org
649258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org  // Retrieves the native view used to contain plugins and identify the
659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // renderer in IPC messages.
669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual gfx::NativeView GetNativeView() const = 0;
679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual gfx::NativeViewId GetNativeViewId() const = 0;
689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0;
69245aa859d34fd516161c48ef4c69d38d9b889284iposva@chromium.org
709258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org  // Returns a ui::TextInputClient to support text input or NULL if this RWHV
719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // doesn't support text input.
729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // Note: Not all the platforms use ui::InputMethod and ui::TextInputClient for
739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // text input.  Some platforms (Mac and Android for example) use their own
749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  // text input system.
759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com  virtual ui::TextInputClient* GetTextInputClient() = 0;
76
77  // Set focus to the associated View component.
78  virtual void Focus() = 0;
79  // Returns true if the View currently has the focus.
80  virtual bool HasFocus() const = 0;
81  // Returns true is the current display surface is available.
82  virtual bool IsSurfaceAvailableForCopy() const = 0;
83
84  // Shows/hides the view.  These must always be called together in pairs.
85  // It is not legal to call Hide() multiple times in a row.
86  virtual void Show() = 0;
87  virtual void Hide() = 0;
88
89  // Whether the view is showing.
90  virtual bool IsShowing() = 0;
91
92  // Retrieve the bounds of the View, in screen coordinates.
93  virtual gfx::Rect GetViewBounds() const = 0;
94
95  // Returns true if the View's context menu is showing.
96  virtual bool IsShowingContextMenu() const = 0;
97
98  // Tells the View whether the context menu is showing.
99  virtual void SetShowingContextMenu(bool showing) = 0;
100
101  // Returns the currently selected text.
102  virtual base::string16 GetSelectedText() const = 0;
103
104  // Subclasses should override this method to do what is appropriate to set
105  // the background to be transparent or opaque.
106  virtual void SetBackgroundOpaque(bool opaque) = 0;
107  virtual bool GetBackgroundOpaque() = 0;
108
109  // Return value indicates whether the mouse is locked successfully or not.
110  virtual bool LockMouse() = 0;
111  virtual void UnlockMouse() = 0;
112  // Returns true if the mouse pointer is currently locked.
113  virtual bool IsMouseLocked() = 0;
114
115  // Retrives the size of the viewport for the visible region. May be smaller
116  // than the view size if a portion of the view is obstructed (e.g. by a
117  // virtual keyboard).
118  virtual gfx::Size GetVisibleViewportSize() const = 0;
119
120  // Set insets for the visible region of the root window. Used to compute the
121  // visible viewport.
122  virtual void SetInsets(const gfx::Insets& insets) = 0;
123
124  // Begin subscribing for presentation events and captured frames.
125  // |subscriber| is now owned by this object, it will be called only on the
126  // UI thread.
127  virtual void BeginFrameSubscription(
128      scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) = 0;
129
130  // End subscribing for frame presentation events. FrameSubscriber will be
131  // deleted after this call.
132  virtual void EndFrameSubscription() = 0;
133
134#if defined(OS_MACOSX)
135  // Set the view's active state (i.e., tint state of controls).
136  virtual void SetActive(bool active) = 0;
137
138  // Tells the view whether or not to accept first responder status.  If |flag|
139  // is true, the view does not accept first responder status and instead
140  // manually becomes first responder when it receives a mouse down event.  If
141  // |flag| is false, the view participates in the key-view chain as normal.
142  virtual void SetTakesFocusOnlyOnMouseDown(bool flag) = 0;
143
144  // Notifies the view that its enclosing window has changed visibility
145  // (minimized/unminimized, app hidden/unhidden, etc).
146  // TODO(stuartmorgan): This is a temporary plugin-specific workaround for
147  // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding
148  // message and renderer-side handling) can be removed in favor of using
149  // WasHidden/WasShown.
150  virtual void SetWindowVisibility(bool visible) = 0;
151
152  // Informs the view that its containing window's frame changed.
153  virtual void WindowFrameChanged() = 0;
154
155  // Brings up the dictionary showing a definition for the selected text.
156  virtual void ShowDefinitionForSelection() = 0;
157
158  // Returns |true| if Mac OS X text to speech is supported.
159  virtual bool SupportsSpeech() const = 0;
160  // Tells the view to speak the currently selected text.
161  virtual void SpeakSelection() = 0;
162  // Returns |true| if text is currently being spoken by Mac OS X.
163  virtual bool IsSpeaking() const = 0;
164  // Stops speaking, if it is currently in progress.
165  virtual void StopSpeaking() = 0;
166#endif  // defined(OS_MACOSX)
167};
168
169}  // namespace content
170
171#endif  // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_
172