OLD | NEW |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return value->ToObject(); | 141 return value->ToObject(); |
142 } | 142 } |
143 | 143 |
144 class ExtensionImpl : public v8::Extension { | 144 class ExtensionImpl : public v8::Extension { |
145 public: | 145 public: |
146 ExtensionImpl() : v8::Extension(kClassName, kScript) {} | 146 ExtensionImpl() : v8::Extension(kClassName, kScript) {} |
147 | 147 |
148 private: | 148 private: |
149 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 149 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
150 v8::Isolate* isolate, | 150 v8::Isolate* isolate, |
151 v8::Handle<v8::String> name) OVERRIDE { | 151 v8::Handle<v8::String> name) override { |
152 if (name->Equals(v8::String::NewFromUtf8(isolate, "Apply"))) | 152 if (name->Equals(v8::String::NewFromUtf8(isolate, "Apply"))) |
153 return v8::FunctionTemplate::New(isolate, Apply); | 153 return v8::FunctionTemplate::New(isolate, Apply); |
154 if (name->Equals(v8::String::NewFromUtf8(isolate, "Save"))) | 154 if (name->Equals(v8::String::NewFromUtf8(isolate, "Save"))) |
155 return v8::FunctionTemplate::New(isolate, Save); | 155 return v8::FunctionTemplate::New(isolate, Save); |
156 NOTREACHED() << *v8::String::Utf8Value(name); | 156 NOTREACHED() << *v8::String::Utf8Value(name); |
157 return v8::Handle<v8::FunctionTemplate>(); | 157 return v8::Handle<v8::FunctionTemplate>(); |
158 } | 158 } |
159 | 159 |
160 static void Apply(const v8::FunctionCallbackInfo<v8::Value>& info) { | 160 static void Apply(const v8::FunctionCallbackInfo<v8::Value>& info) { |
161 CHECK(info.Length() == 5 && info[0]->IsFunction() && // function | 161 CHECK(info.Length() == 5 && info[0]->IsFunction() && // function |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 v8::Local<v8::Object> SafeBuiltins::GetString() const { | 232 v8::Local<v8::Object> SafeBuiltins::GetString() const { |
233 return Load("String", context_->v8_context()); | 233 return Load("String", context_->v8_context()); |
234 } | 234 } |
235 | 235 |
236 v8::Local<v8::Object> SafeBuiltins::GetError() const { | 236 v8::Local<v8::Object> SafeBuiltins::GetError() const { |
237 return Load("Error", context_->v8_context()); | 237 return Load("Error", context_->v8_context()); |
238 } | 238 } |
239 | 239 |
240 } // namespace extensions | 240 } // namespace extensions |
OLD | NEW |