1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
// Copyright (C) 2013 Canonical Ltd.
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#include "oxide_render_widget_host_view.h"
20
#include "base/callback.h"
21
#include "base/logging.h"
22
#include "content/browser/renderer_host/render_widget_host_impl.h"
23
#include "ui/gfx/rect.h"
27
RenderWidgetHostView::RenderWidgetHostView(content::RenderWidgetHost* host) :
28
content::RenderWidgetHostViewBase(),
30
host_(content::RenderWidgetHostImpl::From(host)) {
31
CHECK(host_) << "Implementation didn't supply a RenderWidgetHost";
34
RenderWidgetHostView::~RenderWidgetHostView() {}
36
void RenderWidgetHostView::InitAsPopup(
37
content::RenderWidgetHostView* parent_host_view,
38
const gfx::Rect& pos) {
40
"InitAsPopup() shouldn't be called until "
41
"WebContentsViewPort::CreateViewForPopupWidget() is implemented";
44
void RenderWidgetHostView::InitAsFullscreen(
45
content::RenderWidgetHostView* reference_host_view) {
47
"InitAsFullScreen() shouldn't be called until "
48
"WebContentsViewPort::CreateViewForPopupWidget() is implemented";
51
void RenderWidgetHostView::WasShown() {
58
GetRenderWidgetHostImpl()->WasShown();
61
void RenderWidgetHostView::WasHidden() {
68
GetRenderWidgetHostImpl()->WasHidden();
71
void RenderWidgetHostView::MovePluginWindows(
72
const gfx::Vector2d& scroll_offset,
73
const std::vector<webkit::npapi::WebPluginGeometry>& moves) {}
75
void RenderWidgetHostView::Blur() {}
77
void RenderWidgetHostView::UpdateCursor(const WebCursor& cursor) {}
79
void RenderWidgetHostView::SetIsLoading(bool is_loading) {}
81
void RenderWidgetHostView::TextInputTypeChanged(ui::TextInputType type,
82
bool can_compose_inline,
83
ui::TextInputMode mode) {}
85
void RenderWidgetHostView::ImeCancelComposition() {}
87
void RenderWidgetHostView::ImeCompositionRangeChanged(
88
const ui::Range& range,
89
const std::vector<gfx::Rect>& character_bounds) {}
91
void RenderWidgetHostView::DidUpdateBackingStore(
92
const gfx::Rect& scroll_rect,
93
const gfx::Vector2d& scroll_delta,
94
const std::vector<gfx::Rect>& copy_rects,
95
const ui::LatencyInfo& latency_info) {
100
ScheduleUpdate(scroll_rect);
102
for (size_t i = 0; i < copy_rects.size(); ++i) {
103
gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
104
if (rect.IsEmpty()) {
108
ScheduleUpdate(rect);
112
void RenderWidgetHostView::RenderProcessGone(base::TerminationStatus status,
117
void RenderWidgetHostView::Destroy() {
122
void RenderWidgetHostView::SetTooltipText(const string16& tooltip_text) {}
124
void RenderWidgetHostView::SelectionBoundsChanged(
125
const ViewHostMsg_SelectionBounds_Params& params) {}
127
void RenderWidgetHostView::ScrollOffsetChanged() {}
129
void RenderWidgetHostView::CopyFromCompositingSurface(
130
const gfx::Rect& src_subrect,
131
const gfx::Size& dst_size,
132
const base::Callback<void(bool, const SkBitmap&)>& callback) {
133
GetRenderWidgetHost()->GetSnapshotFromRenderer(src_subrect, callback);
136
void RenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame(
137
const gfx::Rect& src_subrect,
138
const scoped_refptr<media::VideoFrame>& target,
139
const base::Callback<void(bool)>& callback) {
144
bool RenderWidgetHostView::CanCopyToVideoFrame() const {
148
void RenderWidgetHostView::OnAcceleratedCompositingStateChange() {
152
void RenderWidgetHostView::AcceleratedSurfaceBuffersSwapped(
153
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
156
void RenderWidgetHostView::AcceleratedSurfacePostSubBuffer(
157
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
160
void RenderWidgetHostView::AcceleratedSurfaceSuspend() {}
162
void RenderWidgetHostView::AcceleratedSurfaceRelease() {}
164
bool RenderWidgetHostView::HasAcceleratedSurface(
165
const gfx::Size& desired_size) {
169
gfx::GLSurfaceHandle RenderWidgetHostView::GetCompositingSurface() {
171
return gfx::GLSurfaceHandle();
174
void RenderWidgetHostView::SetHasHorizontalScrollbar(
175
bool has_horizontal_scrollbar) {}
177
void RenderWidgetHostView::SetScrollOffsetPinning(bool is_pinned_to_left,
178
bool is_pinned_to_right) {}
180
void RenderWidgetHostView::OnAccessibilityNotifications(
181
const std::vector<AccessibilityHostMsg_NotificationParams>& params) {}
183
void RenderWidgetHostView::InitAsChild(gfx::NativeView parent_view) {}
185
content::RenderWidgetHost* RenderWidgetHostView::GetRenderWidgetHost() const {
189
void RenderWidgetHostView::SetSize(const gfx::Size& size) {
190
if (requested_size_.width() != size.width() ||
191
requested_size_.height() != size.height()) {
192
requested_size_ = size;
194
GetRenderWidgetHostImpl()->SendScreenRects();
195
GetRenderWidgetHost()->WasResized();
199
void RenderWidgetHostView::SetBounds(const gfx::Rect& rect) {
200
SetSize(rect.size());
203
gfx::NativeView RenderWidgetHostView::GetNativeView() const {
207
gfx::NativeViewId RenderWidgetHostView::GetNativeViewId() const {
211
gfx::NativeViewAccessible RenderWidgetHostView::GetNativeViewAccessible() {
215
void RenderWidgetHostView::Focus() {}
217
bool RenderWidgetHostView::IsSurfaceAvailableForCopy() const {
221
bool RenderWidgetHostView::LockMouse() {
225
void RenderWidgetHostView::UnlockMouse() {}
227
void RenderWidgetHostView::OnFocus() {
228
GetRenderWidgetHostImpl()->GotFocus();
229
GetRenderWidgetHost()->SetActive(true);
232
void RenderWidgetHostView::OnBlur() {
233
GetRenderWidgetHost()->SetActive(false);
234
GetRenderWidgetHost()->Blur();