Home | History | Annotate | Download | only in gaia
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_
      6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 class GURL;
     12 
     13 namespace gaia {
     14 
     15 // 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 // ignores everything after a '+'. For example, c.masone+abc (at) gmail.com ==
     18 // cMaSone (at) gmail.com, per
     19 // http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=10313#
     20 std::string CanonicalizeEmail(const std::string& email_address);
     21 
     22 // Returns the canonical form of the given domain.
     23 std::string CanonicalizeDomain(const std::string& domain);
     24 
     25 // Sanitize emails. Currently, it only ensures all emails have a domain by
     26 // adding gmail.com if no domain is present.
     27 std::string SanitizeEmail(const std::string& email_address);
     28 
     29 // Returns true if the two specified email addresses are the same.  Both
     30 // addresses are first sanitized and then canoncialized before comparing.
     31 bool AreEmailsSame(const std::string& email1, const std::string& email2);
     32 
     33 // Extract the domain part from the canonical form of the given email.
     34 std::string ExtractDomainName(const std::string& email);
     35 
     36 bool IsGaiaSignonRealm(const GURL& url);
     37 
     38 // Parses JSON data returned by /ListAccounts call, returns vector of
     39 // accounts (email addresses).
     40 std::vector<std::string> ParseListAccountsData(const std::string& data);
     41 
     42 }  // namespace gaia
     43 
     44 #endif  // GOOGLE_APIS_GAIA_GAIA_AUTH_UTIL_H_
     45