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

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

Issue 1278973003: Revert of Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « google_apis/drive/test_util.cc ('k') | google_apis/gaia/gaia_auth_fetcher.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/fake_gaia.h" 5 #include "google_apis/gaia/fake_gaia.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const char kAuthHeaderOAuth[] = "OAuth "; 64 const char kAuthHeaderOAuth[] = "OAuth ";
65 65
66 const char kListAccountsResponseFormat[] = 66 const char kListAccountsResponseFormat[] =
67 "[\"gaia.l.a.r\",[[\"gaia.l.a\",1,\"\",\"%s\",\"\",1,1,0,0,1,\"12345\"]]]"; 67 "[\"gaia.l.a.r\",[[\"gaia.l.a\",1,\"\",\"%s\",\"\",1,1,0,0,1,\"12345\"]]]";
68 68
69 typedef std::map<std::string, std::string> CookieMap; 69 typedef std::map<std::string, std::string> CookieMap;
70 70
71 // Parses cookie name-value map our of |request|. 71 // Parses cookie name-value map our of |request|.
72 CookieMap GetRequestCookies(const HttpRequest& request) { 72 CookieMap GetRequestCookies(const HttpRequest& request) {
73 CookieMap result; 73 CookieMap result;
74 auto iter = request.headers.find("Cookie"); 74 std::map<std::string, std::string>::const_iterator iter =
75 request.headers.find("Cookie");
75 if (iter != request.headers.end()) { 76 if (iter != request.headers.end()) {
76 for (const std::string& cookie_line : 77 std::vector<std::string> cookie_nv_pairs;
77 base::SplitString(iter->second, " ", base::TRIM_WHITESPACE, 78 base::SplitString(iter->second, ' ', &cookie_nv_pairs);
78 base::SPLIT_WANT_ALL)) { 79 for(std::vector<std::string>::const_iterator cookie_line =
79 std::vector<std::string> name_value = base::SplitString( 80 cookie_nv_pairs.begin();
80 cookie_line, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 81 cookie_line != cookie_nv_pairs.end();
82 ++cookie_line) {
83 std::vector<std::string> name_value;
84 base::SplitString(*cookie_line, '=', &name_value);
81 if (name_value.size() != 2) 85 if (name_value.size() != 2)
82 continue; 86 continue;
83 87
84 std::string value = name_value[1]; 88 std::string value = name_value[1];
85 if (value.size() && value[value.size() - 1] == ';') 89 if (value.size() && value[value.size() - 1] == ';')
86 value = value.substr(0, value.size() -1); 90 value = value.substr(0, value.size() -1);
87 91
88 result.insert(std::make_pair(name_value[0], value)); 92 result.insert(std::make_pair(name_value[0], value));
89 } 93 }
90 } 94 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 http_response->set_code(net::HTTP_OK); 434 http_response->set_code(net::HTTP_OK);
431 } 435 }
432 436
433 const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo( 437 const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo(
434 const std::string& auth_token, 438 const std::string& auth_token,
435 const std::string& client_id, 439 const std::string& client_id,
436 const std::string& scope_string) const { 440 const std::string& scope_string) const {
437 if (auth_token.empty() || client_id.empty()) 441 if (auth_token.empty() || client_id.empty())
438 return NULL; 442 return NULL;
439 443
440 std::vector<std::string> scope_list = base::SplitString( 444 std::vector<std::string> scope_list;
441 scope_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 445 base::SplitString(scope_string, ' ', &scope_list);
442 ScopeSet scopes(scope_list.begin(), scope_list.end()); 446 ScopeSet scopes(scope_list.begin(), scope_list.end());
443 447
444 for (AccessTokenInfoMap::const_iterator entry( 448 for (AccessTokenInfoMap::const_iterator entry(
445 access_token_info_map_.lower_bound(auth_token)); 449 access_token_info_map_.lower_bound(auth_token));
446 entry != access_token_info_map_.upper_bound(auth_token); 450 entry != access_token_info_map_.upper_bound(auth_token);
447 ++entry) { 451 ++entry) {
448 if (entry->second.audience == client_id && 452 if (entry->second.audience == client_id &&
449 (scope_string.empty() || entry->second.scopes == scopes)) { 453 (scope_string.empty() || entry->second.scopes == scopes)) {
450 return &(entry->second); 454 return &(entry->second);
451 } 455 }
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 if (token_info) { 769 if (token_info) {
766 base::DictionaryValue response_dict; 770 base::DictionaryValue response_dict;
767 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); 771 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email));
768 response_dict.SetString("email", token_info->email); 772 response_dict.SetString("email", token_info->email);
769 response_dict.SetString("verified_email", token_info->email); 773 response_dict.SetString("verified_email", token_info->email);
770 FormatJSONResponse(response_dict, http_response); 774 FormatJSONResponse(response_dict, http_response);
771 } else { 775 } else {
772 http_response->set_code(net::HTTP_BAD_REQUEST); 776 http_response->set_code(net::HTTP_BAD_REQUEST);
773 } 777 }
774 } 778 }
OLDNEW
« no previous file with comments | « google_apis/drive/test_util.cc ('k') | google_apis/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698