Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 10696173: Revert "Revert 146000 - Split out ContentViewCore from ContentView for embedders." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase number deux Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/android/content_view_impl.h" 10 #include "content/browser/android/content_view_core_impl.h"
11 #include "content/browser/gpu/gpu_surface_tracker.h" 11 #include "content/browser/gpu/gpu_surface_tracker.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 12 #include "content/browser/renderer_host/render_widget_host_impl.h"
13 #include "content/common/android/device_info.h" 13 #include "content/common/android/device_info.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 18 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
19 RenderWidgetHostImpl* widget_host, 19 RenderWidgetHostImpl* widget_host,
20 ContentViewImpl* content_view) 20 ContentViewCoreImpl* content_view_core)
21 : host_(widget_host), 21 : host_(widget_host),
22 // ContentViewImpl represents the native side of the Java ContentView. 22 // ContentViewCoreImpl represents the native side of the Java
23 // It being NULL means that it is not attached to the View system yet, 23 // ContentViewCore. It being NULL means that it is not attached to the
24 // so we treat it as hidden. 24 // View system yet, so we treat it as hidden.
25 is_hidden_(!content_view), 25 is_hidden_(!content_view_core),
26 content_view_(content_view) { 26 content_view_core_(content_view_core) {
27 host_->SetView(this); 27 host_->SetView(this);
28 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell 28 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
29 // RenderWidgetHost to hide. 29 // RenderWidgetHost to hide.
30 if (is_hidden_) 30 if (is_hidden_)
31 host_->WasHidden(); 31 host_->WasHidden();
32 } 32 }
33 33
34 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 34 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
35 } 35 }
36 36
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 87 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
88 if (rect.origin().x() || rect.origin().y()) { 88 if (rect.origin().x() || rect.origin().y()) {
89 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)"; 89 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)";
90 } 90 }
91 SetSize(rect.size()); 91 SetSize(rect.size());
92 } 92 }
93 93
94 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { 94 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
95 return content_view_; 95 return content_view_core_;
96 } 96 }
97 97
98 gfx::NativeViewId RenderWidgetHostViewAndroid::GetNativeViewId() const { 98 gfx::NativeViewId RenderWidgetHostViewAndroid::GetNativeViewId() const {
99 return reinterpret_cast<gfx::NativeViewId>( 99 return reinterpret_cast<gfx::NativeViewId>(
100 const_cast<RenderWidgetHostViewAndroid*>(this)); 100 const_cast<RenderWidgetHostViewAndroid*>(this));
101 } 101 }
102 102
103 gfx::NativeViewAccessible 103 gfx::NativeViewAccessible
104 RenderWidgetHostViewAndroid::GetNativeViewAccessible() { 104 RenderWidgetHostViewAndroid::GetNativeViewAccessible() {
105 NOTIMPLEMENTED(); 105 NOTIMPLEMENTED();
(...skipping 13 matching lines...) Expand all
119 } 119 }
120 120
121 void RenderWidgetHostViewAndroid::Blur() { 121 void RenderWidgetHostViewAndroid::Blur() {
122 host_->Send(new ViewMsg_ExecuteEditCommand( 122 host_->Send(new ViewMsg_ExecuteEditCommand(
123 host_->GetRoutingID(), "Unselect", "")); 123 host_->GetRoutingID(), "Unselect", ""));
124 host_->SetInputMethodActive(false); 124 host_->SetInputMethodActive(false);
125 host_->Blur(); 125 host_->Blur();
126 } 126 }
127 127
128 bool RenderWidgetHostViewAndroid::HasFocus() const { 128 bool RenderWidgetHostViewAndroid::HasFocus() const {
129 if (!content_view_) 129 if (!content_view_core_)
130 return false; // ContentView not created yet. 130 return false; // ContentViewCore not created yet.
131 131
132 return content_view_->HasFocus(); 132 return content_view_core_->HasFocus();
133 } 133 }
134 134
135 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const { 135 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const {
136 NOTIMPLEMENTED(); 136 NOTIMPLEMENTED();
137 return false; 137 return false;
138 } 138 }
139 139
140 void RenderWidgetHostViewAndroid::Show() { 140 void RenderWidgetHostViewAndroid::Show() {
141 // nothing to do 141 // nothing to do
142 } 142 }
143 143
144 void RenderWidgetHostViewAndroid::Hide() { 144 void RenderWidgetHostViewAndroid::Hide() {
145 // nothing to do 145 // nothing to do
146 } 146 }
147 147
148 bool RenderWidgetHostViewAndroid::IsShowing() { 148 bool RenderWidgetHostViewAndroid::IsShowing() {
149 return !is_hidden_; 149 return !is_hidden_;
150 } 150 }
151 151
152 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { 152 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
153 if (content_view_) { 153 if (content_view_core_) {
154 return content_view_->GetBounds(); 154 return content_view_core_->GetBounds();
155 } else { 155 } else {
156 // The ContentView has not been created yet. This only happens when 156 // The ContentViewCore has not been created yet. This only happens when
157 // renderer asks for creating new window, for example, 157 // renderer asks for creating new window, for example,
158 // javascript window.open(). 158 // javascript window.open().
159 return gfx::Rect(0, 0, 0, 0); 159 return gfx::Rect(0, 0, 0, 0);
160 } 160 }
161 } 161 }
162 162
163 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { 163 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) {
164 // There are no cursors on Android. 164 // There are no cursors on Android.
165 } 165 }
166 166
(...skipping 20 matching lines...) Expand all
187 const std::vector<gfx::Rect>& copy_rects) { 187 const std::vector<gfx::Rect>& copy_rects) {
188 NOTIMPLEMENTED(); 188 NOTIMPLEMENTED();
189 } 189 }
190 190
191 void RenderWidgetHostViewAndroid::RenderViewGone( 191 void RenderWidgetHostViewAndroid::RenderViewGone(
192 base::TerminationStatus status, int error_code) { 192 base::TerminationStatus status, int error_code) {
193 Destroy(); 193 Destroy();
194 } 194 }
195 195
196 void RenderWidgetHostViewAndroid::Destroy() { 196 void RenderWidgetHostViewAndroid::Destroy() {
197 content_view_ = NULL; 197 content_view_core_ = NULL;
198 198
199 // The RenderWidgetHost's destruction led here, so don't call it. 199 // The RenderWidgetHost's destruction led here, so don't call it.
200 host_ = NULL; 200 host_ = NULL;
201 201
202 delete this; 202 delete this;
203 } 203 }
204 204
205 void RenderWidgetHostViewAndroid::SetTooltipText( 205 void RenderWidgetHostViewAndroid::SetTooltipText(
206 const string16& tooltip_text) { 206 const string16& tooltip_text) {
207 // Tooltips don't makes sense on Android. 207 // Tooltips don't makes sense on Android.
208 } 208 }
209 209
210 void RenderWidgetHostViewAndroid::SelectionChanged(const string16& text, 210 void RenderWidgetHostViewAndroid::SelectionChanged(const string16& text,
211 size_t offset, 211 size_t offset,
212 const ui::Range& range) { 212 const ui::Range& range) {
213 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); 213 RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
214 214
215 if (text.empty() || range.is_empty() || !content_view_) 215 if (text.empty() || range.is_empty() || !content_view_core_)
216 return; 216 return;
217 size_t pos = range.GetMin() - offset; 217 size_t pos = range.GetMin() - offset;
218 size_t n = range.length(); 218 size_t n = range.length();
219 219
220 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; 220 DCHECK(pos + n <= text.length()) << "The text can not fully cover range.";
221 if (pos >= text.length()) { 221 if (pos >= text.length()) {
222 NOTREACHED() << "The text can not cover range."; 222 NOTREACHED() << "The text can not cover range.";
223 return; 223 return;
224 } 224 }
225 225
226 std::string utf8_selection = UTF16ToUTF8(text.substr(pos, n)); 226 std::string utf8_selection = UTF16ToUTF8(text.substr(pos, n));
227 227
228 content_view_->OnSelectionChanged(utf8_selection); 228 content_view_core_->OnSelectionChanged(utf8_selection);
229 } 229 }
230 230
231 BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore( 231 BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore(
232 const gfx::Size& size) { 232 const gfx::Size& size) {
233 NOTIMPLEMENTED(); 233 NOTIMPLEMENTED();
234 return NULL; 234 return NULL;
235 } 235 }
236 236
237 void RenderWidgetHostViewAndroid::SetBackground(const SkBitmap& background) { 237 void RenderWidgetHostViewAndroid::SetBackground(const SkBitmap& background) {
238 RenderWidgetHostViewBase::SetBackground(background); 238 RenderWidgetHostViewBase::SetBackground(background);
239 host_->Send(new ViewMsg_SetBackground(host_->GetRoutingID(), background)); 239 host_->Send(new ViewMsg_SetBackground(host_->GetRoutingID(), background));
240 } 240 }
241 241
242 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( 242 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
243 const gfx::Size& size, 243 const gfx::Size& size,
244 skia::PlatformCanvas* output, 244 skia::PlatformCanvas* output,
245 base::Callback<void(bool)> callback) { 245 base::Callback<void(bool)> callback) {
246 NOTIMPLEMENTED(); 246 NOTIMPLEMENTED();
247 callback.Run(false); 247 callback.Run(false);
248 } 248 }
249 249
250 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { 250 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
251 const bool activated = host_->is_accelerated_compositing_active(); 251 const bool activated = host_->is_accelerated_compositing_active();
252 if (content_view_) 252 if (content_view_core_)
253 content_view_->OnAcceleratedCompositingStateChange(this, activated, false); 253 content_view_core_->OnAcceleratedCompositingStateChange(
254 this, activated, false);
254 } 255 }
255 256
256 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( 257 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
257 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 258 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
258 int gpu_host_id) { 259 int gpu_host_id) {
259 NOTREACHED(); 260 NOTREACHED();
260 } 261 }
261 262
262 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( 263 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
263 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 264 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
264 int gpu_host_id) { 265 int gpu_host_id) {
265 NOTREACHED(); 266 NOTREACHED();
266 } 267 }
267 268
268 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { 269 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() {
269 NOTREACHED(); 270 NOTREACHED();
270 } 271 }
271 272
272 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 273 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
273 const gfx::Size& desired_size) { 274 const gfx::Size& desired_size) {
274 NOTREACHED(); 275 NOTREACHED();
275 return false; 276 return false;
276 } 277 }
277 278
278 void RenderWidgetHostViewAndroid::StartContentIntent( 279 void RenderWidgetHostViewAndroid::StartContentIntent(
279 const GURL& content_url) { 280 const GURL& content_url) {
280 if (content_view_) 281 if (content_view_core_)
281 content_view_->StartContentIntent(content_url); 282 content_view_core_->StartContentIntent(content_url);
282 } 283 }
283 284
284 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { 285 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() {
285 // On Android, we cannot generate a window handle that can be passed to the 286 // On Android, we cannot generate a window handle that can be passed to the
286 // GPU process through the native side. Instead, we send the surface handle 287 // GPU process through the native side. Instead, we send the surface handle
287 // through Binder after the compositing context has been created. 288 // through Binder after the compositing context has been created.
288 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); 289 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true);
289 } 290 }
290 291
291 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) { 292 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) {
(...skipping 29 matching lines...) Expand all
321 322
322 bool RenderWidgetHostViewAndroid::LockMouse() { 323 bool RenderWidgetHostViewAndroid::LockMouse() {
323 NOTIMPLEMENTED(); 324 NOTIMPLEMENTED();
324 return false; 325 return false;
325 } 326 }
326 327
327 void RenderWidgetHostViewAndroid::UnlockMouse() { 328 void RenderWidgetHostViewAndroid::UnlockMouse() {
328 NOTIMPLEMENTED(); 329 NOTIMPLEMENTED();
329 } 330 }
330 331
331 void RenderWidgetHostViewAndroid::SetContentView( 332 void RenderWidgetHostViewAndroid::SetContentViewCore(
332 ContentViewImpl* content_view) { 333 ContentViewCoreImpl* content_view_core) {
333 content_view_ = content_view; 334 content_view_core_ = content_view_core;
334 if (host_) { 335 if (host_) {
335 GpuSurfaceTracker::Get()->SetSurfaceHandle( 336 GpuSurfaceTracker::Get()->SetSurfaceHandle(
336 host_->surface_id(), content_view_ ? 337 host_->surface_id(), content_view_core_ ?
337 GetCompositingSurface() : gfx::GLSurfaceHandle()); 338 GetCompositingSurface() : gfx::GLSurfaceHandle());
338 } 339 }
339 } 340 }
340 341
341 // static 342 // static
342 void RenderWidgetHostViewPort::GetDefaultScreenInfo( 343 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
343 ::WebKit::WebScreenInfo* results) { 344 ::WebKit::WebScreenInfo* results) {
344 DeviceInfo info; 345 DeviceInfo info;
345 const int width = info.GetWidth(); 346 const int width = info.GetWidth();
346 const int height = info.GetHeight(); 347 const int height = info.GetHeight();
(...skipping 11 matching lines...) Expand all
358 // RenderWidgetHostView, public: 359 // RenderWidgetHostView, public:
359 360
360 // static 361 // static
361 RenderWidgetHostView* 362 RenderWidgetHostView*
362 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 363 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
363 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 364 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
364 return new RenderWidgetHostViewAndroid(rwhi, NULL); 365 return new RenderWidgetHostViewAndroid(rwhi, NULL);
365 } 366 }
366 367
367 } // namespace content 368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698