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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 801173002: Fix message routing for BrowserPlugin in iframe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests that don't have a RenderThreadImpl Created 6 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 BrowserPlugin* BrowserPlugin::GetFromNode(blink::WebNode& node) { 51 BrowserPlugin* BrowserPlugin::GetFromNode(blink::WebNode& node) {
52 blink::WebPluginContainer* container = node.pluginContainer(); 52 blink::WebPluginContainer* container = node.pluginContainer();
53 if (!container) 53 if (!container)
54 return NULL; 54 return NULL;
55 55
56 PluginContainerMap* browser_plugins = g_plugin_container_map.Pointer(); 56 PluginContainerMap* browser_plugins = g_plugin_container_map.Pointer();
57 PluginContainerMap::iterator it = browser_plugins->find(container); 57 PluginContainerMap::iterator it = browser_plugins->find(container);
58 return it == browser_plugins->end() ? NULL : it->second; 58 return it == browser_plugins->end() ? NULL : it->second;
59 } 59 }
60 60
61 BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view, 61 BrowserPlugin::BrowserPlugin(RenderFrame* render_frame,
62 blink::WebFrame* frame,
63 scoped_ptr<BrowserPluginDelegate> delegate) 62 scoped_ptr<BrowserPluginDelegate> delegate)
64 : attached_(false), 63 : attached_(false),
65 render_view_(render_view->AsWeakPtr()), 64 render_view_routing_id_(render_frame->GetRenderView()->GetRoutingID()),
66 render_view_routing_id_(render_view->GetRoutingID()),
67 container_(NULL), 65 container_(NULL),
68 last_device_scale_factor_(GetDeviceScaleFactor()), 66 last_device_scale_factor_(GetDeviceScaleFactor()),
69 sad_guest_(NULL), 67 sad_guest_(NULL),
70 guest_crashed_(false), 68 guest_crashed_(false),
71 plugin_focused_(false), 69 plugin_focused_(false),
72 visible_(true), 70 visible_(true),
73 mouse_locked_(false), 71 mouse_locked_(false),
74 ready_(false), 72 ready_(false),
75 browser_plugin_manager_(render_view->GetBrowserPluginManager()),
76 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 73 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
77 contents_opaque_(true), 74 contents_opaque_(true),
78 delegate_(delegate.Pass()), 75 delegate_(delegate.Pass()),
79 weak_ptr_factory_(this) { 76 weak_ptr_factory_(this) {
80 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); 77 browser_plugin_instance_id_ =
78 BrowserPluginManager::Get()->GetNextInstanceID();
81 79
82 if (delegate_) 80 if (delegate_)
83 delegate_->SetElementInstanceID(browser_plugin_instance_id_); 81 delegate_->SetElementInstanceID(browser_plugin_instance_id_);
84 } 82 }
85 83
86 BrowserPlugin::~BrowserPlugin() { 84 BrowserPlugin::~BrowserPlugin() {
87 if (compositing_helper_.get()) 85 if (compositing_helper_.get())
88 compositing_helper_->OnContainerDestroy(); 86 compositing_helper_->OnContainerDestroy();
89 87
90 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); 88 BrowserPluginManager::Get()->RemoveBrowserPlugin(browser_plugin_instance_id_);
91 } 89 }
92 90
93 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { 91 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
94 bool handled = true; 92 bool handled = true;
95 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) 93 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message)
96 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) 94 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus)
97 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, 95 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped,
98 OnCompositorFrameSwapped(message)) 96 OnCompositorFrameSwapped(message))
99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) 97 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone)
100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque) 98 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque)
101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) 99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor)
102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) 100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock)
103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText) 101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText)
104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, 102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents,
105 OnShouldAcceptTouchEvents) 103 OnShouldAcceptTouchEvents)
106 IPC_MESSAGE_UNHANDLED(handled = false) 104 IPC_MESSAGE_UNHANDLED(
105 handled = delegate_ && delegate_->OnMessageReceived(message))
107 IPC_END_MESSAGE_MAP() 106 IPC_END_MESSAGE_MAP()
108 return handled; 107 return handled;
109 } 108 }
110 109
111 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, 110 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name,
112 const base::string16& attribute_value) { 111 const base::string16& attribute_value) {
113 if (!container()) 112 if (!container())
114 return; 113 return;
115 114
116 blink::WebElement element = container()->element(); 115 blink::WebElement element = container()->element();
(...skipping 14 matching lines...) Expand all
131 if (container()) { 130 if (container()) {
132 blink::WebLocalFrame* frame = container()->element().document().frame(); 131 blink::WebLocalFrame* frame = container()->element().document().frame();
133 attach_params.is_full_page_plugin = 132 attach_params.is_full_page_plugin =
134 frame->view()->mainFrame()->document().isPluginDocument(); 133 frame->view()->mainFrame()->document().isPluginDocument();
135 } 134 }
136 gfx::Size view_size(width(), height()); 135 gfx::Size view_size(width(), height());
137 if (!view_size.IsEmpty()) { 136 if (!view_size.IsEmpty()) {
138 PopulateResizeGuestParameters(view_size, 137 PopulateResizeGuestParameters(view_size,
139 &attach_params.resize_guest_params); 138 &attach_params.resize_guest_params);
140 } 139 }
141 browser_plugin_manager()->Send(new BrowserPluginHostMsg_Attach( 140 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_Attach(
142 render_view_routing_id_, 141 render_view_routing_id_,
143 browser_plugin_instance_id_, 142 browser_plugin_instance_id_,
144 attach_params)); 143 attach_params));
145 144
146 attached_ = true; 145 attached_ = true;
147 } 146 }
148 147
149 void BrowserPlugin::Detach() { 148 void BrowserPlugin::Detach() {
150 if (!attached()) 149 if (!attached())
151 return; 150 return;
152 151
153 attached_ = false; 152 attached_ = false;
154 guest_crashed_ = false; 153 guest_crashed_ = false;
155 EnableCompositing(false); 154 EnableCompositing(false);
156 if (compositing_helper_.get()) { 155 if (compositing_helper_.get()) {
157 compositing_helper_->OnContainerDestroy(); 156 compositing_helper_->OnContainerDestroy();
158 compositing_helper_ = NULL; 157 compositing_helper_ = NULL;
159 } 158 }
160 159
161 browser_plugin_manager()->Send(new BrowserPluginHostMsg_Detach( 160 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_Detach(
162 render_view_routing_id_, browser_plugin_instance_id_)); 161 render_view_routing_id_, browser_plugin_instance_id_));
163 } 162 }
164 163
165 void BrowserPlugin::DidCommitCompositorFrame() { 164 void BrowserPlugin::DidCommitCompositorFrame() {
166 if (compositing_helper_.get()) 165 if (compositing_helper_.get())
167 compositing_helper_->DidCommitCompositorFrame(); 166 compositing_helper_->DidCommitCompositorFrame();
168 } 167 }
169 168
170 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, 169 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id,
171 bool reverse) { 170 bool reverse) {
172 DCHECK(render_view_); 171 RenderViewImpl* render_view =
173 render_view_->GetWebView()->advanceFocus(reverse); 172 RenderViewImpl::FromRoutingID(render_view_routing_id());
173 if (!render_view)
174 return;
175 render_view->GetWebView()->advanceFocus(reverse);
174 } 176 }
175 177
176 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { 178 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) {
177 if (!attached()) 179 if (!attached())
178 return; 180 return;
179 181
180 BrowserPluginMsg_CompositorFrameSwapped::Param param; 182 BrowserPluginMsg_CompositorFrameSwapped::Param param;
181 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param)) 183 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param))
182 return; 184 return;
183 // Note that there is no need to send ACK for this message. 185 // Note that there is no need to send ACK for this message.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 compositing_helper_->SetContentsOpaque(opaque); 223 compositing_helper_->SetContentsOpaque(opaque);
222 } 224 }
223 225
224 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id, 226 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id,
225 const WebCursor& cursor) { 227 const WebCursor& cursor) {
226 cursor_ = cursor; 228 cursor_ = cursor;
227 } 229 }
228 230
229 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id, 231 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id,
230 bool enable) { 232 bool enable) {
233 RenderViewImpl* render_view =
234 RenderViewImpl::FromRoutingID(render_view_routing_id());
231 if (enable) { 235 if (enable) {
232 if (mouse_locked_) 236 if (mouse_locked_ || !render_view)
233 return; 237 return;
234 render_view_->mouse_lock_dispatcher()->LockMouse(this); 238 render_view->mouse_lock_dispatcher()->LockMouse(this);
235 } else { 239 } else {
236 if (!mouse_locked_) { 240 if (!mouse_locked_) {
237 OnLockMouseACK(false); 241 OnLockMouseACK(false);
238 return; 242 return;
239 } 243 }
240 render_view_->mouse_lock_dispatcher()->UnlockMouse(this); 244 if (!render_view)
245 return;
246 render_view->mouse_lock_dispatcher()->UnlockMouse(this);
241 } 247 }
242 } 248 }
243 249
244 void BrowserPlugin::OnSetTooltipText(int instance_id, 250 void BrowserPlugin::OnSetTooltipText(int instance_id,
245 const base::string16& tooltip_text) { 251 const base::string16& tooltip_text) {
246 // Show tooltip text by setting the BrowserPlugin's |title| attribute. 252 // Show tooltip text by setting the BrowserPlugin's |title| attribute.
247 UpdateDOMAttribute("title", tooltip_text); 253 UpdateDOMAttribute("title", tooltip_text);
248 } 254 }
249 255
250 void BrowserPlugin::OnShouldAcceptTouchEvents(int browser_plugin_instance_id, 256 void BrowserPlugin::OnShouldAcceptTouchEvents(int browser_plugin_instance_id,
251 bool accept) { 257 bool accept) {
252 if (container()) { 258 if (container()) {
253 container()->requestTouchEventType( 259 container()->requestTouchEventType(
254 accept ? WebPluginContainer::TouchEventRequestTypeRaw 260 accept ? WebPluginContainer::TouchEventRequestTypeRaw
255 : WebPluginContainer::TouchEventRequestTypeNone); 261 : WebPluginContainer::TouchEventRequestTypeNone);
256 } 262 }
257 } 263 }
258 264
259 void BrowserPlugin::ShowSadGraphic() { 265 void BrowserPlugin::ShowSadGraphic() {
260 // If the BrowserPlugin is scheduled to be deleted, then container_ will be 266 // If the BrowserPlugin is scheduled to be deleted, then container_ will be
261 // NULL so we shouldn't attempt to access it. 267 // NULL so we shouldn't attempt to access it.
262 if (container_) 268 if (container_)
263 container_->invalidate(); 269 container_->invalidate();
264 } 270 }
265 271
266 float BrowserPlugin::GetDeviceScaleFactor() const { 272 float BrowserPlugin::GetDeviceScaleFactor() const {
267 if (!render_view_) 273 RenderViewImpl* render_view =
274 RenderViewImpl::FromRoutingID(render_view_routing_id());
275 if (!render_view)
268 return 1.0f; 276 return 1.0f;
269 return render_view_->GetWebView()->deviceScaleFactor(); 277 return render_view->GetWebView()->deviceScaleFactor();
270 } 278 }
271 279
272 void BrowserPlugin::UpdateDeviceScaleFactor() { 280 void BrowserPlugin::UpdateDeviceScaleFactor() {
273 if (last_device_scale_factor_ == GetDeviceScaleFactor()) 281 if (last_device_scale_factor_ == GetDeviceScaleFactor())
274 return; 282 return;
275 283
276 BrowserPluginHostMsg_ResizeGuest_Params params; 284 BrowserPluginHostMsg_ResizeGuest_Params params;
277 PopulateResizeGuestParameters(plugin_size(), &params); 285 PopulateResizeGuestParameters(plugin_size(), &params);
278 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 286 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
279 render_view_routing_id_, 287 render_view_routing_id_,
280 browser_plugin_instance_id_, 288 browser_plugin_instance_id_,
281 params)); 289 params));
282 } 290 }
283 291
284 void BrowserPlugin::UpdateGuestFocusState() { 292 void BrowserPlugin::UpdateGuestFocusState() {
285 if (!attached()) 293 if (!attached())
286 return; 294 return;
287 bool should_be_focused = ShouldGuestBeFocused(); 295 bool should_be_focused = ShouldGuestBeFocused();
288 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( 296 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus(
289 render_view_routing_id_, 297 render_view_routing_id_,
290 browser_plugin_instance_id_, 298 browser_plugin_instance_id_,
291 should_be_focused)); 299 should_be_focused));
292 } 300 }
293 301
294 bool BrowserPlugin::ShouldGuestBeFocused() const { 302 bool BrowserPlugin::ShouldGuestBeFocused() const {
295 bool embedder_focused = false; 303 bool embedder_focused = false;
296 if (render_view_) 304 RenderViewImpl* render_view =
297 embedder_focused = render_view_->has_focus(); 305 RenderViewImpl::FromRoutingID(render_view_routing_id());
306 if (render_view)
307 embedder_focused = render_view->has_focus();
298 return plugin_focused_ && embedder_focused; 308 return plugin_focused_ && embedder_focused;
299 } 309 }
300 310
301 WebPluginContainer* BrowserPlugin::container() const { 311 WebPluginContainer* BrowserPlugin::container() const {
302 return container_; 312 return container_;
303 } 313 }
304 314
305 bool BrowserPlugin::initialize(WebPluginContainer* container) { 315 bool BrowserPlugin::initialize(WebPluginContainer* container) {
306 if (!container) 316 if (!container)
307 return false; 317 return false;
308 318
309 container_ = container; 319 container_ = container;
310 container_->setWantsWheelEvents(true); 320 container_->setWantsWheelEvents(true);
311 321
312 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); 322 g_plugin_container_map.Get().insert(std::make_pair(container_, this));
313 323
314 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); 324 BrowserPluginManager::Get()->AddBrowserPlugin(
325 browser_plugin_instance_id_, this);
315 326
316 // This is a way to notify observers of our attributes that this plugin is 327 // This is a way to notify observers of our attributes that this plugin is
317 // available in render tree. 328 // available in render tree.
318 // TODO(lazyboy): This should be done through the delegate instead. Perhaps 329 // TODO(lazyboy): This should be done through the delegate instead. Perhaps
319 // by firing an event from there. 330 // by firing an event from there.
320 UpdateDOMAttribute( 331 UpdateDOMAttribute(
321 "internalinstanceid", 332 "internalinstanceid",
322 base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_))); 333 base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_)));
323 334
324 return true; 335 return true;
(...skipping 23 matching lines...) Expand all
348 359
349 void BrowserPlugin::destroy() { 360 void BrowserPlugin::destroy() {
350 if (container_) { 361 if (container_) {
351 // The BrowserPlugin's WebPluginContainer is deleted immediately after this 362 // The BrowserPlugin's WebPluginContainer is deleted immediately after this
352 // call returns, so let's not keep a reference to it around. 363 // call returns, so let's not keep a reference to it around.
353 g_plugin_container_map.Get().erase(container_); 364 g_plugin_container_map.Get().erase(container_);
354 } 365 }
355 366
356 container_ = NULL; 367 container_ = NULL;
357 // Will be a no-op if the mouse is not currently locked. 368 // Will be a no-op if the mouse is not currently locked.
358 if (render_view_) 369 RenderViewImpl* render_view =
359 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); 370 RenderViewImpl::FromRoutingID(render_view_routing_id());
371 if (render_view)
372 render_view->mouse_lock_dispatcher()->OnLockTargetDestroyed(this);
360 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 373 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
361 } 374 }
362 375
363 bool BrowserPlugin::supportsKeyboardFocus() const { 376 bool BrowserPlugin::supportsKeyboardFocus() const {
364 return true; 377 return true;
365 } 378 }
366 379
367 bool BrowserPlugin::supportsEditCommands() const { 380 bool BrowserPlugin::supportsEditCommands() const {
368 return true; 381 return true;
369 } 382 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (!ready_) { 447 if (!ready_) {
435 if (delegate_) 448 if (delegate_)
436 delegate_->Ready(); 449 delegate_->Ready();
437 ready_ = true; 450 ready_ = true;
438 } 451 }
439 if (!attached()) 452 if (!attached())
440 return; 453 return;
441 454
442 if (old_width == window_rect.width && old_height == window_rect.height) { 455 if (old_width == window_rect.width && old_height == window_rect.height) {
443 // Let the browser know about the updated view rect. 456 // Let the browser know about the updated view rect.
444 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( 457 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateGeometry(
445 render_view_routing_id_, browser_plugin_instance_id_, plugin_rect_)); 458 render_view_routing_id_, browser_plugin_instance_id_, plugin_rect_));
446 return; 459 return;
447 } 460 }
448 461
449 BrowserPluginHostMsg_ResizeGuest_Params params; 462 BrowserPluginHostMsg_ResizeGuest_Params params;
450 PopulateResizeGuestParameters(plugin_size(), &params); 463 PopulateResizeGuestParameters(plugin_size(), &params);
451 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 464 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
452 render_view_routing_id_, 465 render_view_routing_id_,
453 browser_plugin_instance_id_, 466 browser_plugin_instance_id_,
454 params)); 467 params));
455 } 468 }
456 469
457 void BrowserPlugin::PopulateResizeGuestParameters( 470 void BrowserPlugin::PopulateResizeGuestParameters(
458 const gfx::Size& view_size, 471 const gfx::Size& view_size,
459 BrowserPluginHostMsg_ResizeGuest_Params* params) { 472 BrowserPluginHostMsg_ResizeGuest_Params* params) {
460 params->view_size = view_size; 473 params->view_size = view_size;
461 params->scale_factor = GetDeviceScaleFactor(); 474 params->scale_factor = GetDeviceScaleFactor();
(...skipping 12 matching lines...) Expand all
474 if (visible_ == visible) 487 if (visible_ == visible)
475 return; 488 return;
476 489
477 visible_ = visible; 490 visible_ = visible;
478 if (!attached()) 491 if (!attached())
479 return; 492 return;
480 493
481 if (compositing_helper_.get()) 494 if (compositing_helper_.get())
482 compositing_helper_->UpdateVisibility(visible); 495 compositing_helper_->UpdateVisibility(visible);
483 496
484 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility( 497 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetVisibility(
485 render_view_routing_id_, 498 render_view_routing_id_,
486 browser_plugin_instance_id_, 499 browser_plugin_instance_id_,
487 visible)); 500 visible));
488 } 501 }
489 502
490 bool BrowserPlugin::acceptsInputEvents() { 503 bool BrowserPlugin::acceptsInputEvents() {
491 return true; 504 return true;
492 } 505 }
493 506
494 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, 507 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event,
495 blink::WebCursorInfo& cursor_info) { 508 blink::WebCursorInfo& cursor_info) {
496 if (guest_crashed_ || !attached()) 509 if (guest_crashed_ || !attached())
497 return false; 510 return false;
498 511
499 if (event.type == blink::WebInputEvent::ContextMenu) 512 if (event.type == blink::WebInputEvent::ContextMenu)
500 return true; 513 return true;
501 514
502 if (blink::WebInputEvent::isKeyboardEventType(event.type) && 515 if (blink::WebInputEvent::isKeyboardEventType(event.type) &&
503 !edit_commands_.empty()) { 516 !edit_commands_.empty()) {
504 browser_plugin_manager()->Send( 517 BrowserPluginManager::Get()->Send(
505 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( 518 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent(
506 render_view_routing_id_, 519 render_view_routing_id_,
507 browser_plugin_instance_id_, 520 browser_plugin_instance_id_,
508 edit_commands_)); 521 edit_commands_));
509 edit_commands_.clear(); 522 edit_commands_.clear();
510 } 523 }
511 524
512 browser_plugin_manager()->Send( 525 BrowserPluginManager::Get()->Send(
513 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 526 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
514 browser_plugin_instance_id_, 527 browser_plugin_instance_id_,
515 plugin_rect_, 528 plugin_rect_,
516 &event)); 529 &event));
517 GetWebKitCursorInfo(cursor_, &cursor_info); 530 GetWebKitCursorInfo(cursor_, &cursor_info);
518 return true; 531 return true;
519 } 532 }
520 533
521 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, 534 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status,
522 const blink::WebDragData& drag_data, 535 const blink::WebDragData& drag_data,
523 blink::WebDragOperationsMask mask, 536 blink::WebDragOperationsMask mask,
524 const blink::WebPoint& position, 537 const blink::WebPoint& position,
525 const blink::WebPoint& screen) { 538 const blink::WebPoint& screen) {
526 if (guest_crashed_ || !attached()) 539 if (guest_crashed_ || !attached())
527 return false; 540 return false;
528 browser_plugin_manager()->Send( 541 BrowserPluginManager::Get()->Send(
529 new BrowserPluginHostMsg_DragStatusUpdate( 542 new BrowserPluginHostMsg_DragStatusUpdate(
530 render_view_routing_id_, 543 render_view_routing_id_,
531 browser_plugin_instance_id_, 544 browser_plugin_instance_id_,
532 drag_status, 545 drag_status,
533 DropDataBuilder::Build(drag_data), 546 DropDataBuilder::Build(drag_data),
534 mask, 547 mask,
535 position)); 548 position));
536 return true; 549 return true;
537 } 550 }
538 551
(...skipping 18 matching lines...) Expand all
557 void* notify_data) { 570 void* notify_data) {
558 } 571 }
559 572
560 void BrowserPlugin::didFailLoadingFrameRequest( 573 void BrowserPlugin::didFailLoadingFrameRequest(
561 const blink::WebURL& url, 574 const blink::WebURL& url,
562 void* notify_data, 575 void* notify_data,
563 const blink::WebURLError& error) { 576 const blink::WebURLError& error) {
564 } 577 }
565 578
566 bool BrowserPlugin::executeEditCommand(const blink::WebString& name) { 579 bool BrowserPlugin::executeEditCommand(const blink::WebString& name) {
567 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ExecuteEditCommand( 580 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ExecuteEditCommand(
568 render_view_routing_id_, 581 render_view_routing_id_,
569 browser_plugin_instance_id_, 582 browser_plugin_instance_id_,
570 name.utf8())); 583 name.utf8()));
571 584
572 // BrowserPlugin swallows edit commands. 585 // BrowserPlugin swallows edit commands.
573 return true; 586 return true;
574 } 587 }
575 588
576 bool BrowserPlugin::executeEditCommand(const blink::WebString& name, 589 bool BrowserPlugin::executeEditCommand(const blink::WebString& name,
577 const blink::WebString& value) { 590 const blink::WebString& value) {
578 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); 591 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8()));
579 // BrowserPlugin swallows edit commands. 592 // BrowserPlugin swallows edit commands.
580 return true; 593 return true;
581 } 594 }
582 595
583 bool BrowserPlugin::setComposition( 596 bool BrowserPlugin::setComposition(
584 const blink::WebString& text, 597 const blink::WebString& text,
585 const blink::WebVector<blink::WebCompositionUnderline>& underlines, 598 const blink::WebVector<blink::WebCompositionUnderline>& underlines,
586 int selectionStart, 599 int selectionStart,
587 int selectionEnd) { 600 int selectionEnd) {
588 if (!attached()) 601 if (!attached())
589 return false; 602 return false;
590 std::vector<blink::WebCompositionUnderline> std_underlines; 603 std::vector<blink::WebCompositionUnderline> std_underlines;
591 for (size_t i = 0; i < underlines.size(); ++i) { 604 for (size_t i = 0; i < underlines.size(); ++i) {
592 std_underlines.push_back(underlines[i]); 605 std_underlines.push_back(underlines[i]);
593 } 606 }
594 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeSetComposition( 607 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ImeSetComposition(
595 render_view_routing_id_, 608 render_view_routing_id_,
596 browser_plugin_instance_id_, 609 browser_plugin_instance_id_,
597 text.utf8(), 610 text.utf8(),
598 std_underlines, 611 std_underlines,
599 selectionStart, 612 selectionStart,
600 selectionEnd)); 613 selectionEnd));
601 // TODO(kochi): This assumes the IPC handling always succeeds. 614 // TODO(kochi): This assumes the IPC handling always succeeds.
602 return true; 615 return true;
603 } 616 }
604 617
605 bool BrowserPlugin::confirmComposition( 618 bool BrowserPlugin::confirmComposition(
606 const blink::WebString& text, 619 const blink::WebString& text,
607 blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) { 620 blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) {
608 if (!attached()) 621 if (!attached())
609 return false; 622 return false;
610 bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection); 623 bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection);
611 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeConfirmComposition( 624 BrowserPluginManager::Get()->Send(
612 render_view_routing_id_, 625 new BrowserPluginHostMsg_ImeConfirmComposition(
613 browser_plugin_instance_id_, 626 render_view_routing_id_,
614 text.utf8(), 627 browser_plugin_instance_id_,
615 keep_selection)); 628 text.utf8(),
629 keep_selection));
616 // TODO(kochi): This assumes the IPC handling always succeeds. 630 // TODO(kochi): This assumes the IPC handling always succeeds.
617 return true; 631 return true;
618 } 632 }
619 633
620 void BrowserPlugin::extendSelectionAndDelete(int before, int after) { 634 void BrowserPlugin::extendSelectionAndDelete(int before, int after) {
621 if (!attached()) 635 if (!attached())
622 return; 636 return;
623 browser_plugin_manager()->Send( 637 BrowserPluginManager::Get()->Send(
624 new BrowserPluginHostMsg_ExtendSelectionAndDelete( 638 new BrowserPluginHostMsg_ExtendSelectionAndDelete(
625 render_view_routing_id_, 639 render_view_routing_id_,
626 browser_plugin_instance_id_, 640 browser_plugin_instance_id_,
627 before, 641 before,
628 after)); 642 after));
629 } 643 }
630 644
631 void BrowserPlugin::OnLockMouseACK(bool succeeded) { 645 void BrowserPlugin::OnLockMouseACK(bool succeeded) {
632 mouse_locked_ = succeeded; 646 mouse_locked_ = succeeded;
633 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK( 647 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_LockMouse_ACK(
634 render_view_routing_id_, 648 render_view_routing_id_,
635 browser_plugin_instance_id_, 649 browser_plugin_instance_id_,
636 succeeded)); 650 succeeded));
637 } 651 }
638 652
639 void BrowserPlugin::OnMouseLockLost() { 653 void BrowserPlugin::OnMouseLockLost() {
640 mouse_locked_ = false; 654 mouse_locked_ = false;
641 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( 655 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK(
642 render_view_routing_id_, 656 render_view_routing_id_,
643 browser_plugin_instance_id_)); 657 browser_plugin_instance_id_));
644 } 658 }
645 659
646 bool BrowserPlugin::HandleMouseLockedInputEvent( 660 bool BrowserPlugin::HandleMouseLockedInputEvent(
647 const blink::WebMouseEvent& event) { 661 const blink::WebMouseEvent& event) {
648 browser_plugin_manager()->Send( 662 BrowserPluginManager::Get()->Send(
649 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 663 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
650 browser_plugin_instance_id_, 664 browser_plugin_instance_id_,
651 plugin_rect_, 665 plugin_rect_,
652 &event)); 666 &event));
653 return true; 667 return true;
654 } 668 }
655 669
656 } // namespace content 670 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698