| OLD | NEW |
| (Empty) |
| 1 // Copyright 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/callback.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "google_apis/gaia/gaia_auth_consumer.h" | |
| 15 #include "google_apis/gaia/gaia_auth_fetcher.h" | |
| 16 | |
| 17 class GaiaAuthFetcher; | |
| 18 | |
| 19 namespace net { | |
| 20 class URLRequestContextGetter; | |
| 21 } | |
| 22 | |
| 23 namespace chromeos { | |
| 24 | |
| 25 // Helper class that retrieves the authenticated user's e-mail address. | |
| 26 class AuthenticatedUserEmailRetriever : public GaiaAuthConsumer { | |
| 27 public: | |
| 28 typedef base::Callback<void(const std::string&)> | |
| 29 AuthenticatedUserEmailCallback; | |
| 30 | |
| 31 // Retrieves the authenticated user's e-mail address from GAIA and passes it | |
| 32 // to |callback|. Requires that |url_request_context_getter| contain the GAIA | |
| 33 // cookies for exactly one user. If the e-mail address cannot be retrieved, an | |
| 34 // empty string is passed to the |callback|. | |
| 35 AuthenticatedUserEmailRetriever( | |
| 36 const AuthenticatedUserEmailCallback& callback, | |
| 37 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | |
| 38 ~AuthenticatedUserEmailRetriever() override; | |
| 39 | |
| 40 // GaiaAuthConsumer: | |
| 41 void OnListAccountsSuccess(const std::string& data) override; | |
| 42 void OnListAccountsFailure(const GoogleServiceAuthError& error) override; | |
| 43 | |
| 44 private: | |
| 45 const AuthenticatedUserEmailCallback callback_; | |
| 46 GaiaAuthFetcher gaia_auth_fetcher_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(AuthenticatedUserEmailRetriever); | |
| 49 }; | |
| 50 | |
| 51 } // namespace chromeos | |
| 52 | |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRI
EVER_H_ | |
| OLD | NEW |