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

Side by Side Diff: components/autofill/content/browser/autocheckout_manager.cc

Issue 21054003: Autocheckout: Manually revert r208999 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/content/browser/autocheckout_manager.h" 5 #include "components/autofill/content/browser/autocheckout_manager.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/content/browser/autocheckout_request_manager.h" 10 #include "components/autofill/content/browser/autocheckout_request_manager.h"
11 #include "components/autofill/content/browser/autocheckout_statistic.h"
12 #include "components/autofill/content/browser/autocheckout_steps.h" 11 #include "components/autofill/content/browser/autocheckout_steps.h"
13 #include "components/autofill/core/browser/autofill_country.h" 12 #include "components/autofill/core/browser/autofill_country.h"
14 #include "components/autofill/core/browser/autofill_field.h" 13 #include "components/autofill/core/browser/autofill_field.h"
15 #include "components/autofill/core/browser/autofill_manager.h" 14 #include "components/autofill/core/browser/autofill_manager.h"
16 #include "components/autofill/core/browser/autofill_metrics.h" 15 #include "components/autofill/core/browser/autofill_metrics.h"
17 #include "components/autofill/core/browser/autofill_profile.h" 16 #include "components/autofill/core/browser/autofill_profile.h"
18 #include "components/autofill/core/browser/credit_card.h" 17 #include "components/autofill/core/browser/credit_card.h"
19 #include "components/autofill/core/browser/field_types.h" 18 #include "components/autofill/core/browser/field_types.h"
20 #include "components/autofill/core/browser/form_structure.h" 19 #include "components/autofill/core/browser/form_structure.h"
21 #include "components/autofill/core/common/autofill_messages.h" 20 #include "components/autofill/core/common/autofill_messages.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 autofill_manager_->GetWebContents()->GetRenderViewHost(); 190 autofill_manager_->GetWebContents()->GetRenderViewHost();
192 if (!host) 191 if (!host)
193 return; 192 return;
194 193
195 host->Send(new AutofillMsg_FillFormsAndClick( 194 host->Send(new AutofillMsg_FillFormsAndClick(
196 host->GetRoutingID(), 195 host->GetRoutingID(),
197 filled_forms, 196 filled_forms,
198 page_meta_data_->click_elements_before_form_fill, 197 page_meta_data_->click_elements_before_form_fill,
199 page_meta_data_->click_elements_after_form_fill, 198 page_meta_data_->click_elements_after_form_fill,
200 page_meta_data_->proceed_element_descriptor)); 199 page_meta_data_->proceed_element_descriptor));
201 // Record time taken for navigating current page.
202 RecordTimeTaken(page_meta_data_->current_page_number);
203 } 200 }
204 201
205 void AutocheckoutManager::OnAutocheckoutPageCompleted( 202 void AutocheckoutManager::OnAutocheckoutPageCompleted(
206 AutocheckoutStatus status) { 203 AutocheckoutStatus status) {
207 if (!in_autocheckout_flow_) 204 if (!in_autocheckout_flow_)
208 return; 205 return;
209 206
210 DVLOG(2) << "OnAutocheckoutPageCompleted, page_no: " 207 DVLOG(2) << "OnAutocheckoutPageCompleted, page_no: "
211 << page_meta_data_->current_page_number 208 << page_meta_data_->current_page_number
212 << " status: " 209 << " status: "
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const FormStructure* result, 330 const FormStructure* result,
334 const std::string& google_transaction_id) { 331 const std::string& google_transaction_id) {
335 if (!result) { 332 if (!result) {
336 // When user cancels the dialog, |result| is NULL. 333 // When user cancels the dialog, |result| is NULL.
337 // TODO(): add AutocheckoutStatus.USER_CANCELLED, and call 334 // TODO(): add AutocheckoutStatus.USER_CANCELLED, and call
338 // EndAutocheckout(USER_CANCELLED) instead. 335 // EndAutocheckout(USER_CANCELLED) instead.
339 in_autocheckout_flow_ = false; 336 in_autocheckout_flow_ = false;
340 return; 337 return;
341 } 338 }
342 339
343 latency_statistics_.clear();
344 last_step_completion_timestamp_ = base::TimeTicks().Now();
345 google_transaction_id_ = google_transaction_id; 340 google_transaction_id_ = google_transaction_id;
346 in_autocheckout_flow_ = true; 341 in_autocheckout_flow_ = true;
347 should_preserve_dialog_ = true; 342 should_preserve_dialog_ = true;
348 metric_logger_->LogAutocheckoutBuyFlowMetric( 343 metric_logger_->LogAutocheckoutBuyFlowMetric(
349 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED); 344 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED);
350 345
351 profile_.reset(new AutofillProfile()); 346 profile_.reset(new AutofillProfile());
352 credit_card_.reset(new CreditCard()); 347 credit_card_.reset(new CreditCard());
353 billing_address_.reset(new AutofillProfile()); 348 billing_address_.reset(new AutofillProfile());
354 349
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 AutocheckoutRequestManager* autocheckout_request_manager = 491 AutocheckoutRequestManager* autocheckout_request_manager =
497 AutocheckoutRequestManager::FromBrowserContext( 492 AutocheckoutRequestManager::FromBrowserContext(
498 autofill_manager_->GetWebContents()->GetBrowserContext()); 493 autofill_manager_->GetWebContents()->GetBrowserContext());
499 // It is assumed that the domain Autocheckout starts on does not change 494 // It is assumed that the domain Autocheckout starts on does not change
500 // during the flow. If this proves to be incorrect, the |source_url| from 495 // during the flow. If this proves to be incorrect, the |source_url| from
501 // AutofillDialogControllerImpl will need to be provided in its callback in 496 // AutofillDialogControllerImpl will need to be provided in its callback in
502 // addition to the Google transaction id. 497 // addition to the Google transaction id.
503 autocheckout_request_manager->SendAutocheckoutStatus( 498 autocheckout_request_manager->SendAutocheckoutStatus(
504 status, 499 status,
505 autofill_manager_->GetWebContents()->GetURL(), 500 autofill_manager_->GetWebContents()->GetURL(),
506 latency_statistics_,
507 google_transaction_id_); 501 google_transaction_id_);
508 502
509 // Log the result of this Autocheckout flow to UMA. 503 // Log the result of this Autocheckout flow to UMA.
510 metric_logger_->LogAutocheckoutBuyFlowMetric( 504 metric_logger_->LogAutocheckoutBuyFlowMetric(
511 AutocheckoutStatusToUmaMetric(status)); 505 AutocheckoutStatusToUmaMetric(status));
512 506
513 google_transaction_id_ = kTransactionIdNotSet; 507 google_transaction_id_ = kTransactionIdNotSet;
514 } 508 }
515 509
516 void AutocheckoutManager::SetStepProgressForPage( 510 void AutocheckoutManager::SetStepProgressForPage(
517 int page_number, 511 int page_number,
518 AutocheckoutStepStatus status) { 512 AutocheckoutStepStatus status) {
519 if (page_types_.count(page_number) == 1) { 513 if (page_types_.count(page_number) == 1) {
520 for (size_t i = 0; i < page_types_[page_number].size(); ++i) { 514 for (size_t i = 0; i < page_types_[page_number].size(); ++i) {
521 autofill_manager_->delegate()->UpdateAutocheckoutStep( 515 autofill_manager_->delegate()->UpdateAutocheckoutStep(
522 page_types_[page_number][i], status); 516 page_types_[page_number][i], status);
523 } 517 }
524 } 518 }
525 } 519 }
526 520
527 void AutocheckoutManager::RecordTimeTaken(int page_number) {
528 AutocheckoutStatistic statistic;
529 statistic.page_number = page_number;
530 if (page_types_.count(page_number) == 1) {
531 for (size_t i = 0; i < page_types_[page_number].size(); ++i) {
532 statistic.steps.push_back(page_types_[page_number][i]);
533 }
534 }
535
536 statistic.time_taken =
537 base::TimeTicks().Now() - last_step_completion_timestamp_;
538 latency_statistics_.push_back(statistic);
539
540 // Reset timestamp.
541 last_step_completion_timestamp_ = base::TimeTicks().Now();
542 }
543
544 void AutocheckoutManager::EndAutocheckout(AutocheckoutStatus status) { 521 void AutocheckoutManager::EndAutocheckout(AutocheckoutStatus status) {
545 DCHECK(in_autocheckout_flow_); 522 DCHECK(in_autocheckout_flow_);
546 523
547 DVLOG(2) << "EndAutocheckout at step: " 524 DVLOG(2) << "EndAutocheckout at step: "
548 << page_meta_data_->current_page_number 525 << page_meta_data_->current_page_number
549 << " with status: " 526 << " with status: "
550 << status; 527 << status;
551 528
552 SendAutocheckoutStatus(status); 529 SendAutocheckoutStatus(status);
553 if (status == SUCCESS) 530 if (status == SUCCESS)
554 autofill_manager_->delegate()->OnAutocheckoutSuccess(); 531 autofill_manager_->delegate()->OnAutocheckoutSuccess();
555 else 532 else
556 autofill_manager_->delegate()->OnAutocheckoutError(); 533 autofill_manager_->delegate()->OnAutocheckoutError();
557 in_autocheckout_flow_ = false; 534 in_autocheckout_flow_ = false;
558 } 535 }
559 536
560 } // namespace autofill 537 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698