| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "content/public/renderer/render_frame.h" |
| 13 #include "content/public/renderer/render_view.h" | 14 #include "content/public/renderer/render_view.h" |
| 14 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 15 #include "extensions/common/extensions_client.h" | 16 #include "extensions/common/extensions_client.h" |
| 16 #include "extensions/renderer/console.h" | 17 #include "extensions/renderer/console.h" |
| 17 #include "extensions/renderer/safe_builtins.h" | 18 #include "extensions/renderer/safe_builtins.h" |
| 18 #include "extensions/renderer/script_context.h" | 19 #include "extensions/renderer/script_context.h" |
| 19 #include "gin/modules/module_registry.h" | 20 #include "gin/modules/module_registry.h" |
| 20 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | 22 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
| 22 | 23 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::Bind(&ModuleSystem::Private, base::Unretained(this))); | 138 base::Bind(&ModuleSystem::Private, base::Unretained(this))); |
| 138 | 139 |
| 139 v8::Handle<v8::Object> global(context->v8_context()->Global()); | 140 v8::Handle<v8::Object> global(context->v8_context()->Global()); |
| 140 v8::Isolate* isolate = context->isolate(); | 141 v8::Isolate* isolate = context->isolate(); |
| 141 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModulesField), | 142 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModulesField), |
| 142 v8::Object::New(isolate)); | 143 v8::Object::New(isolate)); |
| 143 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModuleSystem), | 144 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModuleSystem), |
| 144 v8::External::New(isolate, this)); | 145 v8::External::New(isolate, this)); |
| 145 | 146 |
| 146 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); | 147 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); |
| 148 if (context_->GetRenderFrame()) { |
| 149 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( |
| 150 context->isolate(), context->v8_context()); |
| 151 } |
| 147 } | 152 } |
| 148 | 153 |
| 149 ModuleSystem::~ModuleSystem() { Invalidate(); } | 154 ModuleSystem::~ModuleSystem() { Invalidate(); } |
| 150 | 155 |
| 151 void ModuleSystem::Invalidate() { | 156 void ModuleSystem::Invalidate() { |
| 152 if (!is_valid()) | 157 if (!is_valid()) |
| 153 return; | 158 return; |
| 154 | 159 |
| 155 // Clear the module system properties from the global context. It's polite, | 160 // Clear the module system properties from the global context. It's polite, |
| 156 // and we use this as a signal in lazy handlers that we no longer exist. | 161 // and we use this as a signal in lazy handlers that we no longer exist. |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 v8::Handle<v8::Value> value) { | 666 v8::Handle<v8::Value> value) { |
| 662 if (!is_valid()) | 667 if (!is_valid()) |
| 663 return; | 668 return; |
| 664 v8::HandleScope handle_scope(GetIsolate()); | 669 v8::HandleScope handle_scope(GetIsolate()); |
| 665 v8::Handle<v8::Promise::Resolver> resolver_local( | 670 v8::Handle<v8::Promise::Resolver> resolver_local( |
| 666 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); | 671 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); |
| 667 resolver_local->Resolve(value); | 672 resolver_local->Resolve(value); |
| 668 } | 673 } |
| 669 | 674 |
| 670 } // namespace extensions | 675 } // namespace extensions |
| OLD | NEW |