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 #include "google_apis/gaia/gaia_auth_fetcher.h" | 5 #include "google_apis/gaia/gaia_auth_fetcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 for (iter = cookies.begin(); iter != cookies.end(); ++iter) { | 501 for (iter = cookies.begin(); iter != cookies.end(); ++iter) { |
502 if (ParseClientLoginToOAuth2Cookie(*iter, auth_code)) | 502 if (ParseClientLoginToOAuth2Cookie(*iter, auth_code)) |
503 return true; | 503 return true; |
504 } | 504 } |
505 return false; | 505 return false; |
506 } | 506 } |
507 | 507 |
508 // static | 508 // static |
509 bool GaiaAuthFetcher::ParseClientLoginToOAuth2Cookie(const std::string& cookie, | 509 bool GaiaAuthFetcher::ParseClientLoginToOAuth2Cookie(const std::string& cookie, |
510 std::string* auth_code) { | 510 std::string* auth_code) { |
511 std::vector<std::string> parts; | 511 std::vector<std::string> parts = base::SplitString( |
512 base::SplitString(cookie, ';', &parts); | 512 cookie, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
513 // Per documentation, the cookie should have Secure and HttpOnly. | 513 // Per documentation, the cookie should have Secure and HttpOnly. |
514 if (!CookiePartsContains(parts, kClientLoginToOAuth2CookiePartSecure) || | 514 if (!CookiePartsContains(parts, kClientLoginToOAuth2CookiePartSecure) || |
515 !CookiePartsContains(parts, kClientLoginToOAuth2CookiePartHttpOnly)) { | 515 !CookiePartsContains(parts, kClientLoginToOAuth2CookiePartHttpOnly)) { |
516 return false; | 516 return false; |
517 } | 517 } |
518 | 518 |
519 std::vector<std::string>::const_iterator iter; | 519 std::vector<std::string>::const_iterator iter; |
520 for (iter = parts.begin(); iter != parts.end(); ++iter) { | 520 for (iter = parts.begin(); iter != parts.end(); ++iter) { |
521 const std::string& part = *iter; | 521 const std::string& part = *iter; |
522 if (base::StartsWith(part, kClientLoginToOAuth2CookiePartCodePrefix, | 522 if (base::StartsWith(part, kClientLoginToOAuth2CookiePartCodePrefix, |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 return alleged_error.find(kSecondFactor) != | 1091 return alleged_error.find(kSecondFactor) != |
1092 std::string::npos; | 1092 std::string::npos; |
1093 } | 1093 } |
1094 | 1094 |
1095 // static | 1095 // static |
1096 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 1096 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
1097 const std::string& alleged_error) { | 1097 const std::string& alleged_error) { |
1098 return alleged_error.find(kWebLoginRequired) != | 1098 return alleged_error.find(kWebLoginRequired) != |
1099 std::string::npos; | 1099 std::string::npos; |
1100 } | 1100 } |
OLD | NEW |