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_policy_update_dev.h" | 18 #include "ppapi/c/dev/ppp_policy_update_dev.h" |
18 #include "ppapi/c/dev/ppp_selection_dev.h" | 19 #include "ppapi/c/dev/ppp_selection_dev.h" |
19 #include "ppapi/c/dev/ppp_zoom_dev.h" | 20 #include "ppapi/c/dev/ppp_zoom_dev.h" |
20 #include "ppapi/c/pp_input_event.h" | 21 #include "ppapi/c/pp_input_event.h" |
21 #include "ppapi/c/pp_instance.h" | 22 #include "ppapi/c/pp_instance.h" |
22 #include "ppapi/c/pp_rect.h" | 23 #include "ppapi/c/pp_rect.h" |
23 #include "ppapi/c/pp_resource.h" | 24 #include "ppapi/c/pp_resource.h" |
24 #include "ppapi/c/pp_var.h" | 25 #include "ppapi/c/pp_var.h" |
25 #include "ppapi/c/ppb_core.h" | 26 #include "ppapi/c/ppb_core.h" |
26 #include "ppapi/c/ppb_instance.h" | 27 #include "ppapi/c/ppb_instance.h" |
27 #include "ppapi/c/ppp_input_event.h" | 28 #include "ppapi/c/ppp_input_event.h" |
28 #include "ppapi/c/ppp_instance.h" | 29 #include "ppapi/c/ppp_instance.h" |
29 #include "ppapi/c/ppp_messaging.h" | 30 #include "ppapi/c/ppp_messaging.h" |
30 #include "ppapi/c/private/ppb_instance_private.h" | 31 #include "ppapi/c/private/ppb_instance_private.h" |
31 #include "ppapi/c/private/ppp_instance_private.h" | 32 #include "ppapi/c/private/ppp_instance_private.h" |
32 #include "ppapi/shared_impl/input_event_impl.h" | 33 #include "ppapi/shared_impl/input_event_impl.h" |
33 #include "ppapi/shared_impl/resource.h" | 34 #include "ppapi/shared_impl/resource.h" |
34 #include "ppapi/shared_impl/var.h" | 35 #include "ppapi/shared_impl/var.h" |
35 #include "ppapi/thunk/enter.h" | 36 #include "ppapi/thunk/enter.h" |
36 #include "ppapi/thunk/ppb_buffer_api.h" | 37 #include "ppapi/thunk/ppb_buffer_api.h" |
37 #include "printing/units.h" | 38 #include "printing/units.h" |
38 #include "skia/ext/platform_canvas.h" | 39 #include "skia/ext/platform_canvas.h" |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 using ppapi::thunk::EnterResourceNoLock; | 98 using ppapi::thunk::EnterResourceNoLock; |
97 using ppapi::thunk::PPB_Buffer_API; | 99 using ppapi::thunk::PPB_Buffer_API; |
98 using ppapi::thunk::PPB_Graphics2D_API; | 100 using ppapi::thunk::PPB_Graphics2D_API; |
99 using ppapi::thunk::PPB_Graphics3D_API; | 101 using ppapi::thunk::PPB_Graphics3D_API; |
100 using ppapi::thunk::PPB_ImageData_API; | 102 using ppapi::thunk::PPB_ImageData_API; |
101 using ppapi::thunk::PPB_Instance_FunctionAPI; | 103 using ppapi::thunk::PPB_Instance_FunctionAPI; |
102 using ppapi::thunk::PPB_Surface3D_API; | 104 using ppapi::thunk::PPB_Surface3D_API; |
103 using ppapi::Var; | 105 using ppapi::Var; |
104 using WebKit::WebBindings; | 106 using WebKit::WebBindings; |
105 using WebKit::WebCanvas; | 107 using WebKit::WebCanvas; |
| 108 using WebKit::WebConsoleMessage; |
106 using WebKit::WebCursorInfo; | 109 using WebKit::WebCursorInfo; |
107 using WebKit::WebDocument; | 110 using WebKit::WebDocument; |
108 using WebKit::WebFrame; | 111 using WebKit::WebFrame; |
109 using WebKit::WebInputEvent; | 112 using WebKit::WebInputEvent; |
110 using WebKit::WebPluginContainer; | 113 using WebKit::WebPluginContainer; |
111 using WebKit::WebString; | 114 using WebKit::WebString; |
112 using WebKit::WebURLRequest; | 115 using WebKit::WebURLRequest; |
113 using WebKit::WebView; | 116 using WebKit::WebView; |
114 | 117 |
115 namespace webkit { | 118 namespace webkit { |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 try_catch.SetException("Exception caught"); | 1408 try_catch.SetException("Exception caught"); |
1406 WebBindings::releaseVariantValue(&result); | 1409 WebBindings::releaseVariantValue(&result); |
1407 return PP_MakeUndefined(); | 1410 return PP_MakeUndefined(); |
1408 } | 1411 } |
1409 | 1412 |
1410 PP_Var ret = NPVariantToPPVar(this, &result); | 1413 PP_Var ret = NPVariantToPPVar(this, &result); |
1411 WebBindings::releaseVariantValue(&result); | 1414 WebBindings::releaseVariantValue(&result); |
1412 return ret; | 1415 return ret; |
1413 } | 1416 } |
1414 | 1417 |
| 1418 void PluginInstance::Log(PP_Instance instance, |
| 1419 int log_level, |
| 1420 PP_Var value) { |
| 1421 // TODO(brettw) get the plugin name and use it as the source. |
| 1422 LogWithSource(instance, log_level, PP_MakeUndefined(), value); |
| 1423 } |
| 1424 |
| 1425 void PluginInstance::LogWithSource(PP_Instance instance, |
| 1426 int log_level, |
| 1427 PP_Var source, |
| 1428 PP_Var value) { |
| 1429 // Convert the log level, defaulting to error. |
| 1430 WebConsoleMessage::Level web_level; |
| 1431 switch (log_level) { |
| 1432 case PP_LOGLEVEL_TIP: |
| 1433 web_level = WebConsoleMessage::LevelTip; |
| 1434 break; |
| 1435 case PP_LOGLEVEL_LOG: |
| 1436 web_level = WebConsoleMessage::LevelLog; |
| 1437 break; |
| 1438 case PP_LOGLEVEL_WARNING: |
| 1439 web_level = WebConsoleMessage::LevelWarning; |
| 1440 break; |
| 1441 case PP_LOGLEVEL_ERROR: |
| 1442 default: |
| 1443 web_level = WebConsoleMessage::LevelError; |
| 1444 break; |
| 1445 } |
| 1446 |
| 1447 // Format is the "<source>: <value>". The source defaults to the module name |
| 1448 // if the source isn't a string or is empty. |
| 1449 std::string message; |
| 1450 if (source.type == PP_VARTYPE_STRING) |
| 1451 message = Var::PPVarToLogString(source); |
| 1452 if (message.empty()) |
| 1453 message = module()->name(); |
| 1454 message.append(": "); |
| 1455 message.append(Var::PPVarToLogString(value)); |
| 1456 |
| 1457 container()->element().document().frame()->addMessageToConsole( |
| 1458 WebConsoleMessage(web_level, WebString(UTF8ToUTF16(message)))); |
| 1459 } |
| 1460 |
1415 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { | 1461 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { |
1416 return PP_FromBool(fullscreen_); | 1462 return PP_FromBool(fullscreen_); |
1417 } | 1463 } |
1418 | 1464 |
1419 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, | 1465 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, |
1420 PP_Bool fullscreen) { | 1466 PP_Bool fullscreen) { |
1421 SetFullscreen(PP_ToBool(fullscreen), true); | 1467 SetFullscreen(PP_ToBool(fullscreen), true); |
1422 return PP_TRUE; | 1468 return PP_TRUE; |
1423 } | 1469 } |
1424 | 1470 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 } | 1532 } |
1487 | 1533 |
1488 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1534 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
1489 cursor_.reset(cursor); | 1535 cursor_.reset(cursor); |
1490 if (fullscreen_container_) | 1536 if (fullscreen_container_) |
1491 fullscreen_container_->DidChangeCursor(*cursor); | 1537 fullscreen_container_->DidChangeCursor(*cursor); |
1492 } | 1538 } |
1493 | 1539 |
1494 } // namespace ppapi | 1540 } // namespace ppapi |
1495 } // namespace webkit | 1541 } // namespace webkit |
OLD | NEW |