| 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/notifier/gaia_auth/gaiahelper.h" | 5 #include "chrome/browser/sync/notifier/gaia_auth/gaiahelper.h" |
| 6 #include "base/logging.h" |
| 6 #include "talk/base/common.h" | 7 #include "talk/base/common.h" |
| 7 #include "talk/base/cryptstring.h" | 8 #include "talk/base/cryptstring.h" |
| 8 #include "talk/base/httpclient.h" | 9 #include "talk/base/httpclient.h" |
| 9 #include "talk/base/httpcommon-inl.h" | 10 #include "talk/base/httpcommon-inl.h" |
| 10 #include "talk/base/stringutils.h" | 11 #include "talk/base/stringutils.h" |
| 11 #include "talk/base/urlencode.h" | 12 #include "talk/base/urlencode.h" |
| 12 #include "talk/xmpp/constants.h" | 13 #include "talk/xmpp/constants.h" |
| 13 #include "talk/xmpp/jid.h" | 14 #include "talk/xmpp/jid.h" |
| 14 | 15 |
| 15 /////////////////////////////////////////////////////////////////////////////// | 16 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 const talk_base::MemoryStream* stream = | 141 const talk_base::MemoryStream* stream = |
| 141 static_cast<const talk_base::MemoryStream*>( | 142 static_cast<const talk_base::MemoryStream*>( |
| 142 client.response().document.get()); | 143 client.response().document.get()); |
| 143 size_t length; | 144 size_t length; |
| 144 stream->GetPosition(&length); | 145 stream->GetPosition(&length); |
| 145 std::string response; | 146 std::string response; |
| 146 if (length > 0) { | 147 if (length > 0) { |
| 147 response.assign(stream->GetBuffer(), length); | 148 response.assign(stream->GetBuffer(), length); |
| 148 } | 149 } |
| 149 | 150 |
| 150 LOG(LS_INFO) << "GaiaAuth request to " << client.request().path; | 151 LOG(INFO) << "GaiaAuth request to " << client.request().path; |
| 151 LOG(LS_INFO) << "GaiaAuth Status Code: " << status_code; | 152 LOG(INFO) << "GaiaAuth Status Code: " << status_code; |
| 152 LOG(LS_INFO) << response; | 153 LOG(INFO) << response; |
| 153 | 154 |
| 154 if (status_code == talk_base::HC_FORBIDDEN) { | 155 if (status_code == talk_base::HC_FORBIDDEN) { |
| 155 // The error URL may be the relative path to the captcha jpg. | 156 // The error URL may be the relative path to the captcha jpg. |
| 156 std::string image_url = GetValueForKey("CaptchaUrl", response); | 157 std::string image_url = GetValueForKey("CaptchaUrl", response); |
| 157 if (!image_url.empty()) { | 158 if (!image_url.empty()) { |
| 158 // We should activate this "full url code" once we have a better ways | 159 // We should activate this "full url code" once we have a better ways |
| 159 // to crack the URL for later download. Right now we are too dependent | 160 // to crack the URL for later download. Right now we are too dependent |
| 160 // on what Gaia returns. | 161 // on what Gaia returns. |
| 161 #if 0 | 162 #if 0 |
| 162 if (image_url.find("http://") != 0 && | 163 if (image_url.find("http://") != 0 && |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 client.response().document.get()); | 228 client.response().document.get()); |
| 228 size_t length; | 229 size_t length; |
| 229 stream->GetPosition(&length); | 230 stream->GetPosition(&length); |
| 230 while ((length > 0) && isspace(stream->GetBuffer()[length-1])) | 231 while ((length > 0) && isspace(stream->GetBuffer()[length-1])) |
| 231 --length; | 232 --length; |
| 232 auth_token->assign(stream->GetBuffer(), length); | 233 auth_token->assign(stream->GetBuffer(), length); |
| 233 return auth_token->empty() ? GR_ERROR : GR_SUCCESS; | 234 return auth_token->empty() ? GR_ERROR : GR_SUCCESS; |
| 234 } | 235 } |
| 235 | 236 |
| 236 } // namespace buzz | 237 } // namespace buzz |
| OLD | NEW |