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

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

Issue 10693134: Revert 146000 - Split out ContentViewCore from ContentView for embedders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_core_impl.h" 10 #include "content/browser/android/content_view_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 ContentViewCoreImpl* content_view_core) 20 ContentViewImpl* content_view)
21 : host_(widget_host), 21 : host_(widget_host),
22 // ContentViewCoreImpl represents the native side of the Java 22 // ContentViewImpl represents the native side of the Java ContentView.
23 // ContentViewCore. It being NULL means that it is not attached to the 23 // It being NULL means that it is not attached to the View system yet,
24 // View system yet, so we treat it as hidden. 24 // so we treat it as hidden.
25 is_hidden_(!content_view_core), 25 is_hidden_(!content_view),
26 content_view_core_(content_view_core) { 26 content_view_(content_view) {
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_core_; 95 return content_view_;
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_core_) 129 if (!content_view_)
130 return false; // ContentViewCore not created yet. 130 return false; // ContentView not created yet.
131 131
132 return content_view_core_->HasFocus(); 132 return content_view_->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_core_) { 153 if (content_view_) {
154 return content_view_core_->GetBounds(); 154 return content_view_->GetBounds();
155 } else { 155 } else {
156 // The ContentViewCore has not been created yet. This only happens when 156 // The ContentView 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_core_ = NULL; 197 content_view_ = 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_core_) 215 if (text.empty() || range.is_empty() || !content_view_)
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_core_->OnSelectionChanged(utf8_selection); 228 content_view_->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_core_) 252 if (content_view_)
253 content_view_core_->OnAcceleratedCompositingStateChange( 253 content_view_->OnAcceleratedCompositingStateChange(this, activated, false);
254 this, activated, false);
255 } 254 }
256 255
257 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( 256 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
258 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 257 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
259 int gpu_host_id) { 258 int gpu_host_id) {
260 NOTREACHED(); 259 NOTREACHED();
261 } 260 }
262 261
263 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( 262 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
264 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 263 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 315
317 bool RenderWidgetHostViewAndroid::LockMouse() { 316 bool RenderWidgetHostViewAndroid::LockMouse() {
318 NOTIMPLEMENTED(); 317 NOTIMPLEMENTED();
319 return false; 318 return false;
320 } 319 }
321 320
322 void RenderWidgetHostViewAndroid::UnlockMouse() { 321 void RenderWidgetHostViewAndroid::UnlockMouse() {
323 NOTIMPLEMENTED(); 322 NOTIMPLEMENTED();
324 } 323 }
325 324
326 void RenderWidgetHostViewAndroid::SetContentViewCore( 325 void RenderWidgetHostViewAndroid::SetContentView(
327 ContentViewCoreImpl* content_view_core) { 326 ContentViewImpl* content_view) {
328 content_view_core_ = content_view_core; 327 content_view_ = content_view;
329 if (host_) { 328 if (host_) {
330 GpuSurfaceTracker::Get()->SetSurfaceHandle( 329 GpuSurfaceTracker::Get()->SetSurfaceHandle(
331 host_->surface_id(), content_view_core_ ? 330 host_->surface_id(), content_view_ ?
332 GetCompositingSurface() : gfx::GLSurfaceHandle()); 331 GetCompositingSurface() : gfx::GLSurfaceHandle());
333 } 332 }
334 } 333 }
335 334
336 // static 335 // static
337 void RenderWidgetHostViewPort::GetDefaultScreenInfo( 336 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
338 ::WebKit::WebScreenInfo* results) { 337 ::WebKit::WebScreenInfo* results) {
339 DeviceInfo info; 338 DeviceInfo info;
340 const int width = info.GetWidth(); 339 const int width = info.GetWidth();
341 const int height = info.GetHeight(); 340 const int height = info.GetHeight();
(...skipping 11 matching lines...) Expand all
353 // RenderWidgetHostView, public: 352 // RenderWidgetHostView, public:
354 353
355 // static 354 // static
356 RenderWidgetHostView* 355 RenderWidgetHostView*
357 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 356 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
358 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 357 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
359 return new RenderWidgetHostViewAndroid(rwhi, NULL); 358 return new RenderWidgetHostViewAndroid(rwhi, NULL);
360 } 359 }
361 360
362 } // namespace content 361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698