| OLD | NEW |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 render_view_(render_view->AsWeakPtr()), | 65 render_view_(render_view->AsWeakPtr()), |
| 66 render_view_routing_id_(render_view->GetRoutingID()), | 66 render_view_routing_id_(render_view->GetRoutingID()), |
| 67 container_(NULL), | 67 container_(NULL), |
| 68 last_device_scale_factor_(GetDeviceScaleFactor()), | 68 last_device_scale_factor_(GetDeviceScaleFactor()), |
| 69 sad_guest_(NULL), | 69 sad_guest_(NULL), |
| 70 guest_crashed_(false), | 70 guest_crashed_(false), |
| 71 plugin_focused_(false), | 71 plugin_focused_(false), |
| 72 visible_(true), | 72 visible_(true), |
| 73 mouse_locked_(false), | 73 mouse_locked_(false), |
| 74 ready_(false), | 74 ready_(false), |
| 75 browser_plugin_manager_(render_view->GetBrowserPluginManager()), | |
| 76 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), | 75 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), |
| 77 contents_opaque_(true), | 76 contents_opaque_(true), |
| 78 delegate_(delegate.Pass()), | 77 delegate_(delegate.Pass()), |
| 79 weak_ptr_factory_(this) { | 78 weak_ptr_factory_(this) { |
| 80 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); | 79 browser_plugin_instance_id_ = |
| 80 BrowserPluginManager::Get()->GetNextInstanceID(); |
| 81 | 81 |
| 82 if (delegate_) | 82 if (delegate_) |
| 83 delegate_->SetElementInstanceID(browser_plugin_instance_id_); | 83 delegate_->SetElementInstanceID(browser_plugin_instance_id_); |
| 84 } | 84 } |
| 85 | 85 |
| 86 BrowserPlugin::~BrowserPlugin() { | 86 BrowserPlugin::~BrowserPlugin() { |
| 87 if (compositing_helper_.get()) | 87 if (compositing_helper_.get()) |
| 88 compositing_helper_->OnContainerDestroy(); | 88 compositing_helper_->OnContainerDestroy(); |
| 89 | 89 |
| 90 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); | 90 BrowserPluginManager::Get()->RemoveBrowserPlugin(browser_plugin_instance_id_); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { | 93 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { |
| 94 bool handled = true; | 94 bool handled = true; |
| 95 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) | 95 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) |
| 96 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) | 96 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) |
| 97 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, | 97 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, |
| 98 OnCompositorFrameSwapped(message)) | 98 OnCompositorFrameSwapped(message)) |
| 99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) | 99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) |
| 100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque) | 100 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetContentsOpaque, OnSetContentsOpaque) |
| 101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) | 101 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) |
| 102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) | 102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) |
| 103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText) | 103 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText) |
| 104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, | 104 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, |
| 105 OnShouldAcceptTouchEvents) | 105 OnShouldAcceptTouchEvents) |
| 106 IPC_MESSAGE_UNHANDLED(handled = false) | 106 IPC_MESSAGE_UNHANDLED( |
| 107 handled = delegate_ && delegate_->OnMessageReceived(message)) |
| 107 IPC_END_MESSAGE_MAP() | 108 IPC_END_MESSAGE_MAP() |
| 108 return handled; | 109 return handled; |
| 109 } | 110 } |
| 110 | 111 |
| 111 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, | 112 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, |
| 112 const base::string16& attribute_value) { | 113 const base::string16& attribute_value) { |
| 113 if (!container()) | 114 if (!container()) |
| 114 return; | 115 return; |
| 115 | 116 |
| 116 blink::WebElement element = container()->element(); | 117 blink::WebElement element = container()->element(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 131 if (container()) { | 132 if (container()) { |
| 132 blink::WebLocalFrame* frame = container()->element().document().frame(); | 133 blink::WebLocalFrame* frame = container()->element().document().frame(); |
| 133 attach_params.is_full_page_plugin = | 134 attach_params.is_full_page_plugin = |
| 134 frame->view()->mainFrame()->document().isPluginDocument(); | 135 frame->view()->mainFrame()->document().isPluginDocument(); |
| 135 } | 136 } |
| 136 gfx::Size view_size(width(), height()); | 137 gfx::Size view_size(width(), height()); |
| 137 if (!view_size.IsEmpty()) { | 138 if (!view_size.IsEmpty()) { |
| 138 PopulateResizeGuestParameters(view_size, | 139 PopulateResizeGuestParameters(view_size, |
| 139 &attach_params.resize_guest_params); | 140 &attach_params.resize_guest_params); |
| 140 } | 141 } |
| 141 browser_plugin_manager()->Send(new BrowserPluginHostMsg_Attach( | 142 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_Attach( |
| 142 render_view_routing_id_, | 143 render_view_routing_id_, |
| 143 browser_plugin_instance_id_, | 144 browser_plugin_instance_id_, |
| 144 attach_params)); | 145 attach_params)); |
| 145 | 146 |
| 146 attached_ = true; | 147 attached_ = true; |
| 147 } | 148 } |
| 148 | 149 |
| 149 void BrowserPlugin::Detach() { | 150 void BrowserPlugin::Detach() { |
| 150 if (!attached()) | 151 if (!attached()) |
| 151 return; | 152 return; |
| 152 | 153 |
| 153 attached_ = false; | 154 attached_ = false; |
| 154 guest_crashed_ = false; | 155 guest_crashed_ = false; |
| 155 EnableCompositing(false); | 156 EnableCompositing(false); |
| 156 if (compositing_helper_.get()) { | 157 if (compositing_helper_.get()) { |
| 157 compositing_helper_->OnContainerDestroy(); | 158 compositing_helper_->OnContainerDestroy(); |
| 158 compositing_helper_ = NULL; | 159 compositing_helper_ = NULL; |
| 159 } | 160 } |
| 160 | 161 |
| 161 browser_plugin_manager()->Send(new BrowserPluginHostMsg_Detach( | 162 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_Detach( |
| 162 render_view_routing_id_, browser_plugin_instance_id_)); | 163 render_view_routing_id_, browser_plugin_instance_id_)); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void BrowserPlugin::DidCommitCompositorFrame() { | 166 void BrowserPlugin::DidCommitCompositorFrame() { |
| 166 if (compositing_helper_.get()) | 167 if (compositing_helper_.get()) |
| 167 compositing_helper_->DidCommitCompositorFrame(); | 168 compositing_helper_->DidCommitCompositorFrame(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, | 171 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, |
| 171 bool reverse) { | 172 bool reverse) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 return 1.0f; | 269 return 1.0f; |
| 269 return render_view_->GetWebView()->deviceScaleFactor(); | 270 return render_view_->GetWebView()->deviceScaleFactor(); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void BrowserPlugin::UpdateDeviceScaleFactor() { | 273 void BrowserPlugin::UpdateDeviceScaleFactor() { |
| 273 if (last_device_scale_factor_ == GetDeviceScaleFactor()) | 274 if (last_device_scale_factor_ == GetDeviceScaleFactor()) |
| 274 return; | 275 return; |
| 275 | 276 |
| 276 BrowserPluginHostMsg_ResizeGuest_Params params; | 277 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 277 PopulateResizeGuestParameters(plugin_size(), ¶ms); | 278 PopulateResizeGuestParameters(plugin_size(), ¶ms); |
| 278 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 279 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 279 render_view_routing_id_, | 280 render_view_routing_id_, |
| 280 browser_plugin_instance_id_, | 281 browser_plugin_instance_id_, |
| 281 params)); | 282 params)); |
| 282 } | 283 } |
| 283 | 284 |
| 284 void BrowserPlugin::UpdateGuestFocusState() { | 285 void BrowserPlugin::UpdateGuestFocusState() { |
| 285 if (!attached()) | 286 if (!attached()) |
| 286 return; | 287 return; |
| 287 bool should_be_focused = ShouldGuestBeFocused(); | 288 bool should_be_focused = ShouldGuestBeFocused(); |
| 288 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( | 289 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( |
| 289 render_view_routing_id_, | 290 render_view_routing_id_, |
| 290 browser_plugin_instance_id_, | 291 browser_plugin_instance_id_, |
| 291 should_be_focused)); | 292 should_be_focused)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 bool BrowserPlugin::ShouldGuestBeFocused() const { | 295 bool BrowserPlugin::ShouldGuestBeFocused() const { |
| 295 bool embedder_focused = false; | 296 bool embedder_focused = false; |
| 296 if (render_view_) | 297 if (render_view_) |
| 297 embedder_focused = render_view_->has_focus(); | 298 embedder_focused = render_view_->has_focus(); |
| 298 return plugin_focused_ && embedder_focused; | 299 return plugin_focused_ && embedder_focused; |
| 299 } | 300 } |
| 300 | 301 |
| 301 WebPluginContainer* BrowserPlugin::container() const { | 302 WebPluginContainer* BrowserPlugin::container() const { |
| 302 return container_; | 303 return container_; |
| 303 } | 304 } |
| 304 | 305 |
| 305 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 306 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| 306 if (!container) | 307 if (!container) |
| 307 return false; | 308 return false; |
| 308 | 309 |
| 309 container_ = container; | 310 container_ = container; |
| 310 container_->setWantsWheelEvents(true); | 311 container_->setWantsWheelEvents(true); |
| 311 | 312 |
| 312 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); | 313 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); |
| 313 | 314 |
| 314 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); | 315 BrowserPluginManager::Get()->AddBrowserPlugin( |
| 316 browser_plugin_instance_id_, this); |
| 315 | 317 |
| 316 // This is a way to notify observers of our attributes that this plugin is | 318 // This is a way to notify observers of our attributes that this plugin is |
| 317 // available in render tree. | 319 // available in render tree. |
| 318 // TODO(lazyboy): This should be done through the delegate instead. Perhaps | 320 // TODO(lazyboy): This should be done through the delegate instead. Perhaps |
| 319 // by firing an event from there. | 321 // by firing an event from there. |
| 320 UpdateDOMAttribute( | 322 UpdateDOMAttribute( |
| 321 "internalinstanceid", | 323 "internalinstanceid", |
| 322 base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_))); | 324 base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_))); |
| 323 | 325 |
| 324 return true; | 326 return true; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!ready_) { | 436 if (!ready_) { |
| 435 if (delegate_) | 437 if (delegate_) |
| 436 delegate_->Ready(); | 438 delegate_->Ready(); |
| 437 ready_ = true; | 439 ready_ = true; |
| 438 } | 440 } |
| 439 if (!attached()) | 441 if (!attached()) |
| 440 return; | 442 return; |
| 441 | 443 |
| 442 if (old_width == window_rect.width && old_height == window_rect.height) { | 444 if (old_width == window_rect.width && old_height == window_rect.height) { |
| 443 // Let the browser know about the updated view rect. | 445 // Let the browser know about the updated view rect. |
| 444 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( | 446 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateGeometry( |
| 445 render_view_routing_id_, browser_plugin_instance_id_, plugin_rect_)); | 447 render_view_routing_id_, browser_plugin_instance_id_, plugin_rect_)); |
| 446 return; | 448 return; |
| 447 } | 449 } |
| 448 | 450 |
| 449 BrowserPluginHostMsg_ResizeGuest_Params params; | 451 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 450 PopulateResizeGuestParameters(plugin_size(), ¶ms); | 452 PopulateResizeGuestParameters(plugin_size(), ¶ms); |
| 451 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 453 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 452 render_view_routing_id_, | 454 render_view_routing_id_, |
| 453 browser_plugin_instance_id_, | 455 browser_plugin_instance_id_, |
| 454 params)); | 456 params)); |
| 455 } | 457 } |
| 456 | 458 |
| 457 void BrowserPlugin::PopulateResizeGuestParameters( | 459 void BrowserPlugin::PopulateResizeGuestParameters( |
| 458 const gfx::Size& view_size, | 460 const gfx::Size& view_size, |
| 459 BrowserPluginHostMsg_ResizeGuest_Params* params) { | 461 BrowserPluginHostMsg_ResizeGuest_Params* params) { |
| 460 params->view_size = view_size; | 462 params->view_size = view_size; |
| 461 params->scale_factor = GetDeviceScaleFactor(); | 463 params->scale_factor = GetDeviceScaleFactor(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 474 if (visible_ == visible) | 476 if (visible_ == visible) |
| 475 return; | 477 return; |
| 476 | 478 |
| 477 visible_ = visible; | 479 visible_ = visible; |
| 478 if (!attached()) | 480 if (!attached()) |
| 479 return; | 481 return; |
| 480 | 482 |
| 481 if (compositing_helper_.get()) | 483 if (compositing_helper_.get()) |
| 482 compositing_helper_->UpdateVisibility(visible); | 484 compositing_helper_->UpdateVisibility(visible); |
| 483 | 485 |
| 484 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility( | 486 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetVisibility( |
| 485 render_view_routing_id_, | 487 render_view_routing_id_, |
| 486 browser_plugin_instance_id_, | 488 browser_plugin_instance_id_, |
| 487 visible)); | 489 visible)); |
| 488 } | 490 } |
| 489 | 491 |
| 490 bool BrowserPlugin::acceptsInputEvents() { | 492 bool BrowserPlugin::acceptsInputEvents() { |
| 491 return true; | 493 return true; |
| 492 } | 494 } |
| 493 | 495 |
| 494 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, | 496 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, |
| 495 blink::WebCursorInfo& cursor_info) { | 497 blink::WebCursorInfo& cursor_info) { |
| 496 if (guest_crashed_ || !attached()) | 498 if (guest_crashed_ || !attached()) |
| 497 return false; | 499 return false; |
| 498 | 500 |
| 499 if (event.type == blink::WebInputEvent::ContextMenu) | 501 if (event.type == blink::WebInputEvent::ContextMenu) |
| 500 return true; | 502 return true; |
| 501 | 503 |
| 502 if (blink::WebInputEvent::isKeyboardEventType(event.type) && | 504 if (blink::WebInputEvent::isKeyboardEventType(event.type) && |
| 503 !edit_commands_.empty()) { | 505 !edit_commands_.empty()) { |
| 504 browser_plugin_manager()->Send( | 506 BrowserPluginManager::Get()->Send( |
| 505 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( | 507 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( |
| 506 render_view_routing_id_, | 508 render_view_routing_id_, |
| 507 browser_plugin_instance_id_, | 509 browser_plugin_instance_id_, |
| 508 edit_commands_)); | 510 edit_commands_)); |
| 509 edit_commands_.clear(); | 511 edit_commands_.clear(); |
| 510 } | 512 } |
| 511 | 513 |
| 512 browser_plugin_manager()->Send( | 514 BrowserPluginManager::Get()->Send( |
| 513 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 515 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 514 browser_plugin_instance_id_, | 516 browser_plugin_instance_id_, |
| 515 plugin_rect_, | 517 plugin_rect_, |
| 516 &event)); | 518 &event)); |
| 517 GetWebKitCursorInfo(cursor_, &cursor_info); | 519 GetWebKitCursorInfo(cursor_, &cursor_info); |
| 518 return true; | 520 return true; |
| 519 } | 521 } |
| 520 | 522 |
| 521 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, | 523 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, |
| 522 const blink::WebDragData& drag_data, | 524 const blink::WebDragData& drag_data, |
| 523 blink::WebDragOperationsMask mask, | 525 blink::WebDragOperationsMask mask, |
| 524 const blink::WebPoint& position, | 526 const blink::WebPoint& position, |
| 525 const blink::WebPoint& screen) { | 527 const blink::WebPoint& screen) { |
| 526 if (guest_crashed_ || !attached()) | 528 if (guest_crashed_ || !attached()) |
| 527 return false; | 529 return false; |
| 528 browser_plugin_manager()->Send( | 530 BrowserPluginManager::Get()->Send( |
| 529 new BrowserPluginHostMsg_DragStatusUpdate( | 531 new BrowserPluginHostMsg_DragStatusUpdate( |
| 530 render_view_routing_id_, | 532 render_view_routing_id_, |
| 531 browser_plugin_instance_id_, | 533 browser_plugin_instance_id_, |
| 532 drag_status, | 534 drag_status, |
| 533 DropDataBuilder::Build(drag_data), | 535 DropDataBuilder::Build(drag_data), |
| 534 mask, | 536 mask, |
| 535 position)); | 537 position)); |
| 536 return true; | 538 return true; |
| 537 } | 539 } |
| 538 | 540 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 557 void* notify_data) { | 559 void* notify_data) { |
| 558 } | 560 } |
| 559 | 561 |
| 560 void BrowserPlugin::didFailLoadingFrameRequest( | 562 void BrowserPlugin::didFailLoadingFrameRequest( |
| 561 const blink::WebURL& url, | 563 const blink::WebURL& url, |
| 562 void* notify_data, | 564 void* notify_data, |
| 563 const blink::WebURLError& error) { | 565 const blink::WebURLError& error) { |
| 564 } | 566 } |
| 565 | 567 |
| 566 bool BrowserPlugin::executeEditCommand(const blink::WebString& name) { | 568 bool BrowserPlugin::executeEditCommand(const blink::WebString& name) { |
| 567 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ExecuteEditCommand( | 569 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ExecuteEditCommand( |
| 568 render_view_routing_id_, | 570 render_view_routing_id_, |
| 569 browser_plugin_instance_id_, | 571 browser_plugin_instance_id_, |
| 570 name.utf8())); | 572 name.utf8())); |
| 571 | 573 |
| 572 // BrowserPlugin swallows edit commands. | 574 // BrowserPlugin swallows edit commands. |
| 573 return true; | 575 return true; |
| 574 } | 576 } |
| 575 | 577 |
| 576 bool BrowserPlugin::executeEditCommand(const blink::WebString& name, | 578 bool BrowserPlugin::executeEditCommand(const blink::WebString& name, |
| 577 const blink::WebString& value) { | 579 const blink::WebString& value) { |
| 578 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); | 580 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); |
| 579 // BrowserPlugin swallows edit commands. | 581 // BrowserPlugin swallows edit commands. |
| 580 return true; | 582 return true; |
| 581 } | 583 } |
| 582 | 584 |
| 583 bool BrowserPlugin::setComposition( | 585 bool BrowserPlugin::setComposition( |
| 584 const blink::WebString& text, | 586 const blink::WebString& text, |
| 585 const blink::WebVector<blink::WebCompositionUnderline>& underlines, | 587 const blink::WebVector<blink::WebCompositionUnderline>& underlines, |
| 586 int selectionStart, | 588 int selectionStart, |
| 587 int selectionEnd) { | 589 int selectionEnd) { |
| 588 if (!attached()) | 590 if (!attached()) |
| 589 return false; | 591 return false; |
| 590 std::vector<blink::WebCompositionUnderline> std_underlines; | 592 std::vector<blink::WebCompositionUnderline> std_underlines; |
| 591 for (size_t i = 0; i < underlines.size(); ++i) { | 593 for (size_t i = 0; i < underlines.size(); ++i) { |
| 592 std_underlines.push_back(underlines[i]); | 594 std_underlines.push_back(underlines[i]); |
| 593 } | 595 } |
| 594 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeSetComposition( | 596 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ImeSetComposition( |
| 595 render_view_routing_id_, | 597 render_view_routing_id_, |
| 596 browser_plugin_instance_id_, | 598 browser_plugin_instance_id_, |
| 597 text.utf8(), | 599 text.utf8(), |
| 598 std_underlines, | 600 std_underlines, |
| 599 selectionStart, | 601 selectionStart, |
| 600 selectionEnd)); | 602 selectionEnd)); |
| 601 // TODO(kochi): This assumes the IPC handling always succeeds. | 603 // TODO(kochi): This assumes the IPC handling always succeeds. |
| 602 return true; | 604 return true; |
| 603 } | 605 } |
| 604 | 606 |
| 605 bool BrowserPlugin::confirmComposition( | 607 bool BrowserPlugin::confirmComposition( |
| 606 const blink::WebString& text, | 608 const blink::WebString& text, |
| 607 blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) { | 609 blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) { |
| 608 if (!attached()) | 610 if (!attached()) |
| 609 return false; | 611 return false; |
| 610 bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection); | 612 bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection); |
| 611 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeConfirmComposition( | 613 BrowserPluginManager::Get()->Send( |
| 612 render_view_routing_id_, | 614 new BrowserPluginHostMsg_ImeConfirmComposition( |
| 613 browser_plugin_instance_id_, | 615 render_view_routing_id_, |
| 614 text.utf8(), | 616 browser_plugin_instance_id_, |
| 615 keep_selection)); | 617 text.utf8(), |
| 618 keep_selection)); |
| 616 // TODO(kochi): This assumes the IPC handling always succeeds. | 619 // TODO(kochi): This assumes the IPC handling always succeeds. |
| 617 return true; | 620 return true; |
| 618 } | 621 } |
| 619 | 622 |
| 620 void BrowserPlugin::extendSelectionAndDelete(int before, int after) { | 623 void BrowserPlugin::extendSelectionAndDelete(int before, int after) { |
| 621 if (!attached()) | 624 if (!attached()) |
| 622 return; | 625 return; |
| 623 browser_plugin_manager()->Send( | 626 BrowserPluginManager::Get()->Send( |
| 624 new BrowserPluginHostMsg_ExtendSelectionAndDelete( | 627 new BrowserPluginHostMsg_ExtendSelectionAndDelete( |
| 625 render_view_routing_id_, | 628 render_view_routing_id_, |
| 626 browser_plugin_instance_id_, | 629 browser_plugin_instance_id_, |
| 627 before, | 630 before, |
| 628 after)); | 631 after)); |
| 629 } | 632 } |
| 630 | 633 |
| 631 void BrowserPlugin::OnLockMouseACK(bool succeeded) { | 634 void BrowserPlugin::OnLockMouseACK(bool succeeded) { |
| 632 mouse_locked_ = succeeded; | 635 mouse_locked_ = succeeded; |
| 633 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK( | 636 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_LockMouse_ACK( |
| 634 render_view_routing_id_, | 637 render_view_routing_id_, |
| 635 browser_plugin_instance_id_, | 638 browser_plugin_instance_id_, |
| 636 succeeded)); | 639 succeeded)); |
| 637 } | 640 } |
| 638 | 641 |
| 639 void BrowserPlugin::OnMouseLockLost() { | 642 void BrowserPlugin::OnMouseLockLost() { |
| 640 mouse_locked_ = false; | 643 mouse_locked_ = false; |
| 641 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( | 644 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( |
| 642 render_view_routing_id_, | 645 render_view_routing_id_, |
| 643 browser_plugin_instance_id_)); | 646 browser_plugin_instance_id_)); |
| 644 } | 647 } |
| 645 | 648 |
| 646 bool BrowserPlugin::HandleMouseLockedInputEvent( | 649 bool BrowserPlugin::HandleMouseLockedInputEvent( |
| 647 const blink::WebMouseEvent& event) { | 650 const blink::WebMouseEvent& event) { |
| 648 browser_plugin_manager()->Send( | 651 BrowserPluginManager::Get()->Send( |
| 649 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 652 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 650 browser_plugin_instance_id_, | 653 browser_plugin_instance_id_, |
| 651 plugin_rect_, | 654 plugin_rect_, |
| 652 &event)); | 655 &event)); |
| 653 return true; | 656 return true; |
| 654 } | 657 } |
| 655 | 658 |
| 656 } // namespace content | 659 } // namespace content |
| OLD | NEW |