| 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 #ifndef COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ | 5 #ifndef COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ |
| 6 #define COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ | 6 #define COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 11 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 12 #include "components/signin/core/browser/signin_error_controller.h" |
| 12 | 13 |
| 13 class OAuth2AccessTokenFetcher; | 14 class OAuth2AccessTokenFetcher; |
| 14 | 15 |
| 15 namespace ios{ | 16 namespace ios{ |
| 16 class ProfileOAuth2TokenServiceIOSProvider; | 17 class ProfileOAuth2TokenServiceIOSProvider; |
| 17 } | 18 } |
| 18 | 19 |
| 19 // A specialization of ProfileOAuth2TokenService that will be returned by | 20 // A specialization of ProfileOAuth2TokenService that will be returned by |
| 20 // ProfileOAuth2TokenServiceFactory for OS_IOS when iOS authentication service | 21 // ProfileOAuth2TokenServiceFactory for OS_IOS when iOS authentication service |
| 21 // is used to lookup OAuth2 tokens. | 22 // is used to lookup OAuth2 tokens. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 // OAuth2TokenService | 33 // OAuth2TokenService |
| 33 virtual bool RefreshTokenIsAvailable( | 34 virtual bool RefreshTokenIsAvailable( |
| 34 const std::string& account_id) const override; | 35 const std::string& account_id) const override; |
| 35 | 36 |
| 36 virtual void InvalidateOAuth2Token(const std::string& account_id, | 37 virtual void InvalidateOAuth2Token(const std::string& account_id, |
| 37 const std::string& client_id, | 38 const std::string& client_id, |
| 38 const ScopeSet& scopes, | 39 const ScopeSet& scopes, |
| 39 const std::string& access_token) override; | 40 const std::string& access_token) override; |
| 40 | 41 |
| 41 // ProfileOAuth2TokenService | 42 // ProfileOAuth2TokenService |
| 42 virtual void Initialize(SigninClient* client) override; | 43 virtual void Initialize( |
| 44 SigninClient* client, |
| 45 SigninErrorController* signin_error_controller) override; |
| 43 virtual void LoadCredentials(const std::string& primary_account_id) override; | 46 virtual void LoadCredentials(const std::string& primary_account_id) override; |
| 44 virtual std::vector<std::string> GetAccounts() override; | 47 virtual std::vector<std::string> GetAccounts() override; |
| 45 virtual void UpdateAuthError(const std::string& account_id, | 48 virtual void UpdateAuthError(const std::string& account_id, |
| 46 const GoogleServiceAuthError& error) override; | 49 const GoogleServiceAuthError& error) override; |
| 47 | 50 |
| 48 // This method should not be called when using shared authentication. | 51 // This method should not be called when using shared authentication. |
| 49 virtual void UpdateCredentials(const std::string& account_id, | 52 virtual void UpdateCredentials(const std::string& account_id, |
| 50 const std::string& refresh_token) override; | 53 const std::string& refresh_token) override; |
| 51 | 54 |
| 52 // Removes all credentials from this instance of |ProfileOAuth2TokenService|, | 55 // Removes all credentials from this instance of |ProfileOAuth2TokenService|, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 // |OnRefreshTokenAvailable| if the account info is updated. | 81 // |OnRefreshTokenAvailable| if the account info is updated. |
| 79 virtual void AddOrUpdateAccount(const std::string& account_id); | 82 virtual void AddOrUpdateAccount(const std::string& account_id); |
| 80 | 83 |
| 81 // Removes |account_id| from |accounts_|. Fires |OnRefreshTokenRevoked| | 84 // Removes |account_id| from |accounts_|. Fires |OnRefreshTokenRevoked| |
| 82 // if the account info is removed. | 85 // if the account info is removed. |
| 83 virtual void RemoveAccount(const std::string& account_id); | 86 virtual void RemoveAccount(const std::string& account_id); |
| 84 | 87 |
| 85 private: | 88 private: |
| 86 class AccountInfo : public SigninErrorController::AuthStatusProvider { | 89 class AccountInfo : public SigninErrorController::AuthStatusProvider { |
| 87 public: | 90 public: |
| 88 AccountInfo(ProfileOAuth2TokenService* token_service, | 91 AccountInfo(SigninErrorController* signin_error_controller, |
| 89 const std::string& account_id); | 92 const std::string& account_id); |
| 90 virtual ~AccountInfo(); | 93 virtual ~AccountInfo(); |
| 91 | 94 |
| 92 void SetLastAuthError(const GoogleServiceAuthError& error); | 95 void SetLastAuthError(const GoogleServiceAuthError& error); |
| 93 | 96 |
| 94 // SigninErrorController::AuthStatusProvider implementation. | 97 // SigninErrorController::AuthStatusProvider implementation. |
| 95 virtual std::string GetAccountId() const override; | 98 virtual std::string GetAccountId() const override; |
| 96 virtual std::string GetUsername() const override; | 99 virtual std::string GetUsername() const override; |
| 97 virtual GoogleServiceAuthError GetAuthStatus() const override; | 100 virtual GoogleServiceAuthError GetAuthStatus() const override; |
| 98 | 101 |
| 99 private: | 102 private: |
| 100 ProfileOAuth2TokenService* token_service_; | 103 SigninErrorController* signin_error_controller_; |
| 101 std::string account_id_; | 104 std::string account_id_; |
| 102 GoogleServiceAuthError last_auth_error_; | 105 GoogleServiceAuthError last_auth_error_; |
| 103 | 106 |
| 104 DISALLOW_COPY_AND_ASSIGN(AccountInfo); | 107 DISALLOW_COPY_AND_ASSIGN(AccountInfo); |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 // Maps the |account_id| of accounts known to ProfileOAuth2TokenService | 110 // Maps the |account_id| of accounts known to ProfileOAuth2TokenService |
| 108 // to information about the account. | 111 // to information about the account. |
| 109 typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap; | 112 typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap; |
| 110 | 113 |
| 111 // Returns the iOS provider; | 114 // Returns the iOS provider; |
| 112 ios::ProfileOAuth2TokenServiceIOSProvider* GetProvider(); | 115 ios::ProfileOAuth2TokenServiceIOSProvider* GetProvider(); |
| 113 | 116 |
| 114 // Info about the existing accounts. | 117 // Info about the existing accounts. |
| 115 AccountInfoMap accounts_; | 118 AccountInfoMap accounts_; |
| 116 | 119 |
| 117 // Calls to this class are expected to be made from the browser UI thread. | 120 // Calls to this class are expected to be made from the browser UI thread. |
| 118 // The purpose of this checker is to detect access to | 121 // The purpose of this checker is to detect access to |
| 119 // ProfileOAuth2TokenService from multiple threads in upstream code. | 122 // ProfileOAuth2TokenService from multiple threads in upstream code. |
| 120 base::ThreadChecker thread_checker_; | 123 base::ThreadChecker thread_checker_; |
| 121 | 124 |
| 122 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenServiceIOS); | 125 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenServiceIOS); |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 #endif // COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ | 128 #endif // COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_H_ |
| OLD | NEW |