Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / authenticated_user_email_retriever.h
blobba938e716cae66ecaccea6a647e17a2485337ee0
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.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"
17 class GaiaAuthFetcher;
19 namespace net {
20 class URLRequestContextGetter;
23 namespace chromeos {
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;
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;
40 // GaiaAuthConsumer:
41 void OnListAccountsSuccess(const std::string& data) override;
42 void OnListAccountsFailure(const GoogleServiceAuthError& error) override;
44 private:
45 const AuthenticatedUserEmailCallback callback_;
46 GaiaAuthFetcher gaia_auth_fetcher_;
48 DISALLOW_COPY_AND_ASSIGN(AuthenticatedUserEmailRetriever);
51 } // namespace chromeos
53 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_AUTHENTICATED_USER_EMAIL_RETRIEVER_H_