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

Side by Side Diff: shell/context.cc

Issue 926093003: AddOriginMapping() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Comments Created 5 years, 10 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 2013 The Chromium Authors. All rights reserved. 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 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 "shell/context.h" 5 #include "shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 10 matching lines...) Expand all
21 #include "mojo/common/trace_controller_impl.h" 21 #include "mojo/common/trace_controller_impl.h"
22 #include "mojo/common/tracing_impl.h" 22 #include "mojo/common/tracing_impl.h"
23 #include "mojo/edk/embedder/embedder.h" 23 #include "mojo/edk/embedder/embedder.h"
24 #include "mojo/edk/embedder/simple_platform_support.h" 24 #include "mojo/edk/embedder/simple_platform_support.h"
25 #include "mojo/public/cpp/application/application_connection.h" 25 #include "mojo/public/cpp/application/application_connection.h"
26 #include "mojo/public/cpp/application/application_delegate.h" 26 #include "mojo/public/cpp/application/application_delegate.h"
27 #include "mojo/public/cpp/application/application_impl.h" 27 #include "mojo/public/cpp/application/application_impl.h"
28 #include "services/tracing/tracing.mojom.h" 28 #include "services/tracing/tracing.mojom.h"
29 #include "shell/application_manager/application_loader.h" 29 #include "shell/application_manager/application_loader.h"
30 #include "shell/application_manager/application_manager.h" 30 #include "shell/application_manager/application_manager.h"
31 #include "shell/command_line_util.h"
31 #include "shell/dynamic_application_loader.h" 32 #include "shell/dynamic_application_loader.h"
32 #include "shell/external_application_listener.h" 33 #include "shell/external_application_listener.h"
33 #include "shell/filename_util.h" 34 #include "shell/filename_util.h"
34 #include "shell/in_process_dynamic_service_runner.h" 35 #include "shell/in_process_dynamic_service_runner.h"
35 #include "shell/out_of_process_dynamic_service_runner.h" 36 #include "shell/out_of_process_dynamic_service_runner.h"
36 #include "shell/switches.h" 37 #include "shell/switches.h"
37 #include "url/gurl.h" 38 #include "url/gurl.h"
38 39
39 namespace mojo { 40 namespace mojo {
40 namespace shell { 41 namespace shell {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 resolver->SetMojoBaseURL(base_url); 121 resolver->SetMojoBaseURL(base_url);
121 122
122 // The network service must be loaded from the filesystem. 123 // The network service must be loaded from the filesystem.
123 // This mapping is done before the command line URL mapping are processed, so 124 // This mapping is done before the command line URL mapping are processed, so
124 // that it can be overridden. 125 // that it can be overridden.
125 resolver->AddURLMapping( 126 resolver->AddURLMapping(
126 GURL("mojo:network_service"), 127 GURL("mojo:network_service"),
127 context->ResolveShellFileURL("file:network_service.mojo")); 128 context->ResolveShellFileURL("file:network_service.mojo"));
128 129
129 // Command line URL mapping. 130 // Command line URL mapping.
131 std::vector<URLResolver::OriginMapping> origin_mappings =
132 URLResolver::GetOriginMappings(command_line->argv());
133 for (const auto& origin_mapping : origin_mappings)
134 resolver->AddOriginMapping(GURL(origin_mapping.origin),
135 GURL(origin_mapping.base_url));
136
130 if (command_line->HasSwitch(switches::kURLMappings)) { 137 if (command_line->HasSwitch(switches::kURLMappings)) {
131 const std::string mappings = 138 const std::string mappings =
132 command_line->GetSwitchValueASCII(switches::kURLMappings); 139 command_line->GetSwitchValueASCII(switches::kURLMappings);
133 140
134 base::StringPairs pairs; 141 base::StringPairs pairs;
135 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) 142 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs))
136 return false; 143 return false;
137 using StringPair = std::pair<std::string, std::string>; 144 using StringPair = std::pair<std::string, std::string>;
138 for (const StringPair& pair : pairs) { 145 for (const StringPair& pair : pairs) {
139 const GURL from(pair.first); 146 const GURL from(pair.first);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) 274 if (app_urls_.empty() && base::MessageLoop::current()->is_running())
268 base::MessageLoop::current()->Quit(); 275 base::MessageLoop::current()->Quit();
269 } 276 }
270 } 277 }
271 278
272 GURL Context::ResolveURL(const GURL& url) { 279 GURL Context::ResolveURL(const GURL& url) {
273 return url_resolver_.ResolveMojoURL(url); 280 return url_resolver_.ResolveMojoURL(url);
274 } 281 }
275 282
276 GURL Context::ResolveMappings(const GURL& url) { 283 GURL Context::ResolveMappings(const GURL& url) {
277 return url_resolver_.ApplyURLMappings(url); 284 return url_resolver_.ApplyMappings(url);
278 } 285 }
279 286
280 void Context::Run(const GURL& url) { 287 void Context::Run(const GURL& url) {
281 ServiceProviderPtr services; 288 ServiceProviderPtr services;
282 ServiceProviderPtr exposed_services; 289 ServiceProviderPtr exposed_services;
283 290
284 app_urls_.insert(url); 291 app_urls_.insert(url);
285 application_manager_.ConnectToApplication(url, GURL(), GetProxy(&services), 292 application_manager_.ConnectToApplication(url, GURL(), GetProxy(&services),
286 exposed_services.Pass()); 293 exposed_services.Pass());
287 } 294 }
288 295
289 ScopedMessagePipeHandle Context::ConnectToServiceByName( 296 ScopedMessagePipeHandle Context::ConnectToServiceByName(
290 const GURL& application_url, 297 const GURL& application_url,
291 const std::string& service_name) { 298 const std::string& service_name) {
292 app_urls_.insert(application_url); 299 app_urls_.insert(application_url);
293 return application_manager_.ConnectToServiceByName(application_url, 300 return application_manager_.ConnectToServiceByName(application_url,
294 service_name).Pass(); 301 service_name).Pass();
295 } 302 }
296 303
297 } // namespace shell 304 } // namespace shell
298 } // namespace mojo 305 } // namespace mojo
OLDNEW
« no previous file with comments | « services/console/console.cc ('k') | shell/switches.h » ('j') | shell/switches.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698