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

Side by Side Diff: extensions/renderer/safe_builtins.cc

Issue 1115563002: extensions/renderer: Use v8::Local instead of v8::Handle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « extensions/renderer/resource_bundle_source_map.cc ('k') | extensions/renderer/script_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/safe_builtins.h" 5 #include "extensions/renderer/safe_builtins.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "extensions/renderer/script_context.h" 10 #include "extensions/renderer/script_context.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 void SaveImpl(const char* name, 130 void SaveImpl(const char* name,
131 v8::Local<v8::Value> value, 131 v8::Local<v8::Value> value,
132 v8::Local<v8::Context> context) { 132 v8::Local<v8::Context> context) {
133 CHECK(!value.IsEmpty() && value->IsObject()) << name; 133 CHECK(!value.IsEmpty() && value->IsObject()) << name;
134 context->Global()->SetHiddenValue(MakeKey(name, context->GetIsolate()), 134 context->Global()->SetHiddenValue(MakeKey(name, context->GetIsolate()),
135 value); 135 value);
136 } 136 }
137 137
138 v8::Local<v8::Object> Load(const char* name, v8::Handle<v8::Context> context) { 138 v8::Local<v8::Object> Load(const char* name, v8::Local<v8::Context> context) {
139 v8::Local<v8::Value> value = 139 v8::Local<v8::Value> value =
140 context->Global()->GetHiddenValue(MakeKey(name, context->GetIsolate())); 140 context->Global()->GetHiddenValue(MakeKey(name, context->GetIsolate()));
141 CHECK(!value.IsEmpty() && value->IsObject()) << name; 141 CHECK(!value.IsEmpty() && value->IsObject()) << name;
142 return v8::Local<v8::Object>::Cast(value); 142 return v8::Local<v8::Object>::Cast(value);
143 } 143 }
144 144
145 class ExtensionImpl : public v8::Extension { 145 class ExtensionImpl : public v8::Extension {
146 public: 146 public:
147 ExtensionImpl() : v8::Extension(kClassName, kScript) {} 147 ExtensionImpl() : v8::Extension(kClassName, kScript) {}
148 148
149 private: 149 private:
150 v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( 150 v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
151 v8::Isolate* isolate, 151 v8::Isolate* isolate,
152 v8::Handle<v8::String> name) override { 152 v8::Local<v8::String> name) override {
153 if (name->Equals(v8::String::NewFromUtf8(isolate, "Apply"))) 153 if (name->Equals(v8::String::NewFromUtf8(isolate, "Apply")))
154 return v8::FunctionTemplate::New(isolate, Apply); 154 return v8::FunctionTemplate::New(isolate, Apply);
155 if (name->Equals(v8::String::NewFromUtf8(isolate, "Save"))) 155 if (name->Equals(v8::String::NewFromUtf8(isolate, "Save")))
156 return v8::FunctionTemplate::New(isolate, Save); 156 return v8::FunctionTemplate::New(isolate, Save);
157 NOTREACHED() << *v8::String::Utf8Value(name); 157 NOTREACHED() << *v8::String::Utf8Value(name);
158 return v8::Handle<v8::FunctionTemplate>(); 158 return v8::Local<v8::FunctionTemplate>();
159 } 159 }
160 160
161 static void Apply(const v8::FunctionCallbackInfo<v8::Value>& info) { 161 static void Apply(const v8::FunctionCallbackInfo<v8::Value>& info) {
162 CHECK(info.Length() == 5 && info[0]->IsFunction() && // function 162 CHECK(info.Length() == 5 && info[0]->IsFunction() && // function
163 // info[1] could be an object or a string 163 // info[1] could be an object or a string
164 info[2]->IsObject() && // args 164 info[2]->IsObject() && // args
165 info[3]->IsInt32() && // first_arg_index 165 info[3]->IsInt32() && // first_arg_index
166 info[4]->IsInt32()); // args_length 166 info[4]->IsInt32()); // args_length
167 v8::Local<v8::Function> function = info[0].As<v8::Function>(); 167 v8::Local<v8::Function> function = info[0].As<v8::Function>();
168 v8::Local<v8::Object> recv; 168 v8::Local<v8::Object> recv;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 v8::Local<v8::Object> SafeBuiltins::GetString() const { 234 v8::Local<v8::Object> SafeBuiltins::GetString() const {
235 return Load("String", context_->v8_context()); 235 return Load("String", context_->v8_context());
236 } 236 }
237 237
238 v8::Local<v8::Object> SafeBuiltins::GetError() const { 238 v8::Local<v8::Object> SafeBuiltins::GetError() const {
239 return Load("Error", context_->v8_context()); 239 return Load("Error", context_->v8_context());
240 } 240 }
241 241
242 } // namespace extensions 242 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/resource_bundle_source_map.cc ('k') | extensions/renderer/script_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698