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

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

Issue 2412783002: Only inject mojo builtins to contexts with the mojoPrivate API feature. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « extensions/common/api/_api_features.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 // 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() && 172 if (context_->GetRenderFrame() &&
177 context_->context_type() == Feature::BLESSED_EXTENSION_CONTEXT) { 173 context_->context_type() == Feature::BLESSED_EXTENSION_CONTEXT &&
174 context_->GetAvailability("mojoPrivate").is_available()) {
Devlin 2016/10/12 14:58:09 This doesn't seem to be quite the right relationsh
Sam McNally 2016/10/13 07:13:08 Done. mojoPrivate does need to make the builtins
178 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( 175 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable(
179 context->isolate(), context->v8_context()); 176 context->isolate(), context->v8_context());
180 } 177 }
181 } 178 }
182 179
183 ModuleSystem::~ModuleSystem() { 180 ModuleSystem::~ModuleSystem() {
184 } 181 }
185 182
186 void ModuleSystem::Invalidate() { 183 void ModuleSystem::Invalidate() {
187 // Clear the module system properties from the global context. It's polite, 184 // Clear the module system properties from the global context. It's polite,
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 759
763 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { 760 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) {
764 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); 761 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name);
765 if (existing_handler != native_handler_map_.end()) { 762 if (existing_handler != native_handler_map_.end()) {
766 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); 763 clobbered_native_handlers_.push_back(std::move(existing_handler->second));
767 native_handler_map_.erase(existing_handler); 764 native_handler_map_.erase(existing_handler);
768 } 765 }
769 } 766 }
770 767
771 } // namespace extensions 768 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/api/_api_features.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698