| OLD | NEW |
| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers | 98 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers |
| 99 << ": '" << parts[i + 1] << "' is not a valid URL."; | 99 << ": '" << parts[i + 1] << "' is not a valid URL."; |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 // TODO(eseidel): We should also validate that the mimetype is valid | 102 // TODO(eseidel): We should also validate that the mimetype is valid |
| 103 // net/base/mime_util.h could do this, but we don't want to depend on net. | 103 // net/base/mime_util.h could do this, but we don't want to depend on net. |
| 104 loader->RegisterContentHandler(parts[i], url); | 104 loader->RegisterContentHandler(parts[i], url); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { | |
| 109 private: | |
| 110 void ConnectToService(const mojo::String& service_name, | |
| 111 ScopedMessagePipeHandle client_handle) override {} | |
| 112 }; | |
| 113 | |
| 114 bool ConfigureURLMappings(const std::string& mappings, | 108 bool ConfigureURLMappings(const std::string& mappings, |
| 115 mojo::shell::MojoURLResolver* resolver) { | 109 mojo::shell::MojoURLResolver* resolver) { |
| 116 base::StringPairs pairs; | 110 base::StringPairs pairs; |
| 117 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) | 111 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) |
| 118 return false; | 112 return false; |
| 119 using StringPair = std::pair<std::string, std::string>; | 113 using StringPair = std::pair<std::string, std::string>; |
| 120 for (const StringPair& pair : pairs) { | 114 for (const StringPair& pair : pairs) { |
| 121 const GURL from(pair.first); | 115 const GURL from(pair.first); |
| 122 const GURL to(pair.second); | 116 const GURL to(pair.second); |
| 123 if (!from.is_valid() || !to.is_valid()) | 117 if (!from.is_valid() || !to.is_valid()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) | 199 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) |
| 206 base::MessageLoop::current()->Quit(); | 200 base::MessageLoop::current()->Quit(); |
| 207 } | 201 } |
| 208 } | 202 } |
| 209 | 203 |
| 210 GURL Context::ResolveURL(const GURL& url) { | 204 GURL Context::ResolveURL(const GURL& url) { |
| 211 return mojo_url_resolver_.Resolve(url); | 205 return mojo_url_resolver_.Resolve(url); |
| 212 } | 206 } |
| 213 | 207 |
| 214 void Context::Run(const GURL& url) { | 208 void Context::Run(const GURL& url) { |
| 215 EmptyServiceProvider* sp = new EmptyServiceProvider; | 209 ServiceProviderPtr services; |
| 216 ServiceProviderPtr spp; | 210 ServiceProviderPtr exposed_services; |
| 217 BindToProxy(sp, &spp); | |
| 218 | 211 |
| 219 app_urls_.insert(url); | 212 app_urls_.insert(url); |
| 220 application_manager_.ConnectToApplication(url, GURL(), spp.Pass()); | 213 application_manager_.ConnectToApplication(url, GURL(), GetProxy(&services), |
| 214 exposed_services.Pass()); |
| 221 } | 215 } |
| 222 | 216 |
| 223 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 217 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
| 224 const GURL& application_url, | 218 const GURL& application_url, |
| 225 const std::string& service_name) { | 219 const std::string& service_name) { |
| 226 app_urls_.insert(application_url); | 220 app_urls_.insert(application_url); |
| 227 return application_manager_.ConnectToServiceByName(application_url, | 221 return application_manager_.ConnectToServiceByName(application_url, |
| 228 service_name).Pass(); | 222 service_name).Pass(); |
| 229 } | 223 } |
| 230 | 224 |
| 231 } // namespace shell | 225 } // namespace shell |
| 232 } // namespace mojo | 226 } // namespace mojo |
| OLD | NEW |