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

Unified Diff: components/autofill/browser/autocheckout_manager.cc

Issue 12457033: Implements SendAutocheckoutStatus API calls for stats tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaning up Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/autocheckout_manager.cc
diff --git a/components/autofill/browser/autocheckout_manager.cc b/components/autofill/browser/autocheckout_manager.cc
index 9b8804bce5daca8bf0eb82ac072181af9b2d06b4..e399d3af60ac28f0549b4893603f8e1fcf2673e7 100644
--- a/components/autofill/browser/autocheckout_manager.cc
+++ b/components/autofill/browser/autocheckout_manager.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/utf_string_conversions.h"
+#include "components/autofill/browser/autocheckout_request_manager.h"
#include "components/autofill/browser/autofill_country.h"
#include "components/autofill/browser/autofill_field.h"
#include "components/autofill/browser/autofill_manager.h"
@@ -14,7 +15,6 @@
#include "components/autofill/browser/credit_card.h"
#include "components/autofill/browser/field_types.h"
#include "components/autofill/browser/form_structure.h"
-#include "components/autofill/common/autocheckout_status.h"
#include "components/autofill/common/autofill_messages.h"
#include "components/autofill/common/form_data.h"
#include "components/autofill/common/form_field_data.h"
@@ -78,6 +78,8 @@ AutocheckoutManager::AutocheckoutManager(AutofillManager* autofill_manager)
is_autocheckout_bubble_showing_(false),
in_autocheckout_flow_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
+ AutocheckoutRequestManager::CreateFromBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
}
AutocheckoutManager::~AutocheckoutManager() {
@@ -117,6 +119,22 @@ void AutocheckoutManager::FillForms() {
*page_meta_data_->proceed_element_descriptor));
}
+void AutocheckoutManager::OnClickFailed(AutocheckoutStatus status) {
+ AutocheckoutRequestManager* autocheckout_request_manager =
+ AutocheckoutRequestManager::FromBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
+ // It is assumed that the domain Autocheckout starts on does not change during
+ // the flow. If this proves to be incorrect, the |source_url| from
+ // AutofillDialogControllerImpl will need to be provided in its callback in
+ // addition to the Google transaction id.
+ autocheckout_request_manager->SendAutocheckoutStatus(
+ status,
+ autofill_manager_->GetWebContents()->GetURL(),
+ google_transaction_id_);
Ilya Sherman 2013/03/26 23:50:01 nit: DCHECK that the transaction_id_ is set?
ahutter 2013/03/27 01:23:33 By set do you mean non-empty? Because empty is ok.
Ilya Sherman 2013/03/27 01:36:55 Maybe you should initialize the transaction id to
ahutter 2013/03/27 19:30:49 Done.
+ autofill_manager_->delegate()->OnAutocheckoutError();
+}
+
+
void AutocheckoutManager::OnLoadedPageMetaData(
scoped_ptr<AutocheckoutPageMetaData> page_meta_data) {
scoped_ptr<AutocheckoutPageMetaData> old_meta_data =
@@ -128,24 +146,40 @@ void AutocheckoutManager::OnLoadedPageMetaData(
if (!in_autocheckout_flow_)
return;
+ AutocheckoutStatus status = SUCCESS;
+
// Missing Autofill server results.
if (!page_meta_data_) {
in_autocheckout_flow_ = false;
+ status = MISSING_FIELDMAPPING;
} else if (page_meta_data_->IsStartOfAutofillableFlow()) {
// Not possible unless Autocheckout failed to proceed.
in_autocheckout_flow_ = false;
+ status = CANNOT_PROCEED;
} else if (!page_meta_data_->IsInAutofillableFlow()) {
// Missing Autocheckout meta data in the Autofill server results.
in_autocheckout_flow_ = false;
+ status = MISSING_FIELDMAPPING;
} else if (page_meta_data_->current_page_number <=
old_meta_data->current_page_number) {
// Not possible unless Autocheckout failed to proceed.
in_autocheckout_flow_ = false;
+ status = CANNOT_PROCEED;
}
// Encountered an error during the Autocheckout flow.
if (!in_autocheckout_flow_) {
- // TODO(ahutter): SendAutocheckoutStatus of the error.
+ AutocheckoutRequestManager* autocheckout_request_manager =
+ AutocheckoutRequestManager::FromBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
+ // It is assumed that the domain Autocheckout starts on does not change
+ // during the flow. If this proves to be incorrect, the |source_url| from
+ // AutofillDialogControllerImpl will need to be provided in its callback in
+ // addition to the Google transaction id.
+ autocheckout_request_manager->SendAutocheckoutStatus(
+ status,
+ autofill_manager_->GetWebContents()->GetURL(),
+ google_transaction_id_);
Ilya Sherman 2013/03/26 23:50:01 nit: Decompose this code into a shared method rath
ahutter 2013/03/27 01:23:33 Done.
autofill_manager_->delegate()->OnAutocheckoutError();
return;
}
@@ -157,7 +191,17 @@ void AutocheckoutManager::OnLoadedPageMetaData(
FillForms();
// If the current page is the last page in the flow, close the dialog.
if (page_meta_data_->IsEndOfAutofillableFlow()) {
- // TODO(ahutter): SendAutocheckoutStatus of SUCCESS.
+ AutocheckoutRequestManager* autocheckout_request_manager =
+ AutocheckoutRequestManager::FromBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
+ // It is assumed that the domain Autocheckout starts on does not change
+ // during the flow. If this proves to be incorrect, the |source_url| from
+ // AutofillDialogControllerImpl will need to be provided in its callback in
+ // addition to the Google transaction id.
+ autocheckout_request_manager->SendAutocheckoutStatus(
+ status,
+ autofill_manager_->GetWebContents()->GetURL(),
+ google_transaction_id_);
Ilya Sherman 2013/03/26 23:50:01 Ditto.
ahutter 2013/03/27 01:23:33 Done.
autofill_manager_->delegate()->HideRequestAutocompleteDialog();
in_autocheckout_flow_ = false;
}
@@ -200,7 +244,7 @@ void AutocheckoutManager::MaybeShowAutocheckoutDialog(
FormData form = BuildAutocheckoutFormData();
form.ssl_status = ssl_status;
- base::Callback<void(const FormStructure*)> callback =
+ base::Callback<void(const FormStructure*, const std::string&)> callback =
base::Bind(&AutocheckoutManager::ReturnAutocheckoutData,
weak_ptr_factory_.GetWeakPtr());
autofill_manager_->ShowRequestAutocompleteDialog(
@@ -215,10 +259,13 @@ bool AutocheckoutManager::IsInAutofillableFlow() const {
return page_meta_data_ && page_meta_data_->IsInAutofillableFlow();
}
-void AutocheckoutManager::ReturnAutocheckoutData(const FormStructure* result) {
+void AutocheckoutManager::ReturnAutocheckoutData(
+ const FormStructure* result,
+ const std::string& google_transaction_id) {
if (!result)
return;
+ google_transaction_id_ = google_transaction_id;
in_autocheckout_flow_ = true;
profile_.reset(new AutofillProfile());
@@ -246,7 +293,17 @@ void AutocheckoutManager::ReturnAutocheckoutData(const FormStructure* result) {
// If the current page is the last page in the flow, close the dialog.
if (page_meta_data_->IsEndOfAutofillableFlow()) {
- // TODO(ahutter): SendAutocheckoutStatus of SUCCESS.
+ AutocheckoutRequestManager* autocheckout_request_manager =
+ AutocheckoutRequestManager::FromBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
+ // It is assumed that the domain Autocheckout starts on does not change
+ // during the flow. If this proves to be incorrect, the |source_url| from
+ // AutofillDialogControllerImpl will need to be provided in its callback in
+ // addition to the Google transaction id.
+ autocheckout_request_manager->SendAutocheckoutStatus(
+ SUCCESS,
+ autofill_manager_->GetWebContents()->GetURL(),
+ google_transaction_id_);
Ilya Sherman 2013/03/26 23:50:01 Ditto
ahutter 2013/03/27 01:23:33 Done.
autofill_manager_->delegate()->HideRequestAutocompleteDialog();
in_autocheckout_flow_ = false;
}

Powered by Google App Engine
This is Rietveld 408576698