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

Side by Side Diff: content/renderer/mojo_context_state.cc

Issue 2869663002: ResourceFetcher::Start should be given a WebLocalFrame (Closed)
Patch Set: fix Created 3 years, 7 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 | « content/renderer/mojo_context_state.h ('k') | content/renderer/resource_fetcher_browsertest.cc » ('j') | 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 "content/renderer/mojo_context_state.h" 5 #include "content/renderer/mojo_context_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 11 matching lines...) Expand all
22 #include "content/renderer/mojo_bindings_controller.h" 22 #include "content/renderer/mojo_bindings_controller.h"
23 #include "content/renderer/mojo_main_runner.h" 23 #include "content/renderer/mojo_main_runner.h"
24 #include "gin/converter.h" 24 #include "gin/converter.h"
25 #include "gin/modules/module_registry.h" 25 #include "gin/modules/module_registry.h"
26 #include "gin/per_context_data.h" 26 #include "gin/per_context_data.h"
27 #include "gin/public/context_holder.h" 27 #include "gin/public/context_holder.h"
28 #include "gin/try_catch.h" 28 #include "gin/try_catch.h"
29 #include "mojo/public/js/constants.h" 29 #include "mojo/public/js/constants.h"
30 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 30 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
31 #include "third_party/WebKit/public/platform/WebURLResponse.h" 31 #include "third_party/WebKit/public/platform/WebURLResponse.h"
32 #include "third_party/WebKit/public/web/WebFrame.h" 32 #include "third_party/WebKit/public/web/WebLocalFrame.h"
33 #include "third_party/WebKit/public/web/WebScriptSource.h" 33 #include "third_party/WebKit/public/web/WebScriptSource.h"
34 34
35 using v8::Context; 35 using v8::Context;
36 using v8::HandleScope; 36 using v8::HandleScope;
37 using v8::Isolate; 37 using v8::Isolate;
38 using v8::Object; 38 using v8::Object;
39 using v8::ObjectTemplate; 39 using v8::ObjectTemplate;
40 using v8::Script; 40 using v8::Script;
41 41
42 namespace content { 42 namespace content {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 DCHECK(module_sources); 104 DCHECK(module_sources);
105 auto source_iter = module_sources->find(path); 105 auto source_iter = module_sources->find(path);
106 if (source_iter == module_sources->end()) 106 if (source_iter == module_sources->end())
107 return nullptr; 107 return nullptr;
108 return source_iter->second; 108 return source_iter->second;
109 } 109 }
110 110
111 std::string GetModulePrefixForBindingsType(MojoBindingsType bindings_type, 111 std::string GetModulePrefixForBindingsType(MojoBindingsType bindings_type,
112 blink::WebFrame* frame) { 112 blink::WebLocalFrame* frame) {
113 switch (bindings_type) { 113 switch (bindings_type) {
114 case MojoBindingsType::FOR_WEB_UI: 114 case MojoBindingsType::FOR_WEB_UI:
115 return frame->GetSecurityOrigin().ToString().Utf8() + "/"; 115 return frame->GetSecurityOrigin().ToString().Utf8() + "/";
116 case MojoBindingsType::FOR_LAYOUT_TESTS: 116 case MojoBindingsType::FOR_LAYOUT_TESTS:
117 return "layout-test-mojom://"; 117 return "layout-test-mojom://";
118 case MojoBindingsType::FOR_HEADLESS: 118 case MojoBindingsType::FOR_HEADLESS:
119 return "headless-mojom://"; 119 return "headless-mojom://";
120 } 120 }
121 NOTREACHED(); 121 NOTREACHED();
122 return ""; 122 return "";
123 } 123 }
124 124
125 } // namespace 125 } // namespace
126 126
127 MojoContextState::MojoContextState(blink::WebFrame* frame, 127 MojoContextState::MojoContextState(blink::WebLocalFrame* frame,
128 v8::Local<v8::Context> context, 128 v8::Local<v8::Context> context,
129 MojoBindingsType bindings_type) 129 MojoBindingsType bindings_type)
130 : frame_(frame), 130 : frame_(frame),
131 module_added_(false), 131 module_added_(false),
132 module_prefix_(GetModulePrefixForBindingsType(bindings_type, frame)) { 132 module_prefix_(GetModulePrefixForBindingsType(bindings_type, frame)) {
133 gin::PerContextData* context_data = gin::PerContextData::From(context); 133 gin::PerContextData* context_data = gin::PerContextData::From(context);
134 gin::ContextHolder* context_holder = context_data->context_holder(); 134 gin::ContextHolder* context_holder = context_data->context_holder();
135 runner_.reset(new MojoMainRunner(frame_, context_holder)); 135 runner_.reset(new MojoMainRunner(frame_, context_holder));
136 gin::Runner::Scope scoper(runner_.get()); 136 gin::Runner::Scope scoper(runner_.get());
137 gin::ModuleRegistry::From(context)->AddObserver(this); 137 gin::ModuleRegistry::From(context)->AddObserver(this);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 const std::vector<std::string>& dependencies) { 233 const std::vector<std::string>& dependencies) {
234 FetchModules(dependencies); 234 FetchModules(dependencies);
235 235
236 gin::ContextHolder* context_holder = runner_->GetContextHolder(); 236 gin::ContextHolder* context_holder = runner_->GetContextHolder();
237 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( 237 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(
238 context_holder->context()); 238 context_holder->context());
239 registry->AttemptToLoadMoreModules(context_holder->isolate()); 239 registry->AttemptToLoadMoreModules(context_holder->isolate());
240 } 240 }
241 241
242 } // namespace content 242 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mojo_context_state.h ('k') | content/renderer/resource_fetcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698