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

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

Issue 2409073002: Use mojo from the PDF extension instead of using an extension API.
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
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()) {
175 gin::ModuleRegistry::InstallGlobals(context->isolate(),
176 context->v8_context()->Global());
178 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( 177 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable(
179 context->isolate(), context->v8_context()); 178 context->isolate(), context->v8_context());
180 } 179 }
181 } 180 }
182 181
183 ModuleSystem::~ModuleSystem() { 182 ModuleSystem::~ModuleSystem() {
184 } 183 }
185 184
186 void ModuleSystem::Invalidate() { 185 void ModuleSystem::Invalidate() {
187 // Clear the module system properties from the global context. It's polite, 186 // 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 761
763 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { 762 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) {
764 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); 763 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name);
765 if (existing_handler != native_handler_map_.end()) { 764 if (existing_handler != native_handler_map_.end()) {
766 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); 765 clobbered_native_handlers_.push_back(std::move(existing_handler->second));
767 native_handler_map_.erase(existing_handler); 766 native_handler_map_.erase(existing_handler);
768 } 767 }
769 } 768 }
770 769
771 } // namespace extensions 770 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/mojo/keep_alive_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698