| 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/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 } | 977 } |
| 978 | 978 |
| 979 bool BrowserPlugin::supportsKeyboardFocus() const { | 979 bool BrowserPlugin::supportsKeyboardFocus() const { |
| 980 return true; | 980 return true; |
| 981 } | 981 } |
| 982 | 982 |
| 983 bool BrowserPlugin::supportsEditCommands() const { | 983 bool BrowserPlugin::supportsEditCommands() const { |
| 984 return true; | 984 return true; |
| 985 } | 985 } |
| 986 | 986 |
| 987 bool BrowserPlugin::supportsInputMethod() const { |
| 988 return true; |
| 989 } |
| 990 |
| 987 bool BrowserPlugin::canProcessDrag() const { | 991 bool BrowserPlugin::canProcessDrag() const { |
| 988 return true; | 992 return true; |
| 989 } | 993 } |
| 990 | 994 |
| 991 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 995 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
| 992 if (guest_crashed_) { | 996 if (guest_crashed_) { |
| 993 if (!sad_guest_) // Lazily initialize bitmap. | 997 if (!sad_guest_) // Lazily initialize bitmap. |
| 994 sad_guest_ = content::GetContentClient()->renderer()-> | 998 sad_guest_ = content::GetContentClient()->renderer()-> |
| 995 GetSadWebViewBitmap(); | 999 GetSadWebViewBitmap(); |
| 996 // content_shell does not have the sad plugin bitmap, so we'll paint black | 1000 // content_shell does not have the sad plugin bitmap, so we'll paint black |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 return true; | 1334 return true; |
| 1331 } | 1335 } |
| 1332 | 1336 |
| 1333 bool BrowserPlugin::executeEditCommand(const blink::WebString& name, | 1337 bool BrowserPlugin::executeEditCommand(const blink::WebString& name, |
| 1334 const blink::WebString& value) { | 1338 const blink::WebString& value) { |
| 1335 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); | 1339 edit_commands_.push_back(EditCommand(name.utf8(), value.utf8())); |
| 1336 // BrowserPlugin swallows edit commands. | 1340 // BrowserPlugin swallows edit commands. |
| 1337 return true; | 1341 return true; |
| 1338 } | 1342 } |
| 1339 | 1343 |
| 1344 bool BrowserPlugin::setComposition( |
| 1345 const blink::WebString& text, |
| 1346 const blink::WebVector<blink::WebCompositionUnderline>& underlines, |
| 1347 int selectionStart, |
| 1348 int selectionEnd) { |
| 1349 if (!HasGuestInstanceID()) |
| 1350 return false; |
| 1351 std::vector<blink::WebCompositionUnderline> std_underlines; |
| 1352 for (size_t i = 0; i < underlines.size(); ++i) { |
| 1353 std_underlines.push_back(underlines[i]); |
| 1354 } |
| 1355 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeSetComposition( |
| 1356 render_view_routing_id_, |
| 1357 guest_instance_id_, |
| 1358 text.utf8(), |
| 1359 std_underlines, |
| 1360 selectionStart, |
| 1361 selectionEnd)); |
| 1362 // TODO(kochi): This assumes the IPC handling always succeeds. |
| 1363 return true; |
| 1364 } |
| 1365 |
| 1366 bool BrowserPlugin::confirmComposition( |
| 1367 const blink::WebString& text, |
| 1368 blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) { |
| 1369 if (!HasGuestInstanceID()) |
| 1370 return false; |
| 1371 bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection); |
| 1372 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeConfirmComposition( |
| 1373 render_view_routing_id_, |
| 1374 guest_instance_id_, |
| 1375 text.utf8(), |
| 1376 keep_selection)); |
| 1377 // TODO(kochi): This assumes the IPC handling always succeeds. |
| 1378 return true; |
| 1379 } |
| 1380 |
| 1381 void BrowserPlugin::extendSelectionAndDelete(int before, int after) { |
| 1382 if (!HasGuestInstanceID()) |
| 1383 return; |
| 1384 browser_plugin_manager()->Send( |
| 1385 new BrowserPluginHostMsg_ExtendSelectionAndDelete( |
| 1386 render_view_routing_id_, |
| 1387 guest_instance_id_, |
| 1388 before, |
| 1389 after)); |
| 1390 } |
| 1391 |
| 1340 void BrowserPlugin::OnLockMouseACK(bool succeeded) { | 1392 void BrowserPlugin::OnLockMouseACK(bool succeeded) { |
| 1341 mouse_locked_ = succeeded; | 1393 mouse_locked_ = succeeded; |
| 1342 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK( | 1394 browser_plugin_manager()->Send(new BrowserPluginHostMsg_LockMouse_ACK( |
| 1343 render_view_routing_id_, | 1395 render_view_routing_id_, |
| 1344 guest_instance_id_, | 1396 guest_instance_id_, |
| 1345 succeeded)); | 1397 succeeded)); |
| 1346 } | 1398 } |
| 1347 | 1399 |
| 1348 void BrowserPlugin::OnMouseLockLost() { | 1400 void BrowserPlugin::OnMouseLockLost() { |
| 1349 mouse_locked_ = false; | 1401 mouse_locked_ = false; |
| 1350 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( | 1402 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UnlockMouse_ACK( |
| 1351 render_view_routing_id_, | 1403 render_view_routing_id_, |
| 1352 guest_instance_id_)); | 1404 guest_instance_id_)); |
| 1353 } | 1405 } |
| 1354 | 1406 |
| 1355 bool BrowserPlugin::HandleMouseLockedInputEvent( | 1407 bool BrowserPlugin::HandleMouseLockedInputEvent( |
| 1356 const blink::WebMouseEvent& event) { | 1408 const blink::WebMouseEvent& event) { |
| 1357 browser_plugin_manager()->Send( | 1409 browser_plugin_manager()->Send( |
| 1358 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1410 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 1359 guest_instance_id_, | 1411 guest_instance_id_, |
| 1360 plugin_rect_, | 1412 plugin_rect_, |
| 1361 &event)); | 1413 &event)); |
| 1362 return true; | 1414 return true; |
| 1363 } | 1415 } |
| 1364 | 1416 |
| 1365 } // namespace content | 1417 } // namespace content |
| OLD | NEW |