OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/sync/engine/net/gaia_authenticator.h" | 5 #include "chrome/browser/sync/engine/net/gaia_authenticator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // TODO(timsteele): Integrate the following two functions to string_util.h or | 24 // TODO(timsteele): Integrate the following two functions to string_util.h or |
25 // somewhere that makes them unit-testable. | 25 // somewhere that makes them unit-testable. |
26 bool SplitStringIntoKeyValues(const string& line, | 26 bool SplitStringIntoKeyValues(const string& line, |
27 char key_value_delimiter, | 27 char key_value_delimiter, |
28 string* key, vector<string>* values) { | 28 string* key, vector<string>* values) { |
29 key->clear(); | 29 key->clear(); |
30 values->clear(); | 30 values->clear(); |
31 | 31 |
32 // find the key string | 32 // find the key string |
33 int end_key_pos = line.find_first_of(key_value_delimiter); | 33 size_t end_key_pos = line.find_first_of(key_value_delimiter); |
34 if (end_key_pos == string::npos) { | 34 if (end_key_pos == string::npos) { |
35 DLOG(INFO) << "cannot parse key from line: " << line; | 35 DLOG(INFO) << "cannot parse key from line: " << line; |
36 return false; // no key | 36 return false; // no key |
37 } | 37 } |
38 key->assign(line, 0, end_key_pos); | 38 key->assign(line, 0, end_key_pos); |
39 | 39 |
40 // find the values string | 40 // find the values string |
41 string remains(line, end_key_pos, line.size() - end_key_pos); | 41 string remains(line, end_key_pos, line.size() - end_key_pos); |
42 int begin_values_pos = remains.find_first_not_of(key_value_delimiter); | 42 size_t begin_values_pos = remains.find_first_not_of(key_value_delimiter); |
43 if (begin_values_pos == string::npos) { | 43 if (begin_values_pos == string::npos) { |
44 DLOG(INFO) << "cannot parse value from line: " << line; | 44 DLOG(INFO) << "cannot parse value from line: " << line; |
45 return false; // no value | 45 return false; // no value |
46 } | 46 } |
47 string values_string(remains, begin_values_pos, | 47 string values_string(remains, begin_values_pos, |
48 remains.size() - begin_values_pos); | 48 remains.size() - begin_values_pos); |
49 | 49 |
50 // construct the values vector | 50 // construct the values vector |
51 values->push_back(values_string); | 51 values->push_back(values_string); |
52 return true; | 52 return true; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static const char kGetUserInfoPath[] = "/accounts/GetUserInfo"; | 85 static const char kGetUserInfoPath[] = "/accounts/GetUserInfo"; |
86 | 86 |
87 // Sole constructor with initializers for all fields. | 87 // Sole constructor with initializers for all fields. |
88 GaiaAuthenticator::GaiaAuthenticator(const string& user_agent, | 88 GaiaAuthenticator::GaiaAuthenticator(const string& user_agent, |
89 const string& service_id, | 89 const string& service_id, |
90 const string& gaia_url) | 90 const string& gaia_url) |
91 : user_agent_(user_agent), | 91 : user_agent_(user_agent), |
92 service_id_(service_id), | 92 service_id_(service_id), |
93 gaia_url_(gaia_url), | 93 gaia_url_(gaia_url), |
94 request_count_(0), | 94 request_count_(0), |
95 early_auth_attempt_count_(0), | |
96 delay_(0), | 95 delay_(0), |
97 next_allowed_auth_attempt_time_(0) { | 96 next_allowed_auth_attempt_time_(0), |
| 97 early_auth_attempt_count_(0) { |
98 GaiaAuthEvent done = { GaiaAuthEvent::GAIA_AUTHENTICATOR_DESTROYED, None, | 98 GaiaAuthEvent done = { GaiaAuthEvent::GAIA_AUTHENTICATOR_DESTROYED, None, |
99 this }; | 99 this }; |
100 channel_ = new Channel(done); | 100 channel_ = new Channel(done); |
101 } | 101 } |
102 | 102 |
103 GaiaAuthenticator::~GaiaAuthenticator() { | 103 GaiaAuthenticator::~GaiaAuthenticator() { |
104 delete channel_; | 104 delete channel_; |
105 } | 105 } |
106 | 106 |
107 bool GaiaAuthenticator::LaunchAuthenticate(const AuthParams& params, | 107 bool GaiaAuthenticator::LaunchAuthenticate(const AuthParams& params, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 bool GaiaAuthenticator::Authenticate(const string& user_name, | 472 bool GaiaAuthenticator::Authenticate(const string& user_name, |
473 const string& password, | 473 const string& password, |
474 SaveCredentials should_save_credentials, | 474 SaveCredentials should_save_credentials, |
475 bool synchronous, SignIn try_first) { | 475 bool synchronous, SignIn try_first) { |
476 const string empty; | 476 const string empty; |
477 return Authenticate(user_name, password, should_save_credentials, synchronous, | 477 return Authenticate(user_name, password, should_save_credentials, synchronous, |
478 empty, empty, try_first); | 478 empty, empty, try_first); |
479 } | 479 } |
480 | 480 |
481 } // namespace browser_sync | 481 } // namespace browser_sync |
OLD | NEW |