| 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 "chrome/browser/autofill/wallet/wallet_client.h" | 5 #include "chrome/browser/autofill/wallet/wallet_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 billing_address.phone_number()); | 257 billing_address.phone_number()); |
| 258 request_dict.Set("upgraded_billing_address", | 258 request_dict.Set("upgraded_billing_address", |
| 259 billing_address.ToDictionaryWithoutID().release()); | 259 billing_address.ToDictionaryWithoutID().release()); |
| 260 | 260 |
| 261 std::string post_body; | 261 std::string post_body; |
| 262 base::JSONWriter::Write(&request_dict, &post_body); | 262 base::JSONWriter::Write(&request_dict, &post_body); |
| 263 | 263 |
| 264 MakeWalletRequest(GetSaveToWalletUrl(), post_body, observer, kJsonMimeType); | 264 MakeWalletRequest(GetSaveToWalletUrl(), post_body, observer, kJsonMimeType); |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool WalletClient::HasRequestInProgress() const { |
| 268 return request_.get() != NULL; |
| 269 } |
| 270 |
| 267 void WalletClient::MakeWalletRequest(const GURL& url, | 271 void WalletClient::MakeWalletRequest(const GURL& url, |
| 268 const std::string& post_body, | 272 const std::string& post_body, |
| 269 WalletClientObserver* observer, | 273 WalletClientObserver* observer, |
| 270 const std::string& content_type) { | 274 const std::string& content_type) { |
| 271 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; | 275 DCHECK(!HasRequestInProgress()); |
| 272 DCHECK(observer); | 276 DCHECK(observer); |
| 273 | 277 |
| 274 observer_ = observer; | 278 observer_ = observer; |
| 275 | 279 |
| 276 request_.reset(net::URLFetcher::Create( | 280 request_.reset(net::URLFetcher::Create( |
| 277 0, url, net::URLFetcher::POST, this)); | 281 0, url, net::URLFetcher::POST, this)); |
| 278 request_->SetRequestContext(context_getter_); | 282 request_->SetRequestContext(context_getter_); |
| 279 DVLOG(1) << "url=" << url << ", post_body=" << post_body | 283 DVLOG(1) << "url=" << url << ", post_body=" << post_body |
| 280 << ", content_type=" << content_type; | 284 << ", content_type=" << content_type; |
| 281 request_->SetUploadData(content_type, post_body); | 285 request_->SetUploadData(content_type, post_body); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 : context_getter_(context_getter), | 453 : context_getter_(context_getter), |
| 450 observer_(NULL), | 454 observer_(NULL), |
| 451 request_type_(NO_PENDING_REQUEST) { | 455 request_type_(NO_PENDING_REQUEST) { |
| 452 DCHECK(context_getter); | 456 DCHECK(context_getter); |
| 453 } | 457 } |
| 454 | 458 |
| 455 WalletClient::~WalletClient() {} | 459 WalletClient::~WalletClient() {} |
| 456 | 460 |
| 457 } // namespace wallet | 461 } // namespace wallet |
| 458 | 462 |
| OLD | NEW |