| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/login/mock_url_fetchers.h" | 5 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 url_(url), | 53 url_(url), |
| 54 status_(net::URLRequestStatus::CANCELED, 0) { | 54 status_(net::URLRequestStatus::CANCELED, 0) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 GotCanceledFetcher::~GotCanceledFetcher() {} | 57 GotCanceledFetcher::~GotCanceledFetcher() {} |
| 58 | 58 |
| 59 void GotCanceledFetcher::Start() { | 59 void GotCanceledFetcher::Start() { |
| 60 delegate()->OnURLFetchComplete(this); | 60 delegate()->OnURLFetchComplete(this); |
| 61 } | 61 } |
| 62 | 62 |
| 63 const GURL& GotCanceledFetcher::url() const { | 63 const GURL& GotCanceledFetcher::GetUrl() const { |
| 64 return url_; | 64 return url_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const net::URLRequestStatus& GotCanceledFetcher::status() const { | 67 const net::URLRequestStatus& GotCanceledFetcher::GetStatus() const { |
| 68 return status_; | 68 return status_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 int GotCanceledFetcher::response_code() const { | 71 int GotCanceledFetcher::GetResponseCode() const { |
| 72 return RC_FORBIDDEN; | 72 return RC_FORBIDDEN; |
| 73 } | 73 } |
| 74 | 74 |
| 75 SuccessFetcher::SuccessFetcher(bool success, | 75 SuccessFetcher::SuccessFetcher(bool success, |
| 76 const GURL& url, | 76 const GURL& url, |
| 77 const std::string& results, | 77 const std::string& results, |
| 78 URLFetcher::RequestType request_type, | 78 URLFetcher::RequestType request_type, |
| 79 content::URLFetcherDelegate* d) | 79 content::URLFetcherDelegate* d) |
| 80 : URLFetcher(url, request_type, d), | 80 : URLFetcher(url, request_type, d), |
| 81 url_(url), | 81 url_(url), |
| 82 status_(net::URLRequestStatus::SUCCESS, 0) { | 82 status_(net::URLRequestStatus::SUCCESS, 0) { |
| 83 } | 83 } |
| 84 | 84 |
| 85 SuccessFetcher::~SuccessFetcher() {} | 85 SuccessFetcher::~SuccessFetcher() {} |
| 86 | 86 |
| 87 void SuccessFetcher::Start() { | 87 void SuccessFetcher::Start() { |
| 88 delegate()->OnURLFetchComplete(this); | 88 delegate()->OnURLFetchComplete(this); |
| 89 } | 89 } |
| 90 | 90 |
| 91 const GURL& SuccessFetcher::url() const { | 91 const GURL& SuccessFetcher::GetUrl() const { |
| 92 return url_; | 92 return url_; |
| 93 } | 93 } |
| 94 | 94 |
| 95 const net::URLRequestStatus& SuccessFetcher::status() const { | 95 const net::URLRequestStatus& SuccessFetcher::GetStatus() const { |
| 96 return status_; | 96 return status_; |
| 97 } | 97 } |
| 98 | 98 |
| 99 int SuccessFetcher::response_code() const { | 99 int SuccessFetcher::GetResponseCode() const { |
| 100 return RC_REQUEST_OK; | 100 return RC_REQUEST_OK; |
| 101 } | 101 } |
| 102 | 102 |
| 103 FailFetcher::FailFetcher(bool success, | 103 FailFetcher::FailFetcher(bool success, |
| 104 const GURL& url, | 104 const GURL& url, |
| 105 const std::string& results, | 105 const std::string& results, |
| 106 URLFetcher::RequestType request_type, | 106 URLFetcher::RequestType request_type, |
| 107 content::URLFetcherDelegate* d) | 107 content::URLFetcherDelegate* d) |
| 108 : URLFetcher(url, request_type, d), | 108 : URLFetcher(url, request_type, d), |
| 109 url_(url), | 109 url_(url), |
| 110 status_(net::URLRequestStatus::FAILED, ECONNRESET) { | 110 status_(net::URLRequestStatus::FAILED, ECONNRESET) { |
| 111 } | 111 } |
| 112 | 112 |
| 113 FailFetcher::~FailFetcher() {} | 113 FailFetcher::~FailFetcher() {} |
| 114 | 114 |
| 115 void FailFetcher::Start() { | 115 void FailFetcher::Start() { |
| 116 delegate()->OnURLFetchComplete(this); | 116 delegate()->OnURLFetchComplete(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 const GURL& FailFetcher::url() const { | 119 const GURL& FailFetcher::GetUrl() const { |
| 120 return url_; | 120 return url_; |
| 121 } | 121 } |
| 122 | 122 |
| 123 const net::URLRequestStatus& FailFetcher::status() const { | 123 const net::URLRequestStatus& FailFetcher::GetStatus() const { |
| 124 return status_; | 124 return status_; |
| 125 } | 125 } |
| 126 | 126 |
| 127 int FailFetcher::response_code() const { | 127 int FailFetcher::GetResponseCode() const { |
| 128 return RC_REQUEST_OK; | 128 return RC_REQUEST_OK; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 const char CaptchaFetcher::kCaptchaToken[] = "token"; | 132 const char CaptchaFetcher::kCaptchaToken[] = "token"; |
| 133 // static | 133 // static |
| 134 const char CaptchaFetcher::kCaptchaUrlBase[] = "http://www.google.com/accounts/"
; | 134 const char CaptchaFetcher::kCaptchaUrlBase[] = "http://www.google.com/accounts/"
; |
| 135 // static | 135 // static |
| 136 const char CaptchaFetcher::kCaptchaUrlFragment[] = "fragment"; | 136 const char CaptchaFetcher::kCaptchaUrlFragment[] = "fragment"; |
| 137 // static | 137 // static |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 // static | 171 // static |
| 172 std::string CaptchaFetcher::GetUnlockUrl() { | 172 std::string CaptchaFetcher::GetUnlockUrl() { |
| 173 return kUnlockUrl; | 173 return kUnlockUrl; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void CaptchaFetcher::Start() { | 176 void CaptchaFetcher::Start() { |
| 177 delegate()->OnURLFetchComplete(this); | 177 delegate()->OnURLFetchComplete(this); |
| 178 } | 178 } |
| 179 | 179 |
| 180 const GURL& CaptchaFetcher::url() const { | 180 const GURL& CaptchaFetcher::GetUrl() const { |
| 181 return url_; | 181 return url_; |
| 182 } | 182 } |
| 183 | 183 |
| 184 const net::URLRequestStatus& CaptchaFetcher::status() const { | 184 const net::URLRequestStatus& CaptchaFetcher::GetStatus() const { |
| 185 return status_; | 185 return status_; |
| 186 } | 186 } |
| 187 | 187 |
| 188 int CaptchaFetcher::response_code() const { | 188 int CaptchaFetcher::GetResponseCode() const { |
| 189 return RC_FORBIDDEN; | 189 return RC_FORBIDDEN; |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool CaptchaFetcher::GetResponseAsString( | 192 bool CaptchaFetcher::GetResponseAsString( |
| 193 std::string* out_response_string) const { | 193 std::string* out_response_string) const { |
| 194 *out_response_string = data_; | 194 *out_response_string = data_; |
| 195 return true; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 HostedFetcher::HostedFetcher(bool success, | 198 HostedFetcher::HostedFetcher(bool success, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 211 void HostedFetcher::Start() { | 211 void HostedFetcher::Start() { |
| 212 VLOG(1) << upload_data(); | 212 VLOG(1) << upload_data(); |
| 213 if (upload_data().find("HOSTED") == std::string::npos) { | 213 if (upload_data().find("HOSTED") == std::string::npos) { |
| 214 VLOG(1) << "HostedFetcher failing request"; | 214 VLOG(1) << "HostedFetcher failing request"; |
| 215 response_code_ = RC_FORBIDDEN; | 215 response_code_ = RC_FORBIDDEN; |
| 216 data_.assign("Error=BadAuthentication"); | 216 data_.assign("Error=BadAuthentication"); |
| 217 } | 217 } |
| 218 delegate()->OnURLFetchComplete(this); | 218 delegate()->OnURLFetchComplete(this); |
| 219 } | 219 } |
| 220 | 220 |
| 221 const GURL& HostedFetcher::url() const { | 221 const GURL& HostedFetcher::GetUrl() const { |
| 222 return url_; | 222 return url_; |
| 223 } | 223 } |
| 224 | 224 |
| 225 const net::URLRequestStatus& HostedFetcher::status() const { | 225 const net::URLRequestStatus& HostedFetcher::GetStatus() const { |
| 226 return status_; | 226 return status_; |
| 227 } | 227 } |
| 228 | 228 |
| 229 int HostedFetcher::response_code() const { | 229 int HostedFetcher::GetResponseCode() const { |
| 230 return response_code_;; | 230 return response_code_;; |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool HostedFetcher::GetResponseAsString( | 233 bool HostedFetcher::GetResponseAsString( |
| 234 std::string* out_response_string) const { | 234 std::string* out_response_string) const { |
| 235 *out_response_string = data_; | 235 *out_response_string = data_; |
| 236 return true; | 236 return true; |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace chromeos | 239 } // namespace chromeos |
| OLD | NEW |