summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 21:16:29 +0000
committerahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 21:16:29 +0000
commit6f99d22158a48c7ab442b1f8a53cad83c5f6757e (patch)
tree23c3edc58e957070a27840564bb9b7ae96313593 /components
parent62d4d61ec933f2290e2b54f674afed88555ecfa5 (diff)
downloadchromium_src-6f99d22158a48c7ab442b1f8a53cad83c5f6757e.zip
chromium_src-6f99d22158a48c7ab442b1f8a53cad83c5f6757e.tar.gz
chromium_src-6f99d22158a48c7ab442b1f8a53cad83c5f6757e.tar.bz2
Implements SendAutocheckoutStatus API calls for stats tracking.
BUG=224159 Review URL: https://chromiumcodereview.appspot.com/12457033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/autofill/browser/autocheckout_manager.cc53
-rw-r--r--components/autofill/browser/autocheckout_manager.h13
-rw-r--r--components/autofill/browser/autocheckout_manager_unittest.cc14
-rw-r--r--components/autofill/browser/autocheckout_request_manager.cc129
-rw-r--r--components/autofill/browser/autocheckout_request_manager.h98
-rw-r--r--components/autofill/browser/autofill_manager.cc11
-rw-r--r--components/autofill/browser/autofill_manager.h6
-rw-r--r--components/autofill/browser/autofill_manager_delegate.h3
-rw-r--r--components/autofill/browser/test_autofill_manager_delegate.cc3
-rw-r--r--components/autofill/browser/test_autofill_manager_delegate.h3
-rw-r--r--components/autofill/browser/wallet/wallet_client.cc1
-rw-r--r--components/autofill/browser/wallet/wallet_client_delegate.h3
-rw-r--r--components/autofill/browser/wallet/wallet_client_unittest.cc21
-rw-r--r--components/autofill/renderer/autofill_agent.cc17
14 files changed, 326 insertions, 49 deletions
diff --git a/components/autofill/browser/autocheckout_manager.cc b/components/autofill/browser/autocheckout_manager.cc
index 9b8804b..fbb9115 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"
@@ -68,6 +68,8 @@ FormData BuildAutocheckoutFormData() {
return formdata;
}
+const char kTransactionIdNotSet[] = "transaction id not set";
+
} // namespace
namespace autofill {
@@ -77,8 +79,8 @@ AutocheckoutManager::AutocheckoutManager(AutofillManager* autofill_manager)
autocheckout_offered_(false),
is_autocheckout_bubble_showing_(false),
in_autocheckout_flow_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
-}
+ google_transaction_id_(kTransactionIdNotSet),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {}
AutocheckoutManager::~AutocheckoutManager() {
}
@@ -117,6 +119,11 @@ void AutocheckoutManager::FillForms() {
*page_meta_data_->proceed_element_descriptor));
}
+void AutocheckoutManager::OnClickFailed(AutocheckoutStatus status) {
+ SendAutocheckoutStatus(status);
+ autofill_manager_->delegate()->OnAutocheckoutError();
+}
+
void AutocheckoutManager::OnLoadedPageMetaData(
scoped_ptr<AutocheckoutPageMetaData> page_meta_data) {
scoped_ptr<AutocheckoutPageMetaData> old_meta_data =
@@ -128,24 +135,30 @@ 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.
+ SendAutocheckoutStatus(status);
autofill_manager_->delegate()->OnAutocheckoutError();
return;
}
@@ -157,7 +170,7 @@ 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.
+ SendAutocheckoutStatus(status);
autofill_manager_->delegate()->HideRequestAutocompleteDialog();
in_autocheckout_flow_ = false;
}
@@ -200,7 +213,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 +228,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 +262,7 @@ 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.
+ SendAutocheckoutStatus(SUCCESS);
autofill_manager_->delegate()->HideRequestAutocompleteDialog();
in_autocheckout_flow_ = false;
}
@@ -290,4 +306,25 @@ void AutocheckoutManager::SetValue(const AutofillField& field,
profile_->FillFormField(field, 0, field_to_fill);
}
+void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) {
+ // To ensure stale data isn't being sent.
+ DCHECK_NE(kTransactionIdNotSet, google_transaction_id_);
+
+ AutocheckoutRequestManager::CreateForBrowserContext(
+ autofill_manager_->GetWebContents()->GetBrowserContext());
+ 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_);
+
+ google_transaction_id_ = kTransactionIdNotSet;
+}
+
} // namespace autofill
diff --git a/components/autofill/browser/autocheckout_manager.h b/components/autofill/browser/autocheckout_manager.h
index 57a58e8..ffe2b2e 100644
--- a/components/autofill/browser/autocheckout_manager.h
+++ b/components/autofill/browser/autocheckout_manager.h
@@ -11,6 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "components/autofill/browser/autocheckout_page_meta_data.h"
+#include "components/autofill/common/autocheckout_status.h"
#include "ui/gfx/native_widget_types.h"
class AutofillField;
@@ -42,6 +43,10 @@ class AutocheckoutManager {
// gathered from the requestAutocomplete dialog.
void FillForms();
+ // Called when clicking a proceed element in an Autocheckout flow fails.
+ // |status| is the reason for the failure.
+ void OnClickFailed(AutocheckoutStatus status);
+
// Sets |page_meta_data_| with the meta data for the current page.
void OnLoadedPageMetaData(
scoped_ptr<AutocheckoutPageMetaData> page_meta_data);
@@ -84,7 +89,11 @@ class AutocheckoutManager {
bool IsInAutofillableFlow() const;
// Callback called from AutofillDialogController on filling up the UI form.
- void ReturnAutocheckoutData(const FormStructure* result);
+ void ReturnAutocheckoutData(const FormStructure* result,
+ const std::string& google_transaction_id);
+
+ // Sends |status| to Online Wallet using AutocheckoutRequestManager.
+ void SendAutocheckoutStatus(AutocheckoutStatus status);
// Sets value of form field data |field_to_fill| based on the Autofill
// field type specified by |field|.
@@ -115,6 +124,8 @@ class AutocheckoutManager {
// Whether or not the user is in an Autocheckout flow.
bool in_autocheckout_flow_;
+ std::string google_transaction_id_;
+
base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AutocheckoutManager);
diff --git a/components/autofill/browser/autocheckout_manager_unittest.cc b/components/autofill/browser/autocheckout_manager_unittest.cc
index 6983d65..280e249 100644
--- a/components/autofill/browser/autocheckout_manager_unittest.cc
+++ b/components/autofill/browser/autocheckout_manager_unittest.cc
@@ -5,6 +5,7 @@
#include "base/tuple.h"
#include "base/utf_string_conversions.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "chrome/test/base/testing_profile.h"
#include "components/autofill/browser/autocheckout_manager.h"
#include "components/autofill/browser/autofill_common_test.h"
#include "components/autofill/browser/autofill_manager.h"
@@ -237,9 +238,10 @@ class MockAutofillManagerDelegate : public TestAutofillManagerDelegate {
const GURL& source_url,
const AutofillMetrics& metric_logger,
DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback) OVERRIDE {
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback) OVERRIDE {
request_autocomplete_dialog_open_ = true;
- callback.Run(user_supplied_data_.get());
+ callback.Run(user_supplied_data_.get(), "google_transaction_id");
}
MOCK_METHOD1(UpdateProgressBar, void(double value));
@@ -297,7 +299,8 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
public:
AutocheckoutManagerTest()
: ChromeRenderViewHostTestHarness(),
- ui_thread_(BrowserThread::UI, &message_loop_) {
+ ui_thread_(BrowserThread::UI, &message_loop_),
+ io_thread_(BrowserThread::IO) {
}
std::vector<FormData> ReadFilledForms() {
@@ -355,6 +358,7 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
protected:
content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread io_thread_;
scoped_ptr<TestAutofillManager> autofill_manager_;
scoped_ptr<TestAutocheckoutManager> autocheckout_manager_;
scoped_ptr<MockAutofillManagerDelegate> autofill_manager_delegate_;
@@ -362,6 +366,8 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
private:
virtual void SetUp() OVERRIDE {
ChromeRenderViewHostTestHarness::SetUp();
+ io_thread_.StartIOThread();
+ profile()->CreateRequestContext();
autofill_manager_delegate_.reset(new MockAutofillManagerDelegate());
autofill_manager_.reset(new TestAutofillManager(
web_contents(),
@@ -374,7 +380,9 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
autocheckout_manager_.reset();
autofill_manager_delegate_.reset();
autofill_manager_.reset();
+ profile()->ResetRequestContext();
ChromeRenderViewHostTestHarness::TearDown();
+ io_thread_.Stop();
}
DISALLOW_COPY_AND_ASSIGN(AutocheckoutManagerTest);
diff --git a/components/autofill/browser/autocheckout_request_manager.cc b/components/autofill/browser/autocheckout_request_manager.cc
new file mode 100644
index 0000000..fcf9a33
--- /dev/null
+++ b/components/autofill/browser/autocheckout_request_manager.cc
@@ -0,0 +1,129 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/browser/autocheckout_request_manager.h"
+
+#include "components/autofill/browser/autofill_manager_delegate.h"
+#include "content/public/browser/browser_context.h"
+
+namespace {
+
+const char kAutocheckoutRequestManagerKey[] =
+ "browser_context_autocheckout_request_manager";
+
+} // namespace
+
+namespace autofill {
+
+AutocheckoutRequestManager::~AutocheckoutRequestManager() {}
+
+// static
+void AutocheckoutRequestManager::CreateForBrowserContext(
+ content::BrowserContext* browser_context) {
+ if (FromBrowserContext(browser_context))
+ return;
+
+ browser_context->SetUserData(
+ kAutocheckoutRequestManagerKey,
+ new AutocheckoutRequestManager(browser_context->GetRequestContext()));
+}
+
+// static
+AutocheckoutRequestManager* AutocheckoutRequestManager::FromBrowserContext(
+ content::BrowserContext* browser_context) {
+ return static_cast<AutocheckoutRequestManager*>(
+ browser_context->GetUserData(kAutocheckoutRequestManagerKey));
+}
+
+void AutocheckoutRequestManager::SendAutocheckoutStatus(
+ AutocheckoutStatus status,
+ const GURL& source_url,
+ const std::string& google_transaction_id) {
+ wallet_client_.SendAutocheckoutStatus(status,
+ source_url,
+ google_transaction_id);
+}
+
+
+const AutofillMetrics& AutocheckoutRequestManager::GetMetricLogger() const {
+ return metric_logger_;
+}
+
+DialogType AutocheckoutRequestManager::GetDialogType() const {
+ return DIALOG_TYPE_AUTOCHECKOUT;
+}
+
+std::string AutocheckoutRequestManager::GetRiskData() const {
+ NOTREACHED();
+ return std::string();
+}
+
+void AutocheckoutRequestManager::OnDidAcceptLegalDocuments() {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidAuthenticateInstrument(bool success) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidGetFullWallet(
+ scoped_ptr<wallet::FullWallet> full_wallet) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidGetWalletItems(
+ scoped_ptr<wallet::WalletItems> wallet_items) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidSaveAddress(
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidSaveInstrument(
+ const std::string& instrument_id,
+ const std::vector<wallet::RequiredAction>& required_actions) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidSaveInstrumentAndAddress(
+ const std::string& instrument_id,
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidUpdateAddress(
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnDidUpdateInstrument(
+ const std::string& instrument_id,
+ const std::vector<wallet::RequiredAction>& required_actions) {
+ NOTREACHED();
+}
+
+void AutocheckoutRequestManager::OnWalletError(
+ wallet::WalletClient::ErrorType error_type) {
+ // Nothing to be done. |error_type| is logged by |metric_logger_|.
+}
+
+void AutocheckoutRequestManager::OnMalformedResponse() {
+ // Nothing to be done.
+}
+
+void AutocheckoutRequestManager::OnNetworkError(int response_code) {
+ // Nothin to be done. |response_code| is logged by |metric_logger_|.
+}
+
+AutocheckoutRequestManager::AutocheckoutRequestManager(
+ net::URLRequestContextGetter* request_context_getter)
+ : wallet_client_(request_context_getter, this) {
+}
+
+} // namespace autofill
diff --git a/components/autofill/browser/autocheckout_request_manager.h b/components/autofill/browser/autocheckout_request_manager.h
new file mode 100644
index 0000000..2f38789
--- /dev/null
+++ b/components/autofill/browser/autocheckout_request_manager.h
@@ -0,0 +1,98 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
+#define COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
+
+#include "base/supports_user_data.h"
+#include "components/autofill/browser/autofill_metrics.h"
+#include "components/autofill/browser/wallet/wallet_client.h"
+#include "components/autofill/browser/wallet/wallet_client_delegate.h"
+#include "components/autofill/common/autocheckout_status.h"
+#include "googleurl/src/gurl.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace autofill {
+
+// AutocheckoutRequestManager's only responsiblity is to make sure any
+// SendAutocheckoutStatus calls succeed regardless of any actions the user may
+// make in the browser i.e. closing a tab, the requestAutocomplete dialog, etc.
+// To that end, it is a piece of user data tied to the BrowserContext.
+class AutocheckoutRequestManager : public base::SupportsUserData::Data,
+ public wallet::WalletClientDelegate {
+ public:
+ virtual ~AutocheckoutRequestManager();
+
+ // Creates a new AutocheckoutRequestManager and stores it as user data in
+ // |browser_context| if one does not already exist.
+ static void CreateForBrowserContext(
+ content::BrowserContext* browser_context);
+
+ // Retrieves the AutocheckoutRequestManager for |browser_context| if one
+ // exists.
+ static AutocheckoutRequestManager* FromBrowserContext(
+ content::BrowserContext* browser_context);
+
+ // Sends the |status| of an Autocheckout flow to Online Wallet using
+ // |wallet_client_|.
+ void SendAutocheckoutStatus(AutocheckoutStatus status,
+ const GURL& source_url,
+ const std::string& google_transaction_id);
+
+ // wallet::WalletClientDelegate:
+ virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE;
+ virtual DialogType GetDialogType() const OVERRIDE;
+ virtual std::string GetRiskData() const OVERRIDE;
+ virtual void OnDidAcceptLegalDocuments() OVERRIDE;
+ virtual void OnDidAuthenticateInstrument(bool success) OVERRIDE;
+ virtual void OnDidGetFullWallet(
+ scoped_ptr<wallet::FullWallet> full_wallet) OVERRIDE;
+ virtual void OnDidGetWalletItems(
+ scoped_ptr<wallet::WalletItems> wallet_items) OVERRIDE;
+ virtual void OnDidSaveAddress(
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) OVERRIDE;
+ virtual void OnDidSaveInstrument(
+ const std::string& instrument_id,
+ const std::vector<wallet::RequiredAction>& required_actions) OVERRIDE;
+ virtual void OnDidSaveInstrumentAndAddress(
+ const std::string& instrument_id,
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) OVERRIDE;
+ virtual void OnDidUpdateAddress(
+ const std::string& address_id,
+ const std::vector<wallet::RequiredAction>& required_actions) OVERRIDE;
+ virtual void OnDidUpdateInstrument(
+ const std::string& instrument_id,
+ const std::vector<wallet::RequiredAction>& required_actions) OVERRIDE;
+ virtual void OnWalletError(
+ wallet::WalletClient::ErrorType error_type) OVERRIDE;
+ virtual void OnMalformedResponse() OVERRIDE;
+ virtual void OnNetworkError(int response_code) OVERRIDE;
+
+ private:
+ // |request_context_getter| is passed in to construct |wallet_client_|.
+ AutocheckoutRequestManager(
+ net::URLRequestContextGetter* request_context_getter);
+
+ // Logs various UMA metrics.
+ AutofillMetrics metric_logger_;
+
+ // Makes requests to Online Wallet. The only request this class is configured
+ // to make is SendAutocheckoutStatus.
+ wallet::WalletClient wallet_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutocheckoutRequestManager);
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc
index d2632fc..d9e0669 100644
--- a/components/autofill/browser/autofill_manager.cc
+++ b/components/autofill/browser/autofill_manager.cc
@@ -772,7 +772,8 @@ void AutofillManager::ShowRequestAutocompleteDialog(
const FormData& form,
const GURL& source_url,
autofill::DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback) {
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback) {
manager_delegate_->ShowRequestAutocompleteDialog(
form, source_url, *metric_logger_, dialog_type, callback);
}
@@ -827,7 +828,7 @@ void AutofillManager::OnRequestAutocomplete(
return;
}
- base::Callback<void(const FormStructure*)> callback =
+ base::Callback<void(const FormStructure*, const std::string&)> callback =
base::Bind(&AutofillManager::ReturnAutocompleteData,
weak_ptr_factory_.GetWeakPtr());
ShowRequestAutocompleteDialog(
@@ -850,7 +851,9 @@ void AutofillManager::ReturnAutocompleteResult(
form_data));
}
-void AutofillManager::ReturnAutocompleteData(const FormStructure* result) {
+void AutofillManager::ReturnAutocompleteData(
+ const FormStructure* result,
+ const std::string& unused_transaction_id) {
RequestAutocompleteDialogClosed();
if (!result) {
ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorCancel,
@@ -884,7 +887,7 @@ void AutofillManager::OnDidEndTextFieldEditing() {
}
void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) {
- // TODO(ahutter): Plug into WalletClient.
+ autocheckout_manager_.OnClickFailed(status);
}
void AutofillManager::OnMaybeShowAutocheckoutBubble(
diff --git a/components/autofill/browser/autofill_manager.h b/components/autofill/browser/autofill_manager.h
index ad71068..fae3984 100644
--- a/components/autofill/browser/autofill_manager.h
+++ b/components/autofill/browser/autofill_manager.h
@@ -122,7 +122,8 @@ class AutofillManager : public content::WebContentsObserver,
const FormData& form,
const GURL& source_url,
autofill::DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback);
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback);
// Happens when the autocomplete dialog runs its callback when being closed.
void RequestAutocompleteDialogClosed();
@@ -267,7 +268,8 @@ class AutofillManager : public content::WebContentsObserver,
const GURL& frame_url);
// Passes return data for an OnRequestAutocomplete call back to the page.
- void ReturnAutocompleteData(const FormStructure* result);
+ void ReturnAutocompleteData(const FormStructure* result,
+ const std::string& unused_transaction_id);
// Called to signal clicking an element failed in some way during an
// Autocheckout flow.
diff --git a/components/autofill/browser/autofill_manager_delegate.h b/components/autofill/browser/autofill_manager_delegate.h
index a9f11684..cecf6839 100644
--- a/components/autofill/browser/autofill_manager_delegate.h
+++ b/components/autofill/browser/autofill_manager_delegate.h
@@ -125,7 +125,8 @@ class AutofillManagerDelegate {
const GURL& source_url,
const AutofillMetrics& metric_logger,
DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback) = 0;
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback) = 0;
// Hide the Autocheckout bubble if one is currently showing.
virtual void HideAutocheckoutBubble() = 0;
diff --git a/components/autofill/browser/test_autofill_manager_delegate.cc b/components/autofill/browser/test_autofill_manager_delegate.cc
index 4f3be76..44cb44b 100644
--- a/components/autofill/browser/test_autofill_manager_delegate.cc
+++ b/components/autofill/browser/test_autofill_manager_delegate.cc
@@ -61,7 +61,8 @@ void TestAutofillManagerDelegate::ShowRequestAutocompleteDialog(
const GURL& source_url,
const AutofillMetrics& metric_logger,
DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback) {}
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback) {}
void TestAutofillManagerDelegate::RequestAutocompleteDialogClosed() {}
diff --git a/components/autofill/browser/test_autofill_manager_delegate.h b/components/autofill/browser/test_autofill_manager_delegate.h
index ce28402..f044e95 100644
--- a/components/autofill/browser/test_autofill_manager_delegate.h
+++ b/components/autofill/browser/test_autofill_manager_delegate.h
@@ -47,7 +47,8 @@ class TestAutofillManagerDelegate : public AutofillManagerDelegate {
const GURL& source_url,
const AutofillMetrics& metric_logger,
DialogType dialog_type,
- const base::Callback<void(const FormStructure*)>& callback) OVERRIDE;
+ const base::Callback<void(const FormStructure*,
+ const std::string&)>& callback) OVERRIDE;
virtual void RequestAutocompleteDialogClosed() OVERRIDE;
virtual void ShowAutofillPopup(const gfx::RectF& element_bounds,
const std::vector<string16>& values,
diff --git a/components/autofill/browser/wallet/wallet_client.cc b/components/autofill/browser/wallet/wallet_client.cc
index fa36f61..3c24399 100644
--- a/components/autofill/browser/wallet/wallet_client.cc
+++ b/components/autofill/browser/wallet/wallet_client.cc
@@ -733,7 +733,6 @@ void WalletClient::OnURLFetchComplete(
}
case SEND_STATUS:
- delegate_->OnDidSendAutocheckoutStatus();
break;
case GET_FULL_WALLET: {
diff --git a/components/autofill/browser/wallet/wallet_client_delegate.h b/components/autofill/browser/wallet/wallet_client_delegate.h
index 0148f07..2125e07 100644
--- a/components/autofill/browser/wallet/wallet_client_delegate.h
+++ b/components/autofill/browser/wallet/wallet_client_delegate.h
@@ -79,9 +79,6 @@ class WalletClientDelegate {
const std::string& address_id,
const std::vector<RequiredAction>& required_actions) = 0;
- // Called when a SendAutocheckoutStatus request finishes successfully.
- virtual void OnDidSendAutocheckoutStatus() = 0;
-
// Called when an UpdateAddress request finishes successfully.
// |required_actions| is populated if there was a validation error with the
// data being saved.
diff --git a/components/autofill/browser/wallet/wallet_client_unittest.cc b/components/autofill/browser/wallet/wallet_client_unittest.cc
index 6c08d5f..940156c 100644
--- a/components/autofill/browser/wallet/wallet_client_unittest.cc
+++ b/components/autofill/browser/wallet/wallet_client_unittest.cc
@@ -632,7 +632,6 @@ class MockWalletClientDelegate : public WalletClientDelegate {
void(const std::string& instrument_id,
const std::string& shipping_address_id,
const std::vector<RequiredAction>& required_actions));
- MOCK_METHOD0(OnDidSendAutocheckoutStatus, void());
MOCK_METHOD2(OnDidUpdateAddress,
void(const std::string& address_id,
const std::vector<RequiredAction>& required_actions));
@@ -1657,33 +1656,25 @@ TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) {
}
TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) {
- EXPECT_CALL(delegate_, OnDidSendAutocheckoutStatus()).Times(1);
delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
"google_transaction_id");
- net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
- ASSERT_TRUE(fetcher);
- EXPECT_EQ(kSendAutocheckoutStatusOfSuccessValidRequest, GetData(fetcher));
- fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored.
- fetcher->set_response_code(net::HTTP_OK);
- fetcher->delegate()->OnURLFetchComplete(fetcher);
+ VerifyAndFinishRequest(net::HTTP_OK,
+ kSendAutocheckoutStatusOfSuccessValidRequest,
+ ")]}"); // Invalid JSON. Should be ignored.
}
TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) {
- EXPECT_CALL(delegate_, OnDidSendAutocheckoutStatus()).Times(1);
delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
wallet_client_->SendAutocheckoutStatus(autofill::CANNOT_PROCEED,
GURL(kMerchantUrl),
"google_transaction_id");
- net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
- ASSERT_TRUE(fetcher);
- EXPECT_EQ(kSendAutocheckoutStatusOfFailureValidRequest, GetData(fetcher));
- fetcher->set_response_code(net::HTTP_OK);
- fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored.
- fetcher->delegate()->OnURLFetchComplete(fetcher);
+ VerifyAndFinishRequest(net::HTTP_OK,
+ kSendAutocheckoutStatusOfFailureValidRequest,
+ ")]}"); // Invalid JSON. Should be ignored.
}
TEST_F(WalletClientTest, HasRequestInProgress) {
diff --git a/components/autofill/renderer/autofill_agent.cc b/components/autofill/renderer/autofill_agent.cc
index 2c71783..c85c265 100644
--- a/components/autofill/renderer/autofill_agent.cc
+++ b/components/autofill/renderer/autofill_agent.cc
@@ -223,13 +223,7 @@ void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) {
if (!frame->parent()) {
topmost_frame_ = NULL;
- WebKit::WebURL provisional_url =
- frame->provisionalDataSource()->request().url();
- WebKit::WebURL current_url = frame->dataSource()->request().url();
- // If the URL of the topmost frame is changing and the current page is part
- // of an Autocheckout flow, the click was successful as long as the
- // provisional load is committed.
- if (provisional_url != current_url && click_timer_.IsRunning()) {
+ if (click_timer_.IsRunning()) {
click_timer_.Stop();
autocheckout_click_in_progress_ = true;
}
@@ -238,7 +232,7 @@ void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) {
void AutofillAgent::DidFailProvisionalLoad(WebFrame* frame,
const WebKit::WebURLError& error) {
- if (autocheckout_click_in_progress_) {
+ if (!frame->parent() && autocheckout_click_in_progress_) {
autocheckout_click_in_progress_ = false;
ClickFailed();
}
@@ -246,8 +240,9 @@ void AutofillAgent::DidFailProvisionalLoad(WebFrame* frame,
void AutofillAgent::DidCommitProvisionalLoad(WebFrame* frame,
bool is_new_navigation) {
- autocheckout_click_in_progress_ = false;
in_flight_request_form_.reset();
+ if (!frame->parent())
+ autocheckout_click_in_progress_ = false;
}
void AutofillAgent::FrameDetached(WebFrame* frame) {
@@ -755,6 +750,10 @@ void AutofillAgent::OnFillFormsAndClick(
for (size_t i = 0; i < forms.size(); ++i)
FillFormIncludingNonFocusableElements(forms[i], form_elements_[i]);
+ // Exit early if there is nothing to click.
+ if (click_element_descriptor.retrieval_method == WebElementDescriptor::NONE)
+ return;
+
// It's possible that clicking the element to proceed in an Autocheckout
// flow will not actually proceed to the next step in the flow, e.g. there
// is a new required field that Autocheckout does not know how to fill. In