summaryrefslogtreecommitdiffstats
path: root/extensions/renderer
diff options
context:
space:
mode:
authoraboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 18:37:14 +0000
committeraboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 18:37:14 +0000
commited51006db1465dc8542bb6508514fd89414f3f3b (patch)
tree6972994063c5793502e7a96882360d4dda516c87 /extensions/renderer
parent09f60dd57009ea1ac711bf6592e9d90fe66a9e78 (diff)
downloadchromium_src-ed51006db1465dc8542bb6508514fd89414f3f3b.zip
chromium_src-ed51006db1465dc8542bb6508514fd89414f3f3b.tar.gz
chromium_src-ed51006db1465dc8542bb6508514fd89414f3f3b.tar.bz2
This replaces AutomationTree with AutomationRootNode, which is a regular node which happens to be the root of the tree as well, and contains the lookup table for all other nodes etc.
BUG=309681 TBR=jam@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/311913002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/renderer')
-rw-r--r--extensions/renderer/resources/utils.js13
-rw-r--r--extensions/renderer/utils_native_handler.cc30
2 files changed, 28 insertions, 15 deletions
diff --git a/extensions/renderer/resources/utils.js b/extensions/renderer/resources/utils.js
index dd1ec2a..853c652 100644
--- a/extensions/renderer/resources/utils.js
+++ b/extensions/renderer/resources/utils.js
@@ -72,15 +72,18 @@ function loadTypeSchema(typeName, defaultSchema) {
* instance of the implementation class).
* @param {string} name The name of the exposed wrapper class.
* @param {Object} cls The class implementation.
- * @param {{functions: ?Array.<string>,
+ * @param {{superclass: ?Function,
+ * functions: ?Array.<string>,
* properties: ?Array.<string>,
* readonly: ?Array.<string>}} exposed The names of properties on the
- * implementation class to be exposed. |functions| represents the names of
- * functions which should be delegated to the implementation; |properties|
- * are gettable/settable properties and |readonly| are read-only properties.
+ * implementation class to be exposed. |superclass| represents the
+ * constructor of the class to be used as the superclass of the exposed
+ * class; |functions| represents the names of functions which should be
+ * delegated to the implementation; |properties| are gettable/settable
+ * properties and |readonly| are read-only properties.
*/
function expose(name, cls, exposed) {
- var publicClass = createClassWrapper(name, cls);
+ var publicClass = createClassWrapper(name, cls, exposed.superclass);
if ('functions' in exposed) {
$Array.forEach(exposed.functions, function(func) {
diff --git a/extensions/renderer/utils_native_handler.cc b/extensions/renderer/utils_native_handler.cc
index 5c8bf5d..1c0941f 100644
--- a/extensions/renderer/utils_native_handler.cc
+++ b/extensions/renderer/utils_native_handler.cc
@@ -21,25 +21,34 @@ UtilsNativeHandler::~UtilsNativeHandler() {}
void UtilsNativeHandler::CreateClassWrapper(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK_EQ(2, args.Length());
+ CHECK_EQ(3, args.Length());
CHECK(args[0]->IsString());
std::string name = *v8::String::Utf8Value(args[0]);
CHECK(args[1]->IsObject());
- v8::Local<v8::Object> obj = args[1].As<v8::Object>();
+ v8::Local<v8::Object> cls = args[1].As<v8::Object>();
+ CHECK(args[2]->IsObject() || args[2]->IsUndefined());
+ v8::Local<v8::Value> superclass = args[2];
v8::HandleScope handle_scope(GetIsolate());
// TODO(fsamuel): Consider moving the source wrapping to ModuleSystem.
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
GetIsolate(),
base::StringPrintf(
- "(function($Object, $Function, privates, cls) {"
+ "(function($Object, $Function, privates, cls, superclass) {"
"'use strict';\n"
- " return function %s() {\n"
- " var privateObj = $Object.create(cls.prototype);\n"
- " $Function.apply(cls, privateObj, arguments);\n"
- " privateObj.wrapper = this;\n"
- " privates(this).impl = privateObj;\n"
- "}})",
+ " function %s() {\n"
+ " var privateObj = $Object.create(cls.prototype);\n"
+ " $Function.apply(cls, privateObj, arguments);\n"
+ " privateObj.wrapper = this;\n"
+ " privates(this).impl = privateObj;\n"
+ " };\n"
+ " if (superclass) {\n"
+ " %s.prototype = Object.create(superclass.prototype);\n"
+ " }\n"
+ " return %s;\n"
+ "})",
+ name.c_str(),
+ name.c_str(),
name.c_str()).c_str());
v8::Handle<v8::Value> func_as_value = context()->module_system()->RunString(
source, v8::String::NewFromUtf8(GetIsolate(), name.c_str()));
@@ -57,7 +66,8 @@ void UtilsNativeHandler::CreateClassWrapper(
context()->safe_builtins()->GetFunction(),
natives->Get(v8::String::NewFromUtf8(
GetIsolate(), "privates", v8::String::kInternalizedString)),
- obj};
+ cls,
+ superclass};
v8::Local<v8::Value> result;
{
v8::TryCatch try_catch;