Chromium Code Reviews| 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/module_system.h" | 5 #include "extensions/renderer/module_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 } | 545 } |
| 546 | 546 |
| 547 v8::Handle<v8::String> ModuleSystem::WrapSource(v8::Handle<v8::String> source) { | 547 v8::Handle<v8::String> ModuleSystem::WrapSource(v8::Handle<v8::String> source) { |
| 548 v8::EscapableHandleScope handle_scope(GetIsolate()); | 548 v8::EscapableHandleScope handle_scope(GetIsolate()); |
| 549 // Keep in order with the arguments in RequireForJsInner. | 549 // Keep in order with the arguments in RequireForJsInner. |
| 550 v8::Handle<v8::String> left = v8::String::NewFromUtf8( | 550 v8::Handle<v8::String> left = v8::String::NewFromUtf8( |
| 551 GetIsolate(), | 551 GetIsolate(), |
| 552 "(function(define, require, requireNative, requireAsync, exports, " | 552 "(function(define, require, requireNative, requireAsync, exports, " |
| 553 "console, privates," | 553 "console, privates," |
| 554 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" | 554 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" |
| 555 "'use strict';"); | 555 "'use strict';" |
| 556 "var Error = window.Error;"); | |
|
not at google - send to devlin
2014/08/18 16:09:44
This isn't any more desirable than using Error in
robwu
2014/08/18 20:59:46
This protects against redefining the global Error
not at google - send to devlin
2014/08/18 23:13:10
Maybe I'm misunderstanding - that doesn't prevent
robwu
2014/08/18 23:27:18
I assumed that the module system is run before the
not at google - send to devlin
2014/08/18 23:39:16
Right. Unfortunately that's not true, these module
robwu
2014/08/19 14:21:54
Done.
| |
| 556 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})"); | 557 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})"); |
| 557 return handle_scope.Escape(v8::Local<v8::String>( | 558 return handle_scope.Escape(v8::Local<v8::String>( |
| 558 v8::String::Concat(left, v8::String::Concat(source, right)))); | 559 v8::String::Concat(left, v8::String::Concat(source, right)))); |
| 559 } | 560 } |
| 560 | 561 |
| 561 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { | 562 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 562 CHECK_EQ(1, args.Length()); | 563 CHECK_EQ(1, args.Length()); |
| 563 CHECK(args[0]->IsObject()); | 564 CHECK(args[0]->IsObject()); |
| 564 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); | 565 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); |
| 565 v8::Local<v8::String> privates_key = | 566 v8::Local<v8::String> privates_key = |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 v8::Handle<v8::Value> value) { | 661 v8::Handle<v8::Value> value) { |
| 661 if (!is_valid()) | 662 if (!is_valid()) |
| 662 return; | 663 return; |
| 663 v8::HandleScope handle_scope(GetIsolate()); | 664 v8::HandleScope handle_scope(GetIsolate()); |
| 664 v8::Handle<v8::Promise::Resolver> resolver_local( | 665 v8::Handle<v8::Promise::Resolver> resolver_local( |
| 665 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); | 666 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); |
| 666 resolver_local->Resolve(value); | 667 resolver_local->Resolve(value); |
| 667 } | 668 } |
| 668 | 669 |
| 669 } // namespace extensions | 670 } // namespace extensions |
| OLD | NEW |