Commit 74f31070 authored by aa@chromium.org's avatar aa@chromium.org

Add a Print() method to bindings JS for last resort debugging.

BUG=
TEST=


Review URL: http://codereview.chromium.org/7640005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96524 0039d316-1c4b-4281-b951-d872f2087c98
parent 02175aef
......@@ -4,9 +4,11 @@
#include "chrome/renderer/extensions/bindings_utils.h"
#include "base/logging.h"
#include "base/lazy_instance.h"
#include "base/stringprintf.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/renderer/extensions/extension_dispatcher.h"
......@@ -84,6 +86,10 @@ v8::Handle<v8::FunctionTemplate>
return v8::FunctionTemplate::New(GetChromeHidden);
}
if (name->Equals(v8::String::New("Print"))) {
return v8::FunctionTemplate::New(Print);
}
return v8::Handle<v8::FunctionTemplate>();
}
......@@ -110,6 +116,18 @@ v8::Handle<v8::Value> ExtensionBase::GetChromeHidden(
return hidden;
}
v8::Handle<v8::Value> ExtensionBase::Print(const v8::Arguments& args) {
if (args.Length() < 1)
return v8::Undefined();
std::vector<std::string> components;
for (int i = 0; i < args.Length(); ++i)
components.push_back(*v8::String::Utf8Value(args[i]->ToString()));
LOG(ERROR) << JoinString(components, ',');
return v8::Undefined();
}
ContextInfo::ContextInfo(v8::Persistent<v8::Context> context,
const std::string& extension_id,
WebKit::WebFrame* parent_frame,
......
......@@ -67,6 +67,10 @@ class ExtensionBase : public v8::Extension {
static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args);
ExtensionDispatcher* extension_dispatcher_;
private:
// Helper to print from bindings javascript.
static v8::Handle<v8::Value> Print(const v8::Arguments& args);
};
const char* GetStringResource(int resource_id);
......
......@@ -8,6 +8,7 @@ var chrome = chrome || {};
native function AttachEvent(eventName);
native function DetachEvent(eventName);
native function GetExternalFileEntry(fileDefinition);
native function Print();
var chromeHidden = GetChromeHidden();
......
......@@ -23,6 +23,7 @@ var chrome = chrome || {};
native function GetUniqueSubEventName(eventName);
native function GetLocalFileSystem(name, path);
native function DecodeJPEG(jpeg_image);
native function Print();
var chromeHidden = GetChromeHidden();
......@@ -77,8 +78,6 @@ var chrome = chrome || {};
throw new Error(message);
} else if (!schemas[i].optional) {
console.log(chromeHidden.JSON.stringify(args));
console.log(chromeHidden.JSON.stringify(schemas));
throw new Error("Parameter " + (i + 1) + " is required.");
}
}
......
......@@ -17,6 +17,7 @@ var chrome = chrome || {};
native function PostMessage(portId, msg);
native function GetChromeHidden();
native function GetL10nMessage();
native function Print();
var chromeHidden = GetChromeHidden();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment