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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 base::Bind(&ModuleSystem::RequireAsync, base::Unretained(this))); | 162 base::Bind(&ModuleSystem::RequireAsync, base::Unretained(this))); |
| 163 RouteFunction("privates", | 163 RouteFunction("privates", |
| 164 base::Bind(&ModuleSystem::Private, base::Unretained(this))); | 164 base::Bind(&ModuleSystem::Private, base::Unretained(this))); |
| 165 | 165 |
| 166 v8::Local<v8::Object> global(context->v8_context()->Global()); | 166 v8::Local<v8::Object> global(context->v8_context()->Global()); |
| 167 v8::Isolate* isolate = context->isolate(); | 167 v8::Isolate* isolate = context->isolate(); |
| 168 SetPrivate(global, kModulesField, v8::Object::New(isolate)); | 168 SetPrivate(global, kModulesField, v8::Object::New(isolate)); |
| 169 SetPrivate(global, kModuleSystem, v8::External::New(isolate, this)); | 169 SetPrivate(global, kModuleSystem, v8::External::New(isolate, this)); |
| 170 | 170 |
| 171 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); | 171 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); |
| 172 if (context_->GetRenderFrame()) { | 172 // TODO(devlin): We really shouldn't be injecting mojo into every blessed |
| 173 // extension context - it's wasteful. But it's better than injecting into | |
| 174 // every frame (previous behavior) so start with this while we investigate | |
| 175 // further. See crbug.com/636655. | |
| 176 if (context_->GetRenderFrame() && | |
| 177 context_->context_type() == Feature::BLESSED_EXTENSION_CONTEXT) { | |
|
haraken
2016/08/18 01:42:59
Does this mean that we don't inject mojo bindings
Devlin
2016/08/18 02:01:36
This means we only inject bindings for extension f
| |
| 173 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( | 178 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( |
| 174 context->isolate(), context->v8_context()); | 179 context->isolate(), context->v8_context()); |
| 175 } | 180 } |
| 176 } | 181 } |
| 177 | 182 |
| 178 ModuleSystem::~ModuleSystem() { | 183 ModuleSystem::~ModuleSystem() { |
| 179 } | 184 } |
| 180 | 185 |
| 181 void ModuleSystem::Invalidate() { | 186 void ModuleSystem::Invalidate() { |
| 182 // Clear the module system properties from the global context. It's polite, | 187 // Clear the module system properties from the global context. It's polite, |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 | 762 |
| 758 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { | 763 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { |
| 759 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); | 764 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); |
| 760 if (existing_handler != native_handler_map_.end()) { | 765 if (existing_handler != native_handler_map_.end()) { |
| 761 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); | 766 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); |
| 762 native_handler_map_.erase(existing_handler); | 767 native_handler_map_.erase(existing_handler); |
| 763 } | 768 } |
| 764 } | 769 } |
| 765 | 770 |
| 766 } // namespace extensions | 771 } // namespace extensions |
| OLD | NEW |