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

Unified Diff: chrome/browser/google_apis/auth_service.cc

Issue 11618024: [signin] Support for CrOS and OAuth2AccessTokenConsumer services. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor fixes Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/google_apis/DEPS ('k') | chrome/browser/policy/user_policy_signin_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2bbaa3afca7d712e38328f17f57222b661f19fb7 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,11 @@ 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 profile_.
+ // A weak pointer to the profile associated with this service, if any.
+ Profile* profile_;
+
DISALLOW_COPY_AND_ASSIGN(AuthOperation);
};
@@ -79,12 +87,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 +127,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 +145,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 +216,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()));
« no previous file with comments | « chrome/browser/google_apis/DEPS ('k') | chrome/browser/policy/user_policy_signin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698