| 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 // Prevent extensions from overriding the Error constructor. |
| 557 // Use window.Error instead of $Error to make sure that extensions can |
| 558 // still use "instanceof Error" for exception handling. |
| 559 "var Error = window.Error;"); |
| 556 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})"); | 560 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})"); |
| 557 return handle_scope.Escape(v8::Local<v8::String>( | 561 return handle_scope.Escape(v8::Local<v8::String>( |
| 558 v8::String::Concat(left, v8::String::Concat(source, right)))); | 562 v8::String::Concat(left, v8::String::Concat(source, right)))); |
| 559 } | 563 } |
| 560 | 564 |
| 561 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { | 565 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 562 CHECK_EQ(1, args.Length()); | 566 CHECK_EQ(1, args.Length()); |
| 563 CHECK(args[0]->IsObject()); | 567 CHECK(args[0]->IsObject()); |
| 564 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); | 568 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); |
| 565 v8::Local<v8::String> privates_key = | 569 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) { | 664 v8::Handle<v8::Value> value) { |
| 661 if (!is_valid()) | 665 if (!is_valid()) |
| 662 return; | 666 return; |
| 663 v8::HandleScope handle_scope(GetIsolate()); | 667 v8::HandleScope handle_scope(GetIsolate()); |
| 664 v8::Handle<v8::Promise::Resolver> resolver_local( | 668 v8::Handle<v8::Promise::Resolver> resolver_local( |
| 665 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); | 669 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); |
| 666 resolver_local->Resolve(value); | 670 resolver_local->Resolve(value); |
| 667 } | 671 } |
| 668 | 672 |
| 669 } // namespace extensions | 673 } // namespace extensions |
| OLD | NEW |