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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVE R_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVE R_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "google_apis/gaia/gaia_auth_consumer.h"
16 #include "net/cookies/canonical_cookie.h"
17 #include "net/cookies/cookie_store.h"
18 #include "net/url_request/url_request_context_getter.h"
19
20 class GaiaAuthFetcher;
21
22 namespace chromeos {
23
24 // Helper class that retrieves the authenticated user's e-mail address.
25 class AuthenticatedUserEmailRetriever : public GaiaAuthConsumer {
26 public:
27 typedef base::Callback<void(const std::string&)>
28 AuthenticatedUserEmailCallback;
29
30 // Extracts the GAIA cookies from |url_request_context_getter|, retrieves the
31 // authenticated user's e-mail address from GAIA and passes it to |callback|.
32 // If the e-mail address cannot be retrieved, an empty string is passed to
33 // the |callback|.
34 AuthenticatedUserEmailRetriever(
35 const AuthenticatedUserEmailCallback& callback,
36 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
37 virtual ~AuthenticatedUserEmailRetriever();
38
39 // GaiaAuthConsumer:
40 virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE;
41 virtual void OnGetUserInfoFailure(
42 const GoogleServiceAuthError& error) OVERRIDE;
43
44 private:
45 void ExtractCookies(scoped_refptr<net::CookieStore> cookie_store);
46 void ExtractLSIDFromCookies(const net::CookieList& cookies);
47
48 AuthenticatedUserEmailCallback callback_;
49
50 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
51 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
52
53 base::WeakPtrFactory<AuthenticatedUserEmailRetriever> weak_factory_;
54
55 DISALLOW_COPY_AND_ASSIGN(AuthenticatedUserEmailRetriever);
56 };
57
58 } // namespace chromeos
59
60 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRI EVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698