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