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

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 7874002: This patch tries to remove most of the manual registration for Pepper interfaces, and replaces it... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/ppb_console_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
===================================================================
--- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 100758)
+++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/utf_string_conversions.h"
+#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
@@ -38,6 +39,7 @@
#include "printing/units.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
@@ -104,6 +106,7 @@
using ppapi::Var;
using WebKit::WebBindings;
using WebKit::WebCanvas;
+using WebKit::WebConsoleMessage;
using WebKit::WebCursorInfo;
using WebKit::WebDocument;
using WebKit::WebFrame;
@@ -1442,6 +1445,49 @@
return ret;
}
+void PluginInstance::Log(PP_Instance instance,
+ int log_level,
+ PP_Var value) {
+ // TODO(brettw) get the plugin name and use it as the source.
+ LogWithSource(instance, log_level, PP_MakeUndefined(), value);
+}
+
+void PluginInstance::LogWithSource(PP_Instance instance,
+ int log_level,
+ PP_Var source,
+ PP_Var value) {
+ // Convert the log level, defaulting to error.
+ WebConsoleMessage::Level web_level;
+ switch (log_level) {
+ case PP_LOGLEVEL_TIP:
+ web_level = WebConsoleMessage::LevelTip;
+ break;
+ case PP_LOGLEVEL_LOG:
+ web_level = WebConsoleMessage::LevelLog;
+ break;
+ case PP_LOGLEVEL_WARNING:
+ web_level = WebConsoleMessage::LevelWarning;
+ break;
+ case PP_LOGLEVEL_ERROR:
+ default:
+ web_level = WebConsoleMessage::LevelError;
+ break;
+ }
+
+ // Format is the "<source>: <value>". The source defaults to the module name
+ // if the source isn't a string or is empty.
+ std::string message;
+ if (source.type == PP_VARTYPE_STRING)
+ message = Var::PPVarToLogString(source);
+ if (message.empty())
+ message = module()->name();
+ message.append(": ");
+ message.append(Var::PPVarToLogString(value));
+
+ container()->element().document().frame()->addMessageToConsole(
+ WebConsoleMessage(web_level, WebString(UTF8ToUTF16(message))));
+}
+
PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
return PP_FromBool(fullscreen_);
}
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/ppb_console_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698