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

Unified Diff: chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h

Issue 136573002: Retrieve the authenticated user's e-mail from GAIA during SAML login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 11 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: chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h
diff --git a/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h b/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h
new file mode 100644
index 0000000000000000000000000000000000000000..56bafa3aec1705f7783d3836e87381fca0e03b3b
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "google_apis/gaia/gaia_auth_consumer.h"
+#include "net/cookies/canonical_cookie.h"
+#include "net/cookies/cookie_store.h"
+#include "net/url_request/url_request_context_getter.h"
+
+class GaiaAuthFetcher;
+
+namespace chromeos {
+
+// Helper class that retrieves the authenticated user's e-mail address.
+class AuthenticatedUserEmailRetriever : public GaiaAuthConsumer {
+ public:
+ typedef base::Callback<void(const std::string&)>
+ AuthenticatedUserEmailCallback;
+
+ // Extracts the GAIA cookies from |url_request_context_getter|, retrieves the
+ // authenticated user's e-mail address from GAIA and passes it to |callback|.
+ // If the e-mail address cannot be retrieved, an empty string is passed to
+ // the |callback|.
+ AuthenticatedUserEmailRetriever(
+ const AuthenticatedUserEmailCallback& callback,
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
+ virtual ~AuthenticatedUserEmailRetriever();
+
+ // GaiaAuthConsumer:
+ virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE;
+ virtual void OnGetUserInfoFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+
+ private:
+ void ExtractCookies(scoped_refptr<net::CookieStore> cookie_store);
+ void ExtractLSIDFromCookies(const net::CookieList& cookies);
+
+ AuthenticatedUserEmailCallback callback_;
+
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
+ scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
+
+ base::WeakPtrFactory<AuthenticatedUserEmailRetriever> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(AuthenticatedUserEmailRetriever);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_

Powered by Google App Engine
This is Rietveld 408576698