Chromium Code Reviews| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // static | 163 // static |
| 164 const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartHttpOnly[] = | 164 const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartHttpOnly[] = |
| 165 "httponly"; | 165 "httponly"; |
| 166 // static | 166 // static |
| 167 const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefix[] = | 167 const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefix[] = |
| 168 "oauth_code="; | 168 "oauth_code="; |
| 169 // static | 169 // static |
| 170 const int GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefixLength = | 170 const int GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefixLength = |
| 171 arraysize(GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefix) - 1; | 171 arraysize(GaiaAuthFetcher::kClientLoginToOAuth2CookiePartCodePrefix) - 1; |
| 172 | 172 |
| 173 // static | |
| 174 GURL GaiaAuthFetcher::BuildListAccountsURL(const std::string& source) { | |
| 175 if (source.empty()) { | |
| 176 return GaiaUrls::GetInstance()->list_accounts_url(); | |
| 177 } else { | |
| 178 std::string query = GaiaUrls::GetInstance()->list_accounts_url().query(); | |
|
Mike Lerman
2014/09/26 16:57:07
It seems like the logic in this method and the met
guohui
2014/09/26 17:36:01
+1
Roger Tawa OOO till Jul 10th
2014/09/26 19:42:39
Done.
Roger Tawa OOO till Jul 10th
2014/09/26 19:42:39
Done.
| |
| 179 return GaiaUrls::GetInstance()->list_accounts_url().Resolve( | |
| 180 base::StringPrintf("?source=%s&%s", source.c_str(), | |
|
guohui
2014/09/26 17:36:02
do we know if source is not already used by gaia a
Roger Tawa OOO till Jul 10th
2014/09/26 19:42:39
Yes I already checked with gaia folks.
| |
| 181 query.c_str())); | |
|
Mike Lerman
2014/09/26 16:57:07
If query.empty() then you're adding an un-needed &
Roger Tawa OOO till Jul 10th
2014/09/26 19:42:39
Unfortunately, GURL::Resolve("?foo=bar") removes a
Mike Lerman
2014/09/26 20:18:10
I can't find one. Is it worth having a condition,
Roger Tawa OOO till Jul 10th
2014/09/27 00:30:27
Yup, that's why I did not do so.
| |
| 182 } | |
| 183 } | |
| 184 | |
| 185 // static | |
| 186 GURL GaiaAuthFetcher::BuildGetCheckConnectionInfoURL( | |
| 187 const std::string& source) { | |
| 188 return source.empty() | |
| 189 ? GaiaUrls::GetInstance()->get_check_connection_info_url() | |
| 190 : GaiaUrls::GetInstance()->get_check_connection_info_url().Resolve( | |
| 191 base::StringPrintf("?source=%s", source.c_str())); | |
| 192 } | |
| 193 | |
| 173 GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, | 194 GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, |
| 174 const std::string& source, | 195 const std::string& source, |
| 175 net::URLRequestContextGetter* getter) | 196 net::URLRequestContextGetter* getter) |
| 176 : consumer_(consumer), | 197 : consumer_(consumer), |
| 177 getter_(getter), | 198 getter_(getter), |
| 178 source_(source), | 199 source_(source), |
| 179 client_login_gurl_(GaiaUrls::GetInstance()->client_login_url()), | 200 client_login_gurl_(GaiaUrls::GetInstance()->client_login_url()), |
| 180 issue_auth_token_gurl_(GaiaUrls::GetInstance()->issue_auth_token_url()), | 201 issue_auth_token_gurl_(GaiaUrls::GetInstance()->issue_auth_token_url()), |
| 181 oauth2_token_gurl_(GaiaUrls::GetInstance()->oauth2_token_url()), | 202 oauth2_token_gurl_(GaiaUrls::GetInstance()->oauth2_token_url()), |
| 182 oauth2_revoke_gurl_(GaiaUrls::GetInstance()->oauth2_revoke_url()), | 203 oauth2_revoke_gurl_(GaiaUrls::GetInstance()->oauth2_revoke_url()), |
| 183 get_user_info_gurl_(GaiaUrls::GetInstance()->get_user_info_url()), | 204 get_user_info_gurl_(GaiaUrls::GetInstance()->get_user_info_url()), |
| 184 merge_session_gurl_(GaiaUrls::GetInstance()->merge_session_url()), | 205 merge_session_gurl_(GaiaUrls::GetInstance()->merge_session_url()), |
| 185 uberauth_token_gurl_(GaiaUrls::GetInstance()->oauth1_login_url().Resolve( | 206 uberauth_token_gurl_(GaiaUrls::GetInstance()->oauth1_login_url().Resolve( |
| 186 base::StringPrintf(kUberAuthTokenURLFormat, source.c_str()))), | 207 base::StringPrintf(kUberAuthTokenURLFormat, source.c_str()))), |
| 187 oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), | 208 oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), |
| 188 list_accounts_gurl_(GaiaUrls::GetInstance()->list_accounts_url()), | 209 list_accounts_gurl_(BuildListAccountsURL(source)), |
| 189 get_check_connection_info_url_( | 210 get_check_connection_info_url_(BuildGetCheckConnectionInfoURL(source)), |
| 190 GaiaUrls::GetInstance()->get_check_connection_info_url()), | |
| 191 client_login_to_oauth2_gurl_( | 211 client_login_to_oauth2_gurl_( |
| 192 GaiaUrls::GetInstance()->client_login_to_oauth2_url()), | 212 GaiaUrls::GetInstance()->client_login_to_oauth2_url()), |
| 193 fetch_pending_(false) {} | 213 fetch_pending_(false) {} |
| 194 | 214 |
| 195 GaiaAuthFetcher::~GaiaAuthFetcher() {} | 215 GaiaAuthFetcher::~GaiaAuthFetcher() {} |
| 196 | 216 |
| 197 bool GaiaAuthFetcher::HasPendingFetch() { | 217 bool GaiaAuthFetcher::HasPendingFetch() { |
| 198 return fetch_pending_; | 218 return fetch_pending_; |
| 199 } | 219 } |
| 200 | 220 |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 NOTREACHED(); | 994 NOTREACHED(); |
| 975 } | 995 } |
| 976 } | 996 } |
| 977 | 997 |
| 978 // static | 998 // static |
| 979 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 999 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 980 const std::string& alleged_error) { | 1000 const std::string& alleged_error) { |
| 981 return alleged_error.find(kSecondFactor) != | 1001 return alleged_error.find(kSecondFactor) != |
| 982 std::string::npos; | 1002 std::string::npos; |
| 983 } | 1003 } |
| OLD | NEW |