Chromium Code Reviews| Index: chrome/browser/google_apis/auth_service.cc |
| diff --git a/chrome/browser/google_apis/auth_service.cc b/chrome/browser/google_apis/auth_service.cc |
| index d428b8044dcc4c7cfd13567851790ed118018acf..3543b9ffc71266d4939f87d777f123894dd29dc9 100644 |
| --- a/chrome/browser/google_apis/auth_service.cc |
| +++ b/chrome/browser/google_apis/auth_service.cc |
| @@ -13,6 +13,8 @@ |
| #include "chrome/browser/google_apis/auth_service_observer.h" |
| #include "chrome/browser/google_apis/base_operations.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/about_signin_internals.h" |
| +#include "chrome/browser/signin/about_signin_internals_factory.h" |
| #include "chrome/browser/signin/token_service.h" |
| #include "chrome/browser/signin/token_service_factory.h" |
| #include "chrome/common/chrome_notification_types.h" |
| @@ -52,7 +54,8 @@ class AuthOperation : public OperationRegistry::Operation, |
| net::URLRequestContextGetter* url_request_context_getter, |
| const AuthStatusCallback& callback, |
| const std::vector<std::string>& scopes, |
| - const std::string& refresh_token); |
| + const std::string& refresh_token, |
| + Profile* profile); |
| virtual ~AuthOperation(); |
| void Start(); |
| @@ -71,6 +74,10 @@ class AuthOperation : public OperationRegistry::Operation, |
| std::vector<std::string> scopes_; |
| scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; |
| + // TODO(vishwath): Once we move to OAuth2TokenService, this class no longer |
| + // needs a profile var. Remove and refactor ctors()/call-sites accordingly. |
|
James Hawkins
2012/12/21 23:31:04
nit: Document the member variable (also, state 'we
|
| + Profile* profile_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AuthOperation); |
| }; |
| @@ -79,12 +86,14 @@ AuthOperation::AuthOperation( |
| net::URLRequestContextGetter* url_request_context_getter, |
| const AuthStatusCallback& callback, |
| const std::vector<std::string>& scopes, |
| - const std::string& refresh_token) |
| + const std::string& refresh_token, |
| + Profile* profile) |
| : OperationRegistry::Operation(registry), |
| url_request_context_getter_(url_request_context_getter), |
| refresh_token_(refresh_token), |
| callback_(callback), |
| - scopes_(scopes) { |
| + scopes_(scopes), |
| + profile_(profile) { |
| DCHECK(!callback_.is_null()); |
| } |
| @@ -117,6 +126,13 @@ void AuthOperation::OnGetTokenSuccess(const std::string& access_token, |
| kSuccessRatioHistogramSuccess, |
| kSuccessRatioHistogramMaxValue); |
| + // TODO(vishwath): This can be removed once this class is migrated to use |
| + // OAuth2TokenService. |
| + AboutSigninInternalsFactory::GetForProfile(profile_)-> |
| + NotifyTokenReceivedSuccess(signin_internals_util::kAuthOperationToken, |
| + access_token, |
| + true); |
| + |
| callback_.Run(HTTP_SUCCESS, access_token); |
| NotifyFinish(OPERATION_COMPLETED); |
| } |
| @@ -128,6 +144,11 @@ void AuthOperation::OnGetTokenFailure(const GoogleServiceAuthError& error) { |
| LOG(WARNING) << "AuthOperation: token request using refresh token failed: " |
| << error.ToString(); |
| + // TODO(vishwath): This needs to be converted to use OAuth2TokenService. |
| + AboutSigninInternalsFactory::GetForProfile(profile_)-> |
| + NotifyTokenReceivedFailure(signin_internals_util::kAuthOperationToken, |
| + error.ToString()); |
| + |
| // There are many ways to fail, but if the failure is due to connection, |
| // it's likely that the device is off-line. We treat the error differently |
| // so that the file manager works while off-line. |
| @@ -194,7 +215,8 @@ void AuthService::StartAuthentication(OperationRegistry* registry, |
| weak_ptr_factory_.GetWeakPtr(), |
| callback), |
| scopes_, |
| - refresh_token_))->Start(); |
| + refresh_token_, |
| + profile_))->Start(); |
| } else { |
| relay_proxy->PostTask(FROM_HERE, |
| base::Bind(callback, GDATA_NOT_READY, std::string())); |