OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ | 5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ |
6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ | 6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 class GURL; | 12 class GURL; |
12 | 13 |
13 namespace gaia { | 14 namespace gaia { |
14 | 15 |
15 // Perform basic canonicalization of |email_address|, taking into account that | 16 // Perform basic canonicalization of |email_address|, taking into account that |
16 // gmail does not consider '.' or caps inside a username to matter. It also | 17 // gmail does not consider '.' or caps inside a username to matter. It also |
17 // ignores everything after a '+'. For example, c.masone+abc@gmail.com == | 18 // ignores everything after a '+'. For example, c.masone+abc@gmail.com == |
18 // cMaSone@gmail.com, per | 19 // cMaSone@gmail.com, per |
19 // http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=10313# | 20 // http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=10313# |
20 std::string CanonicalizeEmail(const std::string& email_address); | 21 std::string CanonicalizeEmail(const std::string& email_address); |
21 | 22 |
22 // Returns the canonical form of the given domain. | 23 // Returns the canonical form of the given domain. |
23 std::string CanonicalizeDomain(const std::string& domain); | 24 std::string CanonicalizeDomain(const std::string& domain); |
24 | 25 |
25 // Sanitize emails. Currently, it only ensures all emails have a domain by | 26 // Sanitize emails. Currently, it only ensures all emails have a domain by |
26 // adding gmail.com if no domain is present. | 27 // adding gmail.com if no domain is present. |
27 std::string SanitizeEmail(const std::string& email_address); | 28 std::string SanitizeEmail(const std::string& email_address); |
28 | 29 |
29 // Returns true if the two specified email addresses are the same. Both | 30 // Returns true if the two specified email addresses are the same. Both |
30 // addresses are first sanitized and then canoncialized before comparing. | 31 // addresses are first sanitized and then canoncialized before comparing. |
31 bool AreEmailsSame(const std::string& email1, const std::string& email2); | 32 bool AreEmailsSame(const std::string& email1, const std::string& email2); |
32 | 33 |
33 // Extract the domain part from the canonical form of the given email. | 34 // Extract the domain part from the canonical form of the given email. |
34 std::string ExtractDomainName(const std::string& email); | 35 std::string ExtractDomainName(const std::string& email); |
35 | 36 |
36 bool IsGaiaSignonRealm(const GURL& url); | 37 bool IsGaiaSignonRealm(const GURL& url); |
37 | 38 |
38 // Parses JSON data returned by /ListAccounts call, returns vector of | 39 // Parses JSON data returned by /ListAccounts call, returning a vector of |
39 // accounts (email addresses). If there an error parsing the JSON, then | 40 // email/valid pairs. An email addresses is considered valid if a passive |
40 // false is returned. | 41 // login would succeed (i.e. the user does not need to reauthenticate). |
41 bool ParseListAccountsData(const std::string& data, | 42 // If there an error parsing the JSON, then false is returned. |
42 std::vector<std::string>* accounts); | 43 bool ParseListAccountsData( |
| 44 const std::string& data, |
| 45 std::vector<std::pair<std::string, bool> >* accounts); |
43 | 46 |
44 } // namespace gaia | 47 } // namespace gaia |
45 | 48 |
46 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ | 49 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_ |
OLD | NEW |