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

Unified Diff: components/signin/core/browser/about_signin_internals.cc

Issue 1075273002: Handle ListAccount fetches from within the GaiaCookieManagerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a test post rebase Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/signin/core/browser/about_signin_internals.cc
diff --git a/components/signin/core/browser/about_signin_internals.cc b/components/signin/core/browser/about_signin_internals.cc
index 81a7e61406634566482e85541d6437d69474d854..74c3979bfe00baae87ba26937a050bf9306c21dc 100644
--- a/components/signin/core/browser/about_signin_internals.cc
+++ b/components/signin/core/browser/about_signin_internals.cc
@@ -20,11 +20,6 @@
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "components/signin/core/common/signin_switches.h"
-#include "google_apis/gaia/gaia_auth_fetcher.h"
-#include "google_apis/gaia/gaia_auth_util.h"
-#include "google_apis/gaia/gaia_constants.h"
-#include "google_apis/gaia/gaia_urls.h"
-#include "net/cookies/canonical_cookie.h"
using base::Time;
using namespace signin_internals_util;
@@ -135,12 +130,14 @@ AboutSigninInternals::AboutSigninInternals(
ProfileOAuth2TokenService* token_service,
AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager,
- SigninErrorController* signin_error_controller)
+ SigninErrorController* signin_error_controller,
+ GaiaCookieManagerService* cookie_manager_service)
: token_service_(token_service),
account_tracker_(account_tracker),
signin_manager_(signin_manager),
client_(NULL),
- signin_error_controller_(signin_error_controller) {}
+ signin_error_controller_(signin_error_controller),
+ cookie_manager_service_(cookie_manager_service) {}
AboutSigninInternals::~AboutSigninInternals() {}
@@ -211,18 +208,14 @@ void AboutSigninInternals::Initialize(SigninClient* client) {
signin_error_controller_->AddObserver(this);
signin_manager_->AddSigninDiagnosticsObserver(this);
token_service_->AddDiagnosticsObserver(this);
- cookie_changed_subscription_ = client_->AddCookieChangedCallback(
- GaiaUrls::GetInstance()->gaia_url(),
- "LSID",
- base::Bind(&AboutSigninInternals::OnCookieChanged,
- base::Unretained(this)));
+ cookie_manager_service_->AddObserver(this);
}
void AboutSigninInternals::Shutdown() {
signin_error_controller_->RemoveObserver(this);
signin_manager_->RemoveSigninDiagnosticsObserver(this);
token_service_->RemoveDiagnosticsObserver(this);
- cookie_changed_subscription_.reset();
+ cookie_manager_service_->RemoveObserver(this);
}
void AboutSigninInternals::NotifyObservers() {
@@ -329,48 +322,10 @@ void AboutSigninInternals::OnAuthenticationResultReceived(std::string status) {
NotifySigninValueChanged(AUTHENTICATION_RESULT_RECEIVED, status);
}
-void AboutSigninInternals::OnCookieChanged(const net::CanonicalCookie& cookie,
- bool removed) {
- DCHECK_EQ("LSID", cookie.Name());
- DCHECK_EQ(GaiaUrls::GetInstance()->gaia_url().host(), cookie.Domain());
- if (cookie.IsSecure() && cookie.IsHttpOnly()) {
- GetCookieAccountsAsync();
- }
-}
-
void AboutSigninInternals::OnErrorChanged() {
NotifyObservers();
}
-void AboutSigninInternals::GetCookieAccountsAsync() {
- // Don't bother calling /ListAccounts if no one will observe the response.
- if (!gaia_fetcher_ && signin_observers_.might_have_observers()) {
- // There is no list account request in flight.
- gaia_fetcher_.reset(new GaiaAuthFetcher(
- this, GaiaConstants::kChromeSource, client_->GetURLRequestContext()));
- gaia_fetcher_->StartListAccounts();
- }
-}
-
-void AboutSigninInternals::OnListAccountsSuccess(const std::string& data) {
- gaia_fetcher_.reset();
-
- // Get account information from response data.
- std::vector<std::pair<std::string, bool> > gaia_accounts;
- bool valid_json = gaia::ParseListAccountsData(data, &gaia_accounts);
- if (!valid_json) {
- VLOG(1) << "AboutSigninInternals::OnListAccountsSuccess: parsing error";
- } else {
- OnListAccountsComplete(gaia_accounts);
- }
-}
-
-void AboutSigninInternals::OnListAccountsFailure(
- const GoogleServiceAuthError& error) {
- gaia_fetcher_.reset();
- VLOG(1) << "AboutSigninInternals::OnListAccountsFailure:" << error.ToString();
-}
-
void AboutSigninInternals::GoogleSigninFailed(
const GoogleServiceAuthError& error) {
NotifyObservers();
@@ -387,8 +342,12 @@ void AboutSigninInternals::GoogleSignedOut(const std::string& account_id,
NotifyObservers();
}
-void AboutSigninInternals::OnListAccountsComplete(
- std::vector<std::pair<std::string, bool> >& gaia_accounts) {
+void AboutSigninInternals::OnGaiaAccountsInCookieUpdated(
+ const std::vector<std::pair<std::string, bool> >& gaia_accounts,
+ const GoogleServiceAuthError& error) {
+ if (error.state() != GoogleServiceAuthError::NONE)
+ return;
+
base::DictionaryValue cookie_status;
base::ListValue* cookie_info = new base::ListValue();
cookie_status.Set("cookie_info", cookie_info);
« no previous file with comments | « components/signin/core/browser/about_signin_internals.h ('k') | components/signin/core/browser/account_reconcilor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698