~oxide-developers/oxide/1.2

« back to all changes in this revision

Viewing changes to oxide/browser/oxide_render_widget_host_view.cc

  • Committer: Chris Coulson
  • Date: 2013-07-23 11:40:24 UTC
  • Revision ID: chris.coulson@canonical.com-20130723114024-p7z00cs9p0s5te6e
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim:expandtab:shiftwidth=2:tabstop=2:
 
2
// Copyright (C) 2013 Canonical Ltd.
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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
 
17
 
 
18
#include "oxide_render_widget_host_view.h"
 
19
 
 
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"
 
24
 
 
25
namespace oxide {
 
26
 
 
27
RenderWidgetHostView::RenderWidgetHostView(content::RenderWidgetHost* host) :
 
28
    content::RenderWidgetHostViewBase(),
 
29
    is_hidden_(false),
 
30
    host_(content::RenderWidgetHostImpl::From(host)) {
 
31
  CHECK(host_) << "Implementation didn't supply a RenderWidgetHost";
 
32
}
 
33
 
 
34
RenderWidgetHostView::~RenderWidgetHostView() {}
 
35
 
 
36
void RenderWidgetHostView::InitAsPopup(
 
37
    content::RenderWidgetHostView* parent_host_view,
 
38
    const gfx::Rect& pos) {
 
39
  NOTIMPLEMENTED() <<
 
40
      "InitAsPopup() shouldn't be called until "
 
41
      "WebContentsViewPort::CreateViewForPopupWidget() is implemented";
 
42
}
 
43
 
 
44
void RenderWidgetHostView::InitAsFullscreen(
 
45
    content::RenderWidgetHostView* reference_host_view) {
 
46
  NOTIMPLEMENTED() <<
 
47
      "InitAsFullScreen() shouldn't be called until "
 
48
      "WebContentsViewPort::CreateViewForPopupWidget() is implemented";
 
49
}
 
50
 
 
51
void RenderWidgetHostView::WasShown() {
 
52
  if (!is_hidden_) {
 
53
    return;
 
54
  }
 
55
 
 
56
  is_hidden_ = false;
 
57
 
 
58
  GetRenderWidgetHostImpl()->WasShown();
 
59
}
 
60
 
 
61
void RenderWidgetHostView::WasHidden() {
 
62
  if (is_hidden_) {
 
63
    return;
 
64
  }
 
65
 
 
66
  is_hidden_ = true;
 
67
 
 
68
  GetRenderWidgetHostImpl()->WasHidden();
 
69
}
 
70
 
 
71
void RenderWidgetHostView::MovePluginWindows(
 
72
    const gfx::Vector2d& scroll_offset,
 
73
    const std::vector<webkit::npapi::WebPluginGeometry>& moves) {}
 
74
 
 
75
void RenderWidgetHostView::Blur() {}
 
76
 
 
77
void RenderWidgetHostView::UpdateCursor(const WebCursor& cursor) {}
 
78
 
 
79
void RenderWidgetHostView::SetIsLoading(bool is_loading) {}
 
80
 
 
81
void RenderWidgetHostView::TextInputTypeChanged(ui::TextInputType type,
 
82
                                                bool can_compose_inline,
 
83
                                                ui::TextInputMode mode) {}
 
84
 
 
85
void RenderWidgetHostView::ImeCancelComposition() {}
 
86
 
 
87
void RenderWidgetHostView::ImeCompositionRangeChanged(
 
88
    const ui::Range& range,
 
89
    const std::vector<gfx::Rect>& character_bounds) {}
 
90
 
 
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) {
 
96
  if (is_hidden_) {
 
97
    return;
 
98
  }
 
99
 
 
100
  ScheduleUpdate(scroll_rect);
 
101
 
 
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()) {
 
105
      continue;
 
106
    }
 
107
 
 
108
    ScheduleUpdate(rect);
 
109
  }
 
110
}
 
111
 
 
112
void RenderWidgetHostView::RenderProcessGone(base::TerminationStatus status,
 
113
                                             int error_code) {
 
114
  Destroy();
 
115
}
 
116
 
 
117
void RenderWidgetHostView::Destroy() {
 
118
  host_ = NULL;
 
119
  delete this;
 
120
}
 
121
 
 
122
void RenderWidgetHostView::SetTooltipText(const string16& tooltip_text) {}
 
123
 
 
124
void RenderWidgetHostView::SelectionBoundsChanged(
 
125
    const ViewHostMsg_SelectionBounds_Params& params) {}
 
126
 
 
127
void RenderWidgetHostView::ScrollOffsetChanged() {}
 
128
 
 
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);
 
134
}
 
135
 
 
136
void RenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame(
 
137
    const gfx::Rect& src_subrect,
 
138
    const scoped_refptr<media::VideoFrame>& target,
 
139
    const base::Callback<void(bool)>& callback) {
 
140
  NOTIMPLEMENTED();
 
141
  callback.Run(false);
 
142
}
 
143
 
 
144
bool RenderWidgetHostView::CanCopyToVideoFrame() const {
 
145
  return false;
 
146
}
 
147
 
 
148
void RenderWidgetHostView::OnAcceleratedCompositingStateChange() {
 
149
 
 
150
}
 
151
 
 
152
void RenderWidgetHostView::AcceleratedSurfaceBuffersSwapped(
 
153
    const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
 
154
    int gpu_host_id) {}
 
155
 
 
156
void RenderWidgetHostView::AcceleratedSurfacePostSubBuffer(
 
157
      const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
 
158
      int gpu_host_id) {}
 
159
 
 
160
void RenderWidgetHostView::AcceleratedSurfaceSuspend() {}
 
161
 
 
162
void RenderWidgetHostView::AcceleratedSurfaceRelease() {}
 
163
 
 
164
bool RenderWidgetHostView::HasAcceleratedSurface(
 
165
    const gfx::Size& desired_size) {
 
166
  return false;
 
167
}
 
168
 
 
169
gfx::GLSurfaceHandle RenderWidgetHostView::GetCompositingSurface() {
 
170
  NOTIMPLEMENTED();
 
171
  return gfx::GLSurfaceHandle();
 
172
}
 
173
 
 
174
void RenderWidgetHostView::SetHasHorizontalScrollbar(
 
175
    bool has_horizontal_scrollbar) {}
 
176
 
 
177
void RenderWidgetHostView::SetScrollOffsetPinning(bool is_pinned_to_left,
 
178
                                                  bool is_pinned_to_right) {}
 
179
 
 
180
void RenderWidgetHostView::OnAccessibilityNotifications(
 
181
    const std::vector<AccessibilityHostMsg_NotificationParams>& params) {}
 
182
 
 
183
void RenderWidgetHostView::InitAsChild(gfx::NativeView parent_view) {}
 
184
 
 
185
content::RenderWidgetHost* RenderWidgetHostView::GetRenderWidgetHost() const {
 
186
  return host_;
 
187
}
 
188
 
 
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;
 
193
 
 
194
    GetRenderWidgetHostImpl()->SendScreenRects();
 
195
    GetRenderWidgetHost()->WasResized();
 
196
  }
 
197
}
 
198
 
 
199
void RenderWidgetHostView::SetBounds(const gfx::Rect& rect) {
 
200
  SetSize(rect.size());
 
201
}
 
202
 
 
203
gfx::NativeView RenderWidgetHostView::GetNativeView() const {
 
204
  return NULL;
 
205
}
 
206
 
 
207
gfx::NativeViewId RenderWidgetHostView::GetNativeViewId() const {
 
208
  return 0;
 
209
}
 
210
 
 
211
gfx::NativeViewAccessible RenderWidgetHostView::GetNativeViewAccessible() {
 
212
  return NULL;
 
213
}
 
214
 
 
215
void RenderWidgetHostView::Focus() {}
 
216
 
 
217
bool RenderWidgetHostView::IsSurfaceAvailableForCopy() const {
 
218
  return true;
 
219
}
 
220
 
 
221
bool RenderWidgetHostView::LockMouse() {
 
222
  return false;
 
223
}
 
224
 
 
225
void RenderWidgetHostView::UnlockMouse() {}
 
226
 
 
227
void RenderWidgetHostView::OnFocus() {
 
228
  GetRenderWidgetHostImpl()->GotFocus();
 
229
  GetRenderWidgetHost()->SetActive(true);
 
230
}
 
231
 
 
232
void RenderWidgetHostView::OnBlur() {
 
233
  GetRenderWidgetHost()->SetActive(false);
 
234
  GetRenderWidgetHost()->Blur();
 
235
}
 
236
 
 
237
} // namespace oxide