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

Side by Side Diff: google_apis/gaia/gaia_auth_util.cc

Issue 11091048: Add helper function to test that a given URL is a valid Gaia sign in URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 2 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
« no previous file with comments | « google_apis/gaia/gaia_auth_util.h ('k') | google_apis/gaia/gaia_auth_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "google_apis/gaia/gaia_auth_util.h" 5 #include "google_apis/gaia/gaia_auth_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "google_apis/gaia/gaia_urls.h"
13 #include "googleurl/src/gurl.h"
12 14
13 namespace gaia { 15 namespace gaia {
14 16
15 namespace { 17 namespace {
16 const char kGmailDomain[] = "gmail.com"; 18 const char kGmailDomain[] = "gmail.com";
17 } 19 }
18 20
19 std::string CanonicalizeEmail(const std::string& email_address) { 21 std::string CanonicalizeEmail(const std::string& email_address) {
20 std::vector<std::string> parts; 22 std::vector<std::string> parts;
21 char at = '@'; 23 char at = '@';
(...skipping 29 matching lines...) Expand all
51 // First canonicalize which will also verify we have proper domain part. 53 // First canonicalize which will also verify we have proper domain part.
52 std::string email = CanonicalizeEmail(email_address); 54 std::string email = CanonicalizeEmail(email_address);
53 size_t separator_pos = email.find('@'); 55 size_t separator_pos = email.find('@');
54 if (separator_pos != email.npos && separator_pos < email.length() - 1) 56 if (separator_pos != email.npos && separator_pos < email.length() - 1)
55 return email.substr(separator_pos + 1); 57 return email.substr(separator_pos + 1);
56 else 58 else
57 NOTREACHED() << "Not a proper email address: " << email; 59 NOTREACHED() << "Not a proper email address: " << email;
58 return std::string(); 60 return std::string();
59 } 61 }
60 62
63 bool IsGaiaSignonRealm(const GURL& url) {
64 if (!url.SchemeIsSecure())
65 return false;
66
67 // Also check "https://www.google.com" to support old style dasher logins.
68 return url == GURL(GaiaUrls::GetInstance()->gaia_origin_url()) ||
69 url == GURL("https://www.google.com/");
70 }
71
61 } // namespace gaia 72 } // namespace gaia
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_util.h ('k') | google_apis/gaia/gaia_auth_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698