Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: components/autofill/core/browser/payments/payments_client.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/autofill/core/browser/payments/payments_client.h" 5 #include "components/autofill/core/browser/payments/payments_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 std::string GetRequestContentType() override { 164 std::string GetRequestContentType() override {
165 return "application/x-www-form-urlencoded"; 165 return "application/x-www-form-urlencoded";
166 } 166 }
167 167
168 std::string GetRequestContent() override { 168 std::string GetRequestContent() override {
169 base::DictionaryValue request_dict; 169 base::DictionaryValue request_dict;
170 request_dict.SetString("encrypted_cvc", "__param:s7e_13_cvc"); 170 request_dict.SetString("encrypted_cvc", "__param:s7e_13_cvc");
171 request_dict.SetString("credit_card_id", request_details_.card.server_id()); 171 request_dict.SetString("credit_card_id", request_details_.card.server_id());
172 request_dict.Set("risk_data_encoded", 172 request_dict.Set("risk_data_encoded",
173 BuildRiskDictionary(request_details_.risk_data)); 173 BuildRiskDictionary(request_details_.risk_data));
174 request_dict.Set("context", base::WrapUnique(new base::DictionaryValue())); 174 request_dict.Set("context", base::MakeUnique<base::DictionaryValue>());
175 175
176 int value = 0; 176 int value = 0;
177 if (base::StringToInt(request_details_.user_response.exp_month, &value)) 177 if (base::StringToInt(request_details_.user_response.exp_month, &value))
178 request_dict.SetInteger("expiration_month", value); 178 request_dict.SetInteger("expiration_month", value);
179 if (base::StringToInt(request_details_.user_response.exp_year, &value)) 179 if (base::StringToInt(request_details_.user_response.exp_year, &value))
180 request_dict.SetInteger("expiration_year", value); 180 request_dict.SetInteger("expiration_year", value);
181 181
182 std::string json_request; 182 std::string json_request;
183 base::JSONWriter::Write(request_dict, &json_request); 183 base::JSONWriter::Write(request_dict, &json_request);
184 std::string request_content = base::StringPrintf( 184 std::string request_content = base::StringPrintf(
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 PaymentsClient::~PaymentsClient() {} 351 PaymentsClient::~PaymentsClient() {}
352 352
353 void PaymentsClient::Prepare() { 353 void PaymentsClient::Prepare() {
354 if (access_token_.empty()) 354 if (access_token_.empty())
355 StartTokenFetch(false); 355 StartTokenFetch(false);
356 } 356 }
357 357
358 void PaymentsClient::UnmaskCard( 358 void PaymentsClient::UnmaskCard(
359 const PaymentsClient::UnmaskRequestDetails& request_details) { 359 const PaymentsClient::UnmaskRequestDetails& request_details) {
360 IssueRequest(base::WrapUnique(new UnmaskCardRequest(request_details)), true); 360 IssueRequest(base::MakeUnique<UnmaskCardRequest>(request_details), true);
361 } 361 }
362 362
363 void PaymentsClient::GetUploadDetails(const std::string& app_locale) { 363 void PaymentsClient::GetUploadDetails(const std::string& app_locale) {
364 IssueRequest(base::WrapUnique(new GetUploadDetailsRequest(app_locale)), 364 IssueRequest(base::MakeUnique<GetUploadDetailsRequest>(app_locale), false);
365 false);
366 } 365 }
367 366
368 void PaymentsClient::UploadCard( 367 void PaymentsClient::UploadCard(
369 const PaymentsClient::UploadRequestDetails& request_details) { 368 const PaymentsClient::UploadRequestDetails& request_details) {
370 IssueRequest(base::WrapUnique(new UploadCardRequest(request_details)), true); 369 IssueRequest(base::MakeUnique<UploadCardRequest>(request_details), true);
371 } 370 }
372 371
373 void PaymentsClient::IssueRequest(std::unique_ptr<PaymentsRequest> request, 372 void PaymentsClient::IssueRequest(std::unique_ptr<PaymentsRequest> request,
374 bool authenticate) { 373 bool authenticate) {
375 request_ = std::move(request); 374 request_ = std::move(request);
376 has_retried_authorization_ = false; 375 has_retried_authorization_ = false;
377 InitializeUrlFetcher(); 376 InitializeUrlFetcher();
378 377
379 if (!authenticate) 378 if (!authenticate)
380 url_fetcher_->Start(); 379 url_fetcher_->Start();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 520
522 void PaymentsClient::SetOAuth2TokenAndStartRequest() { 521 void PaymentsClient::SetOAuth2TokenAndStartRequest() {
523 url_fetcher_->AddExtraRequestHeader(net::HttpRequestHeaders::kAuthorization + 522 url_fetcher_->AddExtraRequestHeader(net::HttpRequestHeaders::kAuthorization +
524 std::string(": Bearer ") + access_token_); 523 std::string(": Bearer ") + access_token_);
525 524
526 url_fetcher_->Start(); 525 url_fetcher_->Start();
527 } 526 }
528 527
529 } // namespace payments 528 } // namespace payments
530 } // namespace autofill 529 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698