Revert "Enable DMP for system Chromium WebView on Android"
[chromium-blink-merge.git] / gin / modules / module_runner_delegate.cc
blob16b5afd0303ba8a8819cbe54aef25ec8c4c24a84
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gin/modules/module_runner_delegate.h"
7 #include "gin/modules/module_registry.h"
8 #include "gin/object_template_builder.h"
9 #include "gin/public/context_holder.h"
11 namespace gin {
13 ModuleRunnerDelegate::ModuleRunnerDelegate(
14 const std::vector<base::FilePath>& search_paths)
15 : module_provider_(search_paths) {
18 ModuleRunnerDelegate::~ModuleRunnerDelegate() {
21 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
22 ModuleGetter getter) {
23 builtin_modules_[id] = getter;
26 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) {
27 ModuleRegistry* registry = ModuleRegistry::From(
28 runner->GetContextHolder()->context());
29 registry->AttemptToLoadMoreModules(runner->GetContextHolder()->isolate());
30 module_provider_.AttempToLoadModules(
31 runner, registry->unsatisfied_dependencies());
34 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
35 ShellRunner* runner,
36 v8::Isolate* isolate) {
37 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate).Build();
38 ModuleRegistry::RegisterGlobals(isolate, templ);
39 return templ;
42 void ModuleRunnerDelegate::DidCreateContext(ShellRunner* runner) {
43 ShellRunnerDelegate::DidCreateContext(runner);
45 v8::Handle<v8::Context> context = runner->GetContextHolder()->context();
46 ModuleRegistry* registry = ModuleRegistry::From(context);
48 v8::Isolate* isolate = runner->GetContextHolder()->isolate();
49 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
50 it != builtin_modules_.end(); ++it) {
51 registry->AddBuiltinModule(isolate, it->first, it->second(isolate));
55 void ModuleRunnerDelegate::DidRunScript(ShellRunner* runner) {
56 AttemptToLoadMoreModules(runner);
59 } // namespace gin