Index: chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.cc b/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.cc |
index af4803a04b8c3b3ddca9d0f49f18c58546ee41c5..02de45c504650a62121a6cfdd924cdc7a7ce192f 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.cc |
@@ -4,84 +4,39 @@ |
#include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h" |
-#include "base/bind.h" |
-#include "base/callback.h" |
-#include "base/location.h" |
-#include "base/logging.h" |
-#include "content/public/browser/browser_thread.h" |
-#include "google_apis/gaia/gaia_auth_fetcher.h" |
+#include <vector> |
+ |
+#include "google_apis/gaia/gaia_auth_util.h" |
#include "google_apis/gaia/gaia_constants.h" |
-#include "google_apis/gaia/gaia_urls.h" |
#include "google_apis/gaia/google_service_auth_error.h" |
-#include "net/cookies/cookie_monster.h" |
-#include "net/url_request/url_request_context.h" |
-#include "url/gurl.h" |
+#include "net/url_request/url_request_context_getter.h" |
namespace chromeos { |
-namespace { |
- |
-scoped_refptr<net::CookieStore> GetCookieStoreOnIO( |
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
- return url_request_context_getter->GetURLRequestContext()->cookie_store(); |
-} |
- |
-} // namespace |
- |
AuthenticatedUserEmailRetriever::AuthenticatedUserEmailRetriever( |
const AuthenticatedUserEmailCallback& callback, |
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
: callback_(callback), |
- url_request_context_getter_(url_request_context_getter), |
- weak_factory_(this) { |
- content::BrowserThread::PostTaskAndReplyWithResult( |
- content::BrowserThread::IO, |
- FROM_HERE, |
- base::Bind(&GetCookieStoreOnIO, url_request_context_getter), |
- base::Bind(&AuthenticatedUserEmailRetriever::ExtractCookies, |
- weak_factory_.GetWeakPtr())); |
+ gaia_auth_fetcher_(this, |
+ GaiaConstants::kChromeSource, |
+ url_request_context_getter) { |
+ gaia_auth_fetcher_.StartListAccounts(); |
} |
AuthenticatedUserEmailRetriever::~AuthenticatedUserEmailRetriever() { |
} |
-void AuthenticatedUserEmailRetriever::OnGetUserInfoSuccess( |
- const UserInfoMap& data) { |
- UserInfoMap::const_iterator it = data.find("email"); |
- callback_.Run(it != data.end() ? it->second : ""); |
-} |
- |
-void AuthenticatedUserEmailRetriever::OnGetUserInfoFailure( |
- const GoogleServiceAuthError& error) { |
- callback_.Run(std::string()); |
-} |
- |
-void AuthenticatedUserEmailRetriever::ExtractCookies( |
- scoped_refptr<net::CookieStore> cookie_store) { |
- if (!cookie_store) { |
+void AuthenticatedUserEmailRetriever::OnListAccountsSuccess( |
+ const std::string& data) { |
+ std::vector<std::string> accounts = gaia::ParseListAccountsData(data); |
+ if (accounts.size() != 1) |
callback_.Run(std::string()); |
- return; |
- } |
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync( |
- GaiaUrls::GetInstance()->gaia_url(), |
- base::Bind(&AuthenticatedUserEmailRetriever::ExtractLSIDFromCookies, |
- weak_factory_.GetWeakPtr())); |
+ else |
+ callback_.Run(accounts.front()); |
} |
-void AuthenticatedUserEmailRetriever::ExtractLSIDFromCookies( |
- const net::CookieList& cookies) { |
- for (net::CookieList::const_iterator it = cookies.begin(); |
- it != cookies.end(); ++it) { |
- if (it->Name() == "LSID") { |
- gaia_auth_fetcher_.reset(new GaiaAuthFetcher( |
- this, |
- GaiaConstants::kChromeSource, |
- url_request_context_getter_)); |
- gaia_auth_fetcher_->StartGetUserInfo(it->Value()); |
- return; |
- } |
- } |
+void AuthenticatedUserEmailRetriever::OnListAccountsFailure( |
+ const GoogleServiceAuthError& error) { |
callback_.Run(std::string()); |
} |