| 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 "shell/application_manager/application_manager.h" | 5 #include "shell/application_manager/application_manager.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 InterfaceRequest<ServiceProvider> services, | 179 InterfaceRequest<ServiceProvider> services, |
| 180 ServiceProviderPtr exposed_services) { | 180 ServiceProviderPtr exposed_services) { |
| 181 shell_impl->ConnectToClient(requestor_url, services.Pass(), | 181 shell_impl->ConnectToClient(requestor_url, services.Pass(), |
| 182 exposed_services.Pass()); | 182 exposed_services.Pass()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void ApplicationManager::RegisterExternalApplication( | 185 void ApplicationManager::RegisterExternalApplication( |
| 186 const GURL& url, | 186 const GURL& url, |
| 187 const std::vector<std::string>& args, | 187 const std::vector<std::string>& args, |
| 188 ApplicationPtr application) { | 188 ApplicationPtr application) { |
| 189 const auto& args_it = url_to_args_.find(url); | |
| 190 if (args_it != url_to_args_.end()) { | |
| 191 LOG(WARNING) << "--args-for provided for external application " | |
| 192 << url | |
| 193 << " <ignored>"; | |
| 194 } | |
| 195 ShellImpl* shell_impl = new ShellImpl(application.Pass(), this, url, url); | 189 ShellImpl* shell_impl = new ShellImpl(application.Pass(), this, url, url); |
| 196 url_to_shell_impl_[url] = shell_impl; | 190 url_to_shell_impl_[url] = shell_impl; |
| 197 shell_impl->InitializeApplication(Array<String>::From(args)); | 191 |
| 192 if (args.empty()) |
| 193 shell_impl->InitializeApplication(GetArgsForURL(url)); |
| 194 else |
| 195 shell_impl->InitializeApplication(Array<String>::From(args)); |
| 198 } | 196 } |
| 199 | 197 |
| 200 void ApplicationManager::LoadWithContentHandler( | 198 void ApplicationManager::LoadWithContentHandler( |
| 201 const GURL& content_handler_url, | 199 const GURL& content_handler_url, |
| 202 InterfaceRequest<Application> application_request, | 200 InterfaceRequest<Application> application_request, |
| 203 URLResponsePtr url_response) { | 201 URLResponsePtr url_response) { |
| 204 ContentHandlerConnection* connection = NULL; | 202 ContentHandlerConnection* connection = NULL; |
| 205 URLToContentHandlerMap::iterator iter = | 203 URLToContentHandlerMap::iterator iter = |
| 206 url_to_content_handler_.find(content_handler_url); | 204 url_to_content_handler_.find(content_handler_url); |
| 207 if (iter != url_to_content_handler_.end()) { | 205 if (iter != url_to_content_handler_.end()) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const GURL& application_url, | 278 const GURL& application_url, |
| 281 const std::string& interface_name) { | 279 const std::string& interface_name) { |
| 282 ServiceProviderPtr services; | 280 ServiceProviderPtr services; |
| 283 ConnectToApplication(application_url, GURL(), GetProxy(&services), nullptr); | 281 ConnectToApplication(application_url, GURL(), GetProxy(&services), nullptr); |
| 284 MessagePipe pipe; | 282 MessagePipe pipe; |
| 285 services->ConnectToService(interface_name, pipe.handle1.Pass()); | 283 services->ConnectToService(interface_name, pipe.handle1.Pass()); |
| 286 return pipe.handle0.Pass(); | 284 return pipe.handle0.Pass(); |
| 287 } | 285 } |
| 288 | 286 |
| 289 Array<String> ApplicationManager::GetArgsForURL(const GURL& url) { | 287 Array<String> ApplicationManager::GetArgsForURL(const GURL& url) { |
| 290 const auto& args_it = url_to_args_.find(url); | 288 URLToArgsMap::const_iterator args_it = url_to_args_.find(url); |
| 291 if (args_it != url_to_args_.end()) | 289 if (args_it != url_to_args_.end()) |
| 292 return Array<String>::From(args_it->second); | 290 return Array<String>::From(args_it->second); |
| 293 return Array<String>(); | 291 return Array<String>(); |
| 294 } | 292 } |
| 295 } // namespace mojo | 293 } // namespace mojo |
| OLD | NEW |