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 "content/renderer/web_ui_mojo_context_state.h" | 5 #include "content/renderer/web_ui_mojo_context_state.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
10 #include "content/public/renderer/resource_fetcher.h" | 10 #include "content/public/renderer/resource_fetcher.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // All modules have this prefixed to them when downloading. | 32 // All modules have this prefixed to them when downloading. |
33 // TODO(sky): move this into some common place. | 33 // TODO(sky): move this into some common place. |
34 const char kModulePrefix[] = "chrome://mojo/"; | 34 const char kModulePrefix[] = "chrome://mojo/"; |
35 | 35 |
36 void RunMain(base::WeakPtr<gin::Runner> runner, | 36 void RunMain(base::WeakPtr<gin::Runner> runner, |
37 v8::Handle<v8::Value> module) { | 37 v8::Local<v8::Value> module) { |
38 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); | 38 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); |
39 v8::Handle<v8::Function> start; | 39 v8::Local<v8::Function> start; |
40 CHECK(gin::ConvertFromV8(isolate, module, &start)); | 40 CHECK(gin::ConvertFromV8(isolate, module, &start)); |
41 runner->Call(start, runner->global(), 0, NULL); | 41 runner->Call(start, runner->global(), 0, NULL); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // WebUIMojo ------------------------------------------------------------------- | 46 // WebUIMojo ------------------------------------------------------------------- |
47 | 47 |
48 WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame, | 48 WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame, |
49 v8::Handle<v8::Context> context) | 49 v8::Local<v8::Context> context) |
50 : frame_(frame), | 50 : frame_(frame), |
51 module_added_(false) { | 51 module_added_(false) { |
52 gin::PerContextData* context_data = gin::PerContextData::From(context); | 52 gin::PerContextData* context_data = gin::PerContextData::From(context); |
53 gin::ContextHolder* context_holder = context_data->context_holder(); | 53 gin::ContextHolder* context_holder = context_data->context_holder(); |
54 runner_.reset(new WebUIRunner(frame_, context_holder)); | 54 runner_.reset(new WebUIRunner(frame_, context_holder)); |
55 gin::Runner::Scope scoper(runner_.get()); | 55 gin::Runner::Scope scoper(runner_.get()); |
56 gin::ModuleRegistry::From(context)->AddObserver(this); | 56 gin::ModuleRegistry::From(context)->AddObserver(this); |
57 content::RenderFrame::FromWebFrame(frame) | 57 content::RenderFrame::FromWebFrame(frame) |
58 ->EnsureMojoBuiltinsAreAvailable(context_holder->isolate(), context); | 58 ->EnsureMojoBuiltinsAreAvailable(context_holder->isolate(), context); |
59 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global()); | 59 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const std::vector<std::string>& dependencies) { | 131 const std::vector<std::string>& dependencies) { |
132 FetchModules(dependencies); | 132 FetchModules(dependencies); |
133 | 133 |
134 gin::ContextHolder* context_holder = runner_->GetContextHolder(); | 134 gin::ContextHolder* context_holder = runner_->GetContextHolder(); |
135 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( | 135 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( |
136 context_holder->context()); | 136 context_holder->context()); |
137 registry->AttemptToLoadMoreModules(context_holder->isolate()); | 137 registry->AttemptToLoadMoreModules(context_holder->isolate()); |
138 } | 138 } |
139 | 139 |
140 } // namespace content | 140 } // namespace content |
OLD | NEW |