OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "ppapi/c/dev/ppb_console_dev.h" |
12 #include "ppapi/c/dev/ppb_find_dev.h" | 13 #include "ppapi/c/dev/ppb_find_dev.h" |
13 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 14 #include "ppapi/c/dev/ppb_fullscreen_dev.h" |
14 #include "ppapi/c/dev/ppb_memory_dev.h" | 15 #include "ppapi/c/dev/ppb_memory_dev.h" |
15 #include "ppapi/c/dev/ppb_zoom_dev.h" | 16 #include "ppapi/c/dev/ppb_zoom_dev.h" |
16 #include "ppapi/c/dev/ppp_find_dev.h" | 17 #include "ppapi/c/dev/ppp_find_dev.h" |
17 #include "ppapi/c/dev/ppp_mouse_lock_dev.h" | 18 #include "ppapi/c/dev/ppp_mouse_lock_dev.h" |
18 #include "ppapi/c/dev/ppp_policy_update_dev.h" | 19 #include "ppapi/c/dev/ppp_policy_update_dev.h" |
19 #include "ppapi/c/dev/ppp_selection_dev.h" | 20 #include "ppapi/c/dev/ppp_selection_dev.h" |
20 #include "ppapi/c/dev/ppp_zoom_dev.h" | 21 #include "ppapi/c/dev/ppp_zoom_dev.h" |
21 #include "ppapi/c/pp_input_event.h" | 22 #include "ppapi/c/pp_input_event.h" |
22 #include "ppapi/c/pp_instance.h" | 23 #include "ppapi/c/pp_instance.h" |
23 #include "ppapi/c/pp_rect.h" | 24 #include "ppapi/c/pp_rect.h" |
24 #include "ppapi/c/pp_resource.h" | 25 #include "ppapi/c/pp_resource.h" |
25 #include "ppapi/c/pp_var.h" | 26 #include "ppapi/c/pp_var.h" |
26 #include "ppapi/c/ppb_core.h" | 27 #include "ppapi/c/ppb_core.h" |
27 #include "ppapi/c/ppb_instance.h" | 28 #include "ppapi/c/ppb_instance.h" |
28 #include "ppapi/c/ppp_input_event.h" | 29 #include "ppapi/c/ppp_input_event.h" |
29 #include "ppapi/c/ppp_instance.h" | 30 #include "ppapi/c/ppp_instance.h" |
30 #include "ppapi/c/ppp_messaging.h" | 31 #include "ppapi/c/ppp_messaging.h" |
31 #include "ppapi/c/private/ppb_instance_private.h" | 32 #include "ppapi/c/private/ppb_instance_private.h" |
32 #include "ppapi/c/private/ppp_instance_private.h" | 33 #include "ppapi/c/private/ppp_instance_private.h" |
33 #include "ppapi/shared_impl/input_event_impl.h" | 34 #include "ppapi/shared_impl/input_event_impl.h" |
34 #include "ppapi/shared_impl/resource.h" | 35 #include "ppapi/shared_impl/resource.h" |
35 #include "ppapi/shared_impl/var.h" | 36 #include "ppapi/shared_impl/var.h" |
36 #include "ppapi/thunk/enter.h" | 37 #include "ppapi/thunk/enter.h" |
37 #include "ppapi/thunk/ppb_buffer_api.h" | 38 #include "ppapi/thunk/ppb_buffer_api.h" |
38 #include "printing/units.h" | 39 #include "printing/units.h" |
39 #include "skia/ext/platform_canvas.h" | 40 #include "skia/ext/platform_canvas.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 using ppapi::thunk::EnterResourceNoLock; | 99 using ppapi::thunk::EnterResourceNoLock; |
98 using ppapi::thunk::PPB_Buffer_API; | 100 using ppapi::thunk::PPB_Buffer_API; |
99 using ppapi::thunk::PPB_Graphics2D_API; | 101 using ppapi::thunk::PPB_Graphics2D_API; |
100 using ppapi::thunk::PPB_Graphics3D_API; | 102 using ppapi::thunk::PPB_Graphics3D_API; |
101 using ppapi::thunk::PPB_ImageData_API; | 103 using ppapi::thunk::PPB_ImageData_API; |
102 using ppapi::thunk::PPB_Instance_FunctionAPI; | 104 using ppapi::thunk::PPB_Instance_FunctionAPI; |
103 using ppapi::thunk::PPB_Surface3D_API; | 105 using ppapi::thunk::PPB_Surface3D_API; |
104 using ppapi::Var; | 106 using ppapi::Var; |
105 using WebKit::WebBindings; | 107 using WebKit::WebBindings; |
106 using WebKit::WebCanvas; | 108 using WebKit::WebCanvas; |
| 109 using WebKit::WebConsoleMessage; |
107 using WebKit::WebCursorInfo; | 110 using WebKit::WebCursorInfo; |
108 using WebKit::WebDocument; | 111 using WebKit::WebDocument; |
109 using WebKit::WebFrame; | 112 using WebKit::WebFrame; |
110 using WebKit::WebInputEvent; | 113 using WebKit::WebInputEvent; |
111 using WebKit::WebPluginContainer; | 114 using WebKit::WebPluginContainer; |
112 using WebKit::WebString; | 115 using WebKit::WebString; |
113 using WebKit::WebURLRequest; | 116 using WebKit::WebURLRequest; |
114 using WebKit::WebView; | 117 using WebKit::WebView; |
115 | 118 |
116 namespace webkit { | 119 namespace webkit { |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 try_catch.SetException("Exception caught"); | 1438 try_catch.SetException("Exception caught"); |
1436 WebBindings::releaseVariantValue(&result); | 1439 WebBindings::releaseVariantValue(&result); |
1437 return PP_MakeUndefined(); | 1440 return PP_MakeUndefined(); |
1438 } | 1441 } |
1439 | 1442 |
1440 PP_Var ret = NPVariantToPPVar(this, &result); | 1443 PP_Var ret = NPVariantToPPVar(this, &result); |
1441 WebBindings::releaseVariantValue(&result); | 1444 WebBindings::releaseVariantValue(&result); |
1442 return ret; | 1445 return ret; |
1443 } | 1446 } |
1444 | 1447 |
| 1448 void PluginInstance::Log(PP_Instance instance, |
| 1449 int log_level, |
| 1450 PP_Var value) { |
| 1451 // TODO(brettw) get the plugin name and use it as the source. |
| 1452 LogWithSource(instance, log_level, PP_MakeUndefined(), value); |
| 1453 } |
| 1454 |
| 1455 void PluginInstance::LogWithSource(PP_Instance instance, |
| 1456 int log_level, |
| 1457 PP_Var source, |
| 1458 PP_Var value) { |
| 1459 // Convert the log level, defaulting to error. |
| 1460 WebConsoleMessage::Level web_level; |
| 1461 switch (log_level) { |
| 1462 case PP_LOGLEVEL_TIP: |
| 1463 web_level = WebConsoleMessage::LevelTip; |
| 1464 break; |
| 1465 case PP_LOGLEVEL_LOG: |
| 1466 web_level = WebConsoleMessage::LevelLog; |
| 1467 break; |
| 1468 case PP_LOGLEVEL_WARNING: |
| 1469 web_level = WebConsoleMessage::LevelWarning; |
| 1470 break; |
| 1471 case PP_LOGLEVEL_ERROR: |
| 1472 default: |
| 1473 web_level = WebConsoleMessage::LevelError; |
| 1474 break; |
| 1475 } |
| 1476 |
| 1477 // Format is the "<source>: <value>". The source defaults to the module name |
| 1478 // if the source isn't a string or is empty. |
| 1479 std::string message; |
| 1480 if (source.type == PP_VARTYPE_STRING) |
| 1481 message = Var::PPVarToLogString(source); |
| 1482 if (message.empty()) |
| 1483 message = module()->name(); |
| 1484 message.append(": "); |
| 1485 message.append(Var::PPVarToLogString(value)); |
| 1486 |
| 1487 container()->element().document().frame()->addMessageToConsole( |
| 1488 WebConsoleMessage(web_level, WebString(UTF8ToUTF16(message)))); |
| 1489 } |
| 1490 |
1445 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { | 1491 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { |
1446 return PP_FromBool(fullscreen_); | 1492 return PP_FromBool(fullscreen_); |
1447 } | 1493 } |
1448 | 1494 |
1449 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, | 1495 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, |
1450 PP_Bool fullscreen) { | 1496 PP_Bool fullscreen) { |
1451 SetFullscreen(PP_ToBool(fullscreen), true); | 1497 SetFullscreen(PP_ToBool(fullscreen), true); |
1452 return PP_TRUE; | 1498 return PP_TRUE; |
1453 } | 1499 } |
1454 | 1500 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 } | 1587 } |
1542 | 1588 |
1543 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1589 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
1544 cursor_.reset(cursor); | 1590 cursor_.reset(cursor); |
1545 if (fullscreen_container_) | 1591 if (fullscreen_container_) |
1546 fullscreen_container_->DidChangeCursor(*cursor); | 1592 fullscreen_container_->DidChangeCursor(*cursor); |
1547 } | 1593 } |
1548 | 1594 |
1549 } // namespace ppapi | 1595 } // namespace ppapi |
1550 } // namespace webkit | 1596 } // namespace webkit |
OLD | NEW |