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

Side by Side Diff: shell/application_manager/application_manager.cc

Issue 1155283003: Change AuthenticatingURLLoader to be a URLLoaderInterceptor (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address review Created 5 years, 6 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 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "mojo/public/cpp/bindings/error_handler.h" 14 #include "mojo/public/cpp/bindings/error_handler.h"
15 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati ng_url_loader_factory.mojom.h"
15 #include "mojo/services/authentication/public/interfaces/authentication.mojom.h" 16 #include "mojo/services/authentication/public/interfaces/authentication.mojom.h"
16 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h" 17 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h"
17 #include "shell/application_manager/fetcher.h" 18 #include "shell/application_manager/fetcher.h"
18 #include "shell/application_manager/local_fetcher.h" 19 #include "shell/application_manager/local_fetcher.h"
19 #include "shell/application_manager/network_fetcher.h" 20 #include "shell/application_manager/network_fetcher.h"
20 #include "shell/application_manager/query_util.h" 21 #include "shell/application_manager/query_util.h"
21 #include "shell/application_manager/shell_impl.h" 22 #include "shell/application_manager/shell_impl.h"
22 23
23 using mojo::Application; 24 using mojo::Application;
24 using mojo::ApplicationPtr; 25 using mojo::ApplicationPtr;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 bool ApplicationManager::TestAPI::HasFactoryForURL(const GURL& url) const { 94 bool ApplicationManager::TestAPI::HasFactoryForURL(const GURL& url) const {
94 return manager_->identity_to_shell_impl_.find(Identity(url)) != 95 return manager_->identity_to_shell_impl_.find(Identity(url)) !=
95 manager_->identity_to_shell_impl_.end(); 96 manager_->identity_to_shell_impl_.end();
96 } 97 }
97 98
98 ApplicationManager::ApplicationManager(const Options& options, 99 ApplicationManager::ApplicationManager(const Options& options,
99 Delegate* delegate) 100 Delegate* delegate)
100 : options_(options), 101 : options_(options),
101 delegate_(delegate), 102 delegate_(delegate),
102 blocking_pool_(nullptr), 103 blocking_pool_(nullptr),
103 initialized_authentication_service_(false), 104 initialized_authentication_interceptor_(false),
104 weak_ptr_factory_(this) { 105 weak_ptr_factory_(this) {
105 } 106 }
106 107
107 ApplicationManager::~ApplicationManager() { 108 ApplicationManager::~ApplicationManager() {
108 } 109 }
109 110
110 void ApplicationManager::TerminateShellConnections() { 111 void ApplicationManager::TerminateShellConnections() {
111 identity_to_shell_impl_.clear(); 112 identity_to_shell_impl_.clear();
112 } 113 }
113 114
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr), 182 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr),
182 callback); 183 callback);
183 return; 184 return;
184 } 185 }
185 186
186 if (!url_response_disk_cache_) { 187 if (!url_response_disk_cache_) {
187 ConnectToService(GURL("mojo:url_response_disk_cache"), 188 ConnectToService(GURL("mojo:url_response_disk_cache"),
188 &url_response_disk_cache_); 189 &url_response_disk_cache_);
189 } 190 }
190 191
191 if (!url_loader_factory_) { 192 if (!network_service_) {
192 ConnectToService(GURL("mojo:authenticating_url_loader"), 193 ConnectToService(GURL("mojo:network_service"), &network_service_);
193 &url_loader_factory_);
194 } 194 }
195 195
196 // NOTE: Attempting to initialize the AuthenticationService while connecting 196 // NOTE: Attempting to initialize the apps used authentication for while
197 // to the AuthenticationService would result in a recursive loop, so it has 197 // connecting to those apps would result in a recursive loop, so it has to be
198 // to be explicitly avoided here. AuthenticatingURLLoaders work fine without 198 // explicitly avoided here. What this means in practice is that these apps
199 // the AuthenticationService as long as authentication is not needed, so what 199 // cannot themselves require authentication to obtain.
200 // this means in practice is that the AuthenticationService cannot itself 200 if (!initialized_authentication_interceptor_ &&
201 // require authentication to obtain. 201 !EndsWith(resolved_url.path(), "/authentication.mojo", true) &&
202 if (!initialized_authentication_service_ && 202 !EndsWith(resolved_url.path(), "/authenticating_url_loader.mojo", true)) {
203 !EndsWith(resolved_url.path(), "/authentication.mojo", true)) {
204 authentication::AuthenticationServicePtr authentication_service; 203 authentication::AuthenticationServicePtr authentication_service;
205 ConnectToService(GURL("mojo:authentication"), &authentication_service); 204 ConnectToService(GURL("mojo:authentication"), &authentication_service);
206 url_loader_factory_->SetAuthenticationService( 205 mojo::AuthenticatingURLLoaderFactoryPtr url_loader_factory;
207 authentication_service.Pass()); 206 ConnectToService(GURL("mojo:authenticating_url_loader"),
208 initialized_authentication_service_ = true; 207 &url_loader_factory);
208 mojo::URLLoaderInterceptorFactoryPtr interceptor_factory;
209 url_loader_factory->CreateURLLoaderInterceptorFactory(
210 GetProxy(&interceptor_factory), authentication_service.Pass());
211 network_service_->RegisterURLLoaderInterceptor(interceptor_factory.Pass());
212 initialized_authentication_interceptor_ = true;
209 } 213 }
210 214
211 new NetworkFetcher(options_.disable_cache, options_.predictable_app_filenames, 215 new NetworkFetcher(options_.disable_cache, options_.predictable_app_filenames,
212 resolved_url, url_response_disk_cache_.get(), 216 resolved_url, url_response_disk_cache_.get(),
213 url_loader_factory_.get(), callback); 217 network_service_.get(), callback);
214 } 218 }
215 219
216 bool ApplicationManager::ConnectToRunningApplication( 220 bool ApplicationManager::ConnectToRunningApplication(
217 const GURL& resolved_url, 221 const GURL& resolved_url,
218 const GURL& requestor_url, 222 const GURL& requestor_url,
219 InterfaceRequest<ServiceProvider>* services, 223 InterfaceRequest<ServiceProvider>* services,
220 ServiceProviderPtr* exposed_services) { 224 ServiceProviderPtr* exposed_services) {
221 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr); 225 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr);
222 ShellImpl* shell_impl = GetShellImpl(application_url); 226 ShellImpl* shell_impl = GetShellImpl(application_url);
223 if (!shell_impl) 227 if (!shell_impl)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return args_it->second; 504 return args_it->second;
501 return std::vector<std::string>(); 505 return std::vector<std::string>();
502 } 506 }
503 507
504 void ApplicationManager::CleanupRunner(NativeRunner* runner) { 508 void ApplicationManager::CleanupRunner(NativeRunner* runner) {
505 native_runners_.erase( 509 native_runners_.erase(
506 std::find(native_runners_.begin(), native_runners_.end(), runner)); 510 std::find(native_runners_.begin(), native_runners_.end(), runner));
507 } 511 }
508 512
509 } // namespace shell 513 } // namespace shell
OLDNEW
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/application_manager/network_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698