Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_IMP L_H_ | 5 #ifndef SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_IMP L_H_ |
| 6 #define SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_IMP L_H_ | 6 #define SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_IMP L_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "mojo/public/cpp/bindings/error_handler.h" | |
| 12 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 14 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati ng_url_loader_factory.mojom.h" | 13 #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" | 14 #include "mojo/services/authentication/public/interfaces/authentication.mojom.h" |
| 16 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | |
| 17 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 18 | 16 |
| 19 namespace mojo { | 17 namespace mojo { |
| 20 | 18 |
| 21 class ApplicationImpl; | 19 class ApplicationImpl; |
| 22 | 20 |
| 23 class AuthenticatingURLLoaderImpl; | |
| 24 | |
| 25 class AuthenticatingURLLoaderFactoryImpl | 21 class AuthenticatingURLLoaderFactoryImpl |
| 26 : public AuthenticatingURLLoaderFactory, | 22 : public AuthenticatingURLLoaderFactory { |
|
qsr
2015/06/05 10:54:55
This class doesn't seem to have any state in the e
blundell
2015/06/05 13:24:17
The application delegate maps the |cached_tokens|
| |
| 27 public ErrorHandler { | |
| 28 public: | 23 public: |
| 29 AuthenticatingURLLoaderFactoryImpl( | 24 AuthenticatingURLLoaderFactoryImpl( |
| 30 mojo::InterfaceRequest<AuthenticatingURLLoaderFactory> request, | 25 mojo::InterfaceRequest<AuthenticatingURLLoaderFactory> request, |
| 31 mojo::ApplicationImpl* app, | 26 mojo::ApplicationImpl* app, |
| 32 std::map<GURL, std::string>* cached_tokens); | 27 std::map<GURL, std::string>* cached_tokens); |
| 33 ~AuthenticatingURLLoaderFactoryImpl() override; | 28 ~AuthenticatingURLLoaderFactoryImpl() override; |
| 34 | 29 |
| 35 NetworkService* network_service() { return network_service_.get(); } | |
| 36 | |
| 37 // Returns a cached token for the given url (only considers the origin). Will | |
| 38 // returns an empty string if no token is cached. | |
| 39 std::string GetCachedToken(const GURL& url); | |
| 40 | |
| 41 void RetrieveToken(const GURL& url, | |
| 42 const base::Callback<void(std::string)>& callback); | |
| 43 | |
| 44 void OnURLLoaderError(AuthenticatingURLLoaderImpl* url_loader); | |
| 45 | |
| 46 private: | 30 private: |
| 47 // AuthenticatingURLLoaderFactory: | 31 // AuthenticatingURLLoaderFactory: |
| 48 void CreateAuthenticatingURLLoader( | 32 void CreateURLLoaderInterceptorFactory( |
| 49 mojo::InterfaceRequest<AuthenticatingURLLoader> loader_request) override; | 33 mojo::InterfaceRequest<URLLoaderInterceptorFactory> factory_request, |
| 50 void SetAuthenticationService( | |
| 51 authentication::AuthenticationServicePtr authentication_service) override; | 34 authentication::AuthenticationServicePtr authentication_service) override; |
| 52 | 35 |
| 53 // ErrorHandler: | |
| 54 void OnConnectionError() override; | |
| 55 | |
| 56 void OnAccountSelected(const GURL& origin, | |
| 57 mojo::String account, | |
| 58 mojo::String error); | |
| 59 | |
| 60 void OnOAuth2TokenReceived(const GURL& origin, | |
| 61 mojo::String token, | |
| 62 mojo::String error); | |
| 63 | |
| 64 void ExecuteCallbacks(const GURL& origin, const std::string& result); | |
| 65 | |
| 66 StrongBinding<AuthenticatingURLLoaderFactory> binding_; | 36 StrongBinding<AuthenticatingURLLoaderFactory> binding_; |
| 67 ApplicationImpl* app_; | 37 ApplicationImpl* app_; |
| 68 std::map<GURL, std::string>* cached_tokens_; | 38 std::map<GURL, std::string>* cached_tokens_; |
| 69 std::map<GURL, std::string> cached_accounts_; | 39 std::map<GURL, std::string> cached_accounts_; |
|
qsr
2015/06/05 10:54:55
You do not seem to be using this anymore.
blundell
2015/06/05 13:24:17
Done.
| |
| 70 authentication::AuthenticationServicePtr authentication_service_; | |
| 71 NetworkServicePtr network_service_; | |
| 72 std::vector<std::unique_ptr<AuthenticatingURLLoaderImpl>> url_loaders_; | |
| 73 std::map<GURL, std::vector<base::Callback<void(std::string)>>> | |
| 74 pendings_retrieve_token_; | |
| 75 }; | 40 }; |
| 76 | 41 |
| 77 } // namespace mojo | 42 } // namespace mojo |
| 78 | 43 |
| 79 #endif // SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_ IMPL_H_ | 44 #endif // SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_FACTORY_ IMPL_H_ |
| OLD | NEW |