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

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

Issue 482603002: Unify logic of stack trace generation for extension errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add $Error and $String.indexOf to safe builtins Created 6 years, 4 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
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/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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 LoadModule(module_name); 544 LoadModule(module_name);
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, $Error) {"
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;");
560 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})"); 556 v8::Handle<v8::String> right = v8::String::NewFromUtf8(GetIsolate(), "\n})");
561 return handle_scope.Escape(v8::Local<v8::String>( 557 return handle_scope.Escape(v8::Local<v8::String>(
562 v8::String::Concat(left, v8::String::Concat(source, right)))); 558 v8::String::Concat(left, v8::String::Concat(source, right))));
563 } 559 }
564 560
565 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { 561 void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) {
566 CHECK_EQ(1, args.Length()); 562 CHECK_EQ(1, args.Length());
567 CHECK(args[0]->IsObject()); 563 CHECK(args[0]->IsObject());
568 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); 564 v8::Local<v8::Object> obj = args[0].As<v8::Object>();
569 v8::Local<v8::String> privates_key = 565 v8::Local<v8::String> privates_key =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 console::AsV8Object(), 617 console::AsV8Object(),
622 natives->Get(v8::String::NewFromUtf8( 618 natives->Get(v8::String::NewFromUtf8(
623 GetIsolate(), "privates", v8::String::kInternalizedString)), 619 GetIsolate(), "privates", v8::String::kInternalizedString)),
624 // Each safe builtin. Keep in order with the arguments in WrapSource. 620 // Each safe builtin. Keep in order with the arguments in WrapSource.
625 context_->safe_builtins()->GetArray(), 621 context_->safe_builtins()->GetArray(),
626 context_->safe_builtins()->GetFunction(), 622 context_->safe_builtins()->GetFunction(),
627 context_->safe_builtins()->GetJSON(), 623 context_->safe_builtins()->GetJSON(),
628 context_->safe_builtins()->GetObjekt(), 624 context_->safe_builtins()->GetObjekt(),
629 context_->safe_builtins()->GetRegExp(), 625 context_->safe_builtins()->GetRegExp(),
630 context_->safe_builtins()->GetString(), 626 context_->safe_builtins()->GetString(),
627 context_->safe_builtins()->GetError(),
631 }; 628 };
632 { 629 {
633 v8::TryCatch try_catch; 630 v8::TryCatch try_catch;
634 try_catch.SetCaptureMessage(true); 631 try_catch.SetCaptureMessage(true);
635 context_->CallFunction(func, arraysize(args), args); 632 context_->CallFunction(func, arraysize(args), args);
636 if (try_catch.HasCaught()) { 633 if (try_catch.HasCaught()) {
637 HandleException(try_catch); 634 HandleException(try_catch);
638 return v8::Undefined(GetIsolate()); 635 return v8::Undefined(GetIsolate());
639 } 636 }
640 } 637 }
(...skipping 23 matching lines...) Expand all
664 v8::Handle<v8::Value> value) { 661 v8::Handle<v8::Value> value) {
665 if (!is_valid()) 662 if (!is_valid())
666 return; 663 return;
667 v8::HandleScope handle_scope(GetIsolate()); 664 v8::HandleScope handle_scope(GetIsolate());
668 v8::Handle<v8::Promise::Resolver> resolver_local( 665 v8::Handle<v8::Promise::Resolver> resolver_local(
669 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); 666 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver));
670 resolver_local->Resolve(value); 667 resolver_local->Resolve(value);
671 } 668 }
672 669
673 } // namespace extensions 670 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/resources/binding.js » ('j') | extensions/renderer/resources/binding.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698