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

Unified Diff: chrome/renderer/extensions/safe_builtins.cc

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 | « chrome/renderer/extensions/safe_builtins.h ('k') | chrome/renderer/resources/extensions/ad_view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/safe_builtins.cc
diff --git a/chrome/renderer/extensions/safe_builtins.cc b/chrome/renderer/extensions/safe_builtins.cc
index 05f67fca6ce9be9d211882e503c1d34665dda7be..2a58bf291cee6212e9d35e7693f72fa125c7cf13 100644
--- a/chrome/renderer/extensions/safe_builtins.cc
+++ b/chrome/renderer/extensions/safe_builtins.cc
@@ -150,17 +150,21 @@ class ExtensionImpl : public v8::Extension {
static void Apply(const v8::FunctionCallbackInfo<v8::Value>& info) {
CHECK(info.Length() == 5 &&
info[0]->IsFunction() && // function
- // info[1]->Object() // recv (will throw error not check)
+ // info[1] could be an object or a string
info[2]->IsObject() && // args
info[3]->IsInt32() && // first_arg_index
info[4]->IsInt32()); // args_length
- if (!info[1]->IsObject()) {
+ v8::Local<v8::Function> function = info[0].As<v8::Function>();
+ v8::Local<v8::Object> recv;
+ if (info[1]->IsObject()) {
+ recv = info[1]->ToObject();
+ } else if (info[1]->IsString()) {
+ recv = v8::StringObject::New(info[1]->ToString())->ToObject();
+ } else {
v8::ThrowException(v8::Exception::TypeError(v8::String::New(
"The first argument is the receiver and must be an object")));
return;
}
- v8::Local<v8::Function> function = info[0].As<v8::Function>();
- v8::Local<v8::Object> recv = info[1]->ToObject();
v8::Local<v8::Object> args = info[2]->ToObject();
int first_arg_index = static_cast<int>(info[3]->ToInt32()->Value());
int args_length = static_cast<int>(info[4]->ToInt32()->Value());
@@ -214,4 +218,12 @@ v8::Local<v8::Object> SafeBuiltins::GetObjekt() const {
return Load("Object", context_->v8_context());
}
+v8::Local<v8::Object> SafeBuiltins::GetRegExp() const {
+ return Load("RegExp", context_->v8_context());
+}
+
+v8::Local<v8::Object> SafeBuiltins::GetString() const {
+ return Load("String", context_->v8_context());
+}
+
} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/safe_builtins.h ('k') | chrome/renderer/resources/extensions/ad_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698