OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/module_system.h" | 5 #include "chrome/renderer/extensions/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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 v8::Handle<v8::Value> ModuleSystem::RunString(v8::Handle<v8::String> code, | 465 v8::Handle<v8::Value> ModuleSystem::RunString(v8::Handle<v8::String> code, |
466 v8::Handle<v8::String> name) { | 466 v8::Handle<v8::String> name) { |
467 v8::HandleScope handle_scope(GetIsolate()); | 467 v8::HandleScope handle_scope(GetIsolate()); |
468 v8::Context::Scope context_scope(context()->v8_context()); | 468 v8::Context::Scope context_scope(context()->v8_context()); |
469 | 469 |
470 // Prepend extensions:: to |name| so that internal code can be differentiated | 470 // Prepend extensions:: to |name| so that internal code can be differentiated |
471 // from external code in stack traces. This has no effect on behaviour. | 471 // from external code in stack traces. This has no effect on behaviour. |
472 std::string internal_name = base::StringPrintf("extensions::%s", | 472 std::string internal_name = base::StringPrintf("extensions::%s", |
473 *v8::String::Utf8Value(name)); | 473 *v8::String::Utf8Value(name)); |
474 | 474 |
475 WebKit::WebScopedMicrotaskSuppression suppression; | 475 blink::WebScopedMicrotaskSuppression suppression; |
476 v8::TryCatch try_catch; | 476 v8::TryCatch try_catch; |
477 try_catch.SetCaptureMessage(true); | 477 try_catch.SetCaptureMessage(true); |
478 v8::Handle<v8::Script> script(v8::Script::New( | 478 v8::Handle<v8::Script> script(v8::Script::New( |
479 code, v8::String::New(internal_name.c_str(), internal_name.size()))); | 479 code, v8::String::New(internal_name.c_str(), internal_name.size()))); |
480 if (try_catch.HasCaught()) { | 480 if (try_catch.HasCaught()) { |
481 HandleException(try_catch); | 481 HandleException(try_catch); |
482 return v8::Undefined(); | 482 return v8::Undefined(); |
483 } | 483 } |
484 | 484 |
485 v8::Handle<v8::Value> result = script->Run(); | 485 v8::Handle<v8::Value> result = script->Run(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 "(function(require, requireNative, exports, " | 536 "(function(require, requireNative, exports, " |
537 "console, " | 537 "console, " |
538 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" | 538 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" |
539 "'use strict';"); | 539 "'use strict';"); |
540 v8::Handle<v8::String> right = v8::String::New("\n})"); | 540 v8::Handle<v8::String> right = v8::String::New("\n})"); |
541 return handle_scope.Close( | 541 return handle_scope.Close( |
542 v8::String::Concat(left, v8::String::Concat(source, right))); | 542 v8::String::Concat(left, v8::String::Concat(source, right))); |
543 } | 543 } |
544 | 544 |
545 } // namespace extensions | 545 } // namespace extensions |
OLD | NEW |