summaryrefslogtreecommitdiffstats
path: root/components/autofill/content
diff options
context:
space:
mode:
Diffstat (limited to 'components/autofill/content')
-rw-r--r--components/autofill/content/browser/autocheckout_manager.cc59
-rw-r--r--components/autofill/content/browser/autocheckout_manager.h6
-rw-r--r--components/autofill/content/browser/autocheckout_manager_unittest.cc153
-rw-r--r--components/autofill/content/browser/autocheckout_page_meta_data.h7
-rw-r--r--components/autofill/content/browser/autocheckout_steps.h32
5 files changed, 165 insertions, 92 deletions
diff --git a/components/autofill/content/browser/autocheckout_manager.cc b/components/autofill/content/browser/autocheckout_manager.cc
index bdd7119..438b2a7 100644
--- a/components/autofill/content/browser/autocheckout_manager.cc
+++ b/components/autofill/content/browser/autocheckout_manager.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/browser/autocheckout_request_manager.h"
+#include "components/autofill/content/browser/autocheckout_steps.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_manager.h"
@@ -204,6 +205,9 @@ void AutocheckoutManager::OnClickFailed(AutocheckoutStatus status) {
DCHECK_NE(MISSING_FIELDMAPPING, status);
SendAutocheckoutStatus(status);
+ SetStepProgressForPage(page_meta_data_->current_page_number,
+ AUTOCHECKOUT_STEP_FAILED);
+
autofill_manager_->delegate()->OnAutocheckoutError();
in_autocheckout_flow_ = false;
}
@@ -248,20 +252,29 @@ void AutocheckoutManager::OnLoadedPageMetaData(
status = CANNOT_PROCEED;
}
- // Encountered an error during the Autocheckout flow.
+ // Encountered an error during the Autocheckout flow, probably to
+ // do with a problem on the previous page.
if (!in_autocheckout_flow_) {
+ if (old_meta_data) {
+ SetStepProgressForPage(old_meta_data->current_page_number,
+ AUTOCHECKOUT_STEP_FAILED);
+ }
SendAutocheckoutStatus(status);
autofill_manager_->delegate()->OnAutocheckoutError();
return;
}
- // Add 1.0 since page numbers are 0-indexed.
- autofill_manager_->delegate()->UpdateProgressBar(
- (1.0 + page_meta_data_->current_page_number) /
- page_meta_data_->total_pages);
+ SetStepProgressForPage(old_meta_data->current_page_number,
+ AUTOCHECKOUT_STEP_COMPLETED);
+ SetStepProgressForPage(page_meta_data_->current_page_number,
+ AUTOCHECKOUT_STEP_STARTED);
+
FillForms();
- // If the current page is the last page in the flow, close the dialog.
+ // If the current page is the last page in the flow, set in-progress
+ // steps to 'completed', and send status.
if (page_meta_data_->IsEndOfAutofillableFlow()) {
+ SetStepProgressForPage(page_meta_data_->current_page_number,
+ AUTOCHECKOUT_STEP_COMPLETED);
SendAutocheckoutStatus(status);
autofill_manager_->delegate()->OnAutocheckoutSuccess();
in_autocheckout_flow_ = false;
@@ -352,14 +365,19 @@ void AutocheckoutManager::ReturnAutocheckoutData(
}
}
- // Add 1.0 since page numbers are 0-indexed.
- autofill_manager_->delegate()->UpdateProgressBar(
- (1.0 + page_meta_data_->current_page_number) /
- page_meta_data_->total_pages);
+ // Page types only available in first-page meta data, so save
+ // them for use later as we navigate.
+ page_types_ = page_meta_data_->page_types;
+ SetStepProgressForPage(page_meta_data_->current_page_number,
+ AUTOCHECKOUT_STEP_STARTED);
+
FillForms();
- // If the current page is the last page in the flow, close the dialog.
+ // If the current page is the last page in the flow, set in-progress
+ // steps to 'completed', and send status.
if (page_meta_data_->IsEndOfAutofillableFlow()) {
+ SetStepProgressForPage(page_meta_data_->current_page_number,
+ AUTOCHECKOUT_STEP_COMPLETED);
SendAutocheckoutStatus(SUCCESS);
autofill_manager_->delegate()->OnAutocheckoutSuccess();
in_autocheckout_flow_ = false;
@@ -387,6 +405,14 @@ void AutocheckoutManager::MaybeShowAutocheckoutDialog(
weak_ptr_factory_.GetWeakPtr());
autofill_manager_->ShowRequestAutocompleteDialog(
form, frame_url, DIALOG_TYPE_AUTOCHECKOUT, callback);
+
+ for (std::map<int, std::vector<AutocheckoutStepType> >::const_iterator
+ it = page_meta_data_->page_types.begin();
+ it != page_meta_data_->page_types.end(); ++it) {
+ for (size_t i = 0; i < it->second.size(); ++i) {
+ autofill_manager_->delegate()->AddAutocheckoutStep(it->second[i]);
+ }
+ }
}
void AutocheckoutManager::ShowAutocheckoutBubble(
@@ -488,4 +514,15 @@ void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) {
google_transaction_id_ = kTransactionIdNotSet;
}
+void AutocheckoutManager::SetStepProgressForPage(
+ int page_number,
+ AutocheckoutStepStatus status) {
+ if (page_types_.count(page_number) == 1) {
+ for (size_t i = 0; i < page_types_[page_number].size(); ++i) {
+ autofill_manager_->delegate()->UpdateAutocheckoutStep(
+ page_types_[page_number][i], status);
+ }
+ }
+}
+
} // namespace autofill
diff --git a/components/autofill/content/browser/autocheckout_manager.h b/components/autofill/content/browser/autocheckout_manager.h
index 18a0c26..a5442b9 100644
--- a/components/autofill/content/browser/autocheckout_manager.h
+++ b/components/autofill/content/browser/autocheckout_manager.h
@@ -120,6 +120,9 @@ class AutocheckoutManager {
// field type specified by |field|.
void SetValue(const AutofillField& field, FormFieldData* field_to_fill);
+ // Sets the progress of all steps for the given page to the provided value.
+ void SetStepProgressForPage(int page_number, AutocheckoutStepStatus status);
+
AutofillManager* autofill_manager_; // WEAK; owns us
// Credit card verification code.
@@ -150,6 +153,9 @@ class AutocheckoutManager {
// Whether or not the user is in an Autocheckout flow.
bool in_autocheckout_flow_;
+ // AutocheckoutStepTypes for the various pages of the flow.
+ std::map<int, std::vector<AutocheckoutStepType> > page_types_;
+
std::string google_transaction_id_;
base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_;
diff --git a/components/autofill/content/browser/autocheckout_manager_unittest.cc b/components/autofill/content/browser/autocheckout_manager_unittest.cc
index 9c21872..b4f9b1b 100644
--- a/components/autofill/content/browser/autocheckout_manager_unittest.cc
+++ b/components/autofill/content/browser/autocheckout_manager_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <map>
+
#include "base/strings/utf_string_conversions.h"
#include "base/tuple.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
@@ -145,6 +147,9 @@ scoped_ptr<AutocheckoutPageMetaData> CreateStartOfFlowMetaData() {
new AutocheckoutPageMetaData());
start_of_flow->current_page_number = 0;
start_of_flow->total_pages = 3;
+ start_of_flow->page_types[0].push_back(AUTOCHECKOUT_STEP_SHIPPING);
+ start_of_flow->page_types[1].push_back(AUTOCHECKOUT_STEP_DELIVERY);
+ start_of_flow->page_types[2].push_back(AUTOCHECKOUT_STEP_BILLING);
PopulateClickElement(&start_of_flow->proceed_element_descriptor, "#foo");
return start_of_flow.Pass();
}
@@ -178,6 +183,9 @@ scoped_ptr<AutocheckoutPageMetaData> CreateOnePageFlowMetaData() {
new AutocheckoutPageMetaData());
one_page_flow->current_page_number = 0;
one_page_flow->total_pages = 1;
+ one_page_flow->page_types[0].push_back(AUTOCHECKOUT_STEP_SHIPPING);
+ one_page_flow->page_types[0].push_back(AUTOCHECKOUT_STEP_DELIVERY);
+ one_page_flow->page_types[0].push_back(AUTOCHECKOUT_STEP_BILLING);
PopulateClickElement(&one_page_flow->proceed_element_descriptor, "#foo");
return one_page_flow.Pass();
}
@@ -272,8 +280,6 @@ class MockAutofillManagerDelegate : public TestAutofillManagerDelegate {
callback.Run(true);
}
- virtual void HideAutocheckoutBubble() OVERRIDE {}
-
virtual void ShowRequestAutocompleteDialog(
const FormData& form,
const GURL& source_url,
@@ -284,7 +290,16 @@ class MockAutofillManagerDelegate : public TestAutofillManagerDelegate {
callback.Run(user_supplied_data_.get(), "google_transaction_id");
}
- MOCK_METHOD1(UpdateProgressBar, void(double value));
+ virtual void AddAutocheckoutStep(AutocheckoutStepType step_type) OVERRIDE {
+ if (autocheckout_steps_.count(step_type) == 0)
+ autocheckout_steps_[step_type] = AUTOCHECKOUT_STEP_UNSTARTED;
+ }
+
+ virtual void UpdateAutocheckoutStep(
+ AutocheckoutStepType step_type,
+ AutocheckoutStepStatus step_status) OVERRIDE {
+ autocheckout_steps_[step_type] = step_status;
+ }
void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) {
user_supplied_data_.reset(user_supplied_data.release());
@@ -302,10 +317,19 @@ class MockAutofillManagerDelegate : public TestAutofillManagerDelegate {
return request_autocomplete_dialog_open_;
}
+ bool AutocheckoutStepExistsWithStatus(
+ AutocheckoutStepType step_type,
+ AutocheckoutStepStatus step_status) const {
+ std::map<AutocheckoutStepType, AutocheckoutStepStatus>::const_iterator it =
+ autocheckout_steps_.find(step_type);
+ return it != autocheckout_steps_.end() && it->second == step_status;
+ }
+
private:
bool request_autocomplete_dialog_open_;
bool autocheckout_bubble_shown_;
scoped_ptr<FormStructure> user_supplied_data_;
+ std::map<AutocheckoutStepType, AutocheckoutStepStatus> autocheckout_steps_;
};
class TestAutofillManager : public AutofillManager {
@@ -416,8 +440,6 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
FakeUserSubmittedFormStructure());
GURL frame_url;
content::SSLStatus ssl_status;
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(1.0/3.0))).Times(1);
EXPECT_CALL(autocheckout_manager_->metric_logger(),
LogAutocheckoutBuyFlowMetric(
AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED)).Times(1);
@@ -427,6 +449,15 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness {
CheckFillFormsAndClickIpc();
EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
EXPECT_TRUE(autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_STARTED));
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_UNSTARTED));
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_BILLING,
+ AUTOCHECKOUT_STEP_UNSTARTED));
}
void HideRequestAutocompleteDialog() {
@@ -539,6 +570,9 @@ TEST_F(AutocheckoutManagerTest, OnClickFailedTestMissingAdvance) {
EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow());
EXPECT_TRUE(
autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_FAILED));
}
TEST_F(AutocheckoutManagerTest, OnClickFailedTestMissingClickBeforeFilling) {
@@ -604,67 +638,6 @@ TEST_F(AutocheckoutManagerTest, MaybeShowAutocheckoutBubbleTest) {
EXPECT_FALSE(autofill_manager_delegate_->request_autocomplete_dialog_open());
}
-// Test no proceed element is being passed to the render if a page metadata
-// with no proceed element is loaded.
-TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataMissingProceed) {
- OpenRequestAutocompleteDialog();
-
- // Go the second page with no proceed element.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
- autocheckout_manager_->OnLoadedPageMetaData(CreateMissingProceedMetaData());
-
- EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
-
- EXPECT_EQ(1U, process()->sink().message_count());
- uint32 kMsgID = AutofillMsg_FillFormsAndClick::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- AutofillParam autofill_param;
- AutofillMsg_FillFormsAndClick::Read(message, &autofill_param);
- // Ensure no proceed element is being passed to the render through IPC.
- EXPECT_EQ(WebElementDescriptor::NONE, autofill_param.d.retrieval_method);
- EXPECT_EQ("", autofill_param.d.descriptor);
- ClearIpcSink();
-}
-
-// Test |click_elements_before_form_fill| and |click_elements_after_form_fill|
-// are passed to the render correctly through IPC.
-TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataMultiClick) {
- OpenRequestAutocompleteDialog();
-
- // Go to the second page with multi-click elements.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
- autocheckout_manager_->OnLoadedPageMetaData(CreateMultiClickMetaData());
-
- EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
-
- EXPECT_EQ(1U, process()->sink().message_count());
- uint32 kMsgID = AutofillMsg_FillFormsAndClick::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- AutofillParam autofill_param;
- AutofillMsg_FillFormsAndClick::Read(message, &autofill_param);
- EXPECT_EQ(WebElementDescriptor::ID, autofill_param.d.retrieval_method);
- EXPECT_EQ("#foo", autofill_param.d.descriptor);
-
- // Verify |click_elements_before_form_fill|.
- ASSERT_EQ(2U, autofill_param.b.size());
- EXPECT_EQ(WebElementDescriptor::ID, autofill_param.b[0].retrieval_method);
- EXPECT_EQ("#before_form_fill_1", autofill_param.b[0].descriptor);
- EXPECT_EQ(WebElementDescriptor::ID, autofill_param.b[1].retrieval_method);
- EXPECT_EQ("#before_form_fill_2", autofill_param.b[1].descriptor);
-
- // Verify |click_elements_after_form_fill|.
- ASSERT_EQ(1U, autofill_param.c.size());
- EXPECT_EQ(WebElementDescriptor::ID, autofill_param.c[0].retrieval_method);
- EXPECT_EQ("#after_form_fill", autofill_param.c[0].descriptor);
- ClearIpcSink();
-}
-
TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataMissingMetaData) {
// Gettting no meta data after any autocheckout page is an error.
OpenRequestAutocompleteDialog();
@@ -695,14 +668,15 @@ TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataRepeatedStartPage) {
EXPECT_EQ(0U, process()->sink().message_count());
EXPECT_TRUE(
autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_FAILED));
}
TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataRepeatedPage) {
// Repeating a page is an error.
OpenRequestAutocompleteDialog();
// Go to second page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateInFlowMetaData());
EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
CheckFillFormsAndClickIpc();
@@ -716,14 +690,15 @@ TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataRepeatedPage) {
EXPECT_EQ(0U, process()->sink().message_count());
EXPECT_TRUE(
autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_FAILED));
}
TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataNotInFlow) {
// Repeating a page is an error.
OpenRequestAutocompleteDialog();
// Go to second page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateInFlowMetaData());
EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
CheckFillFormsAndClickIpc();
@@ -738,6 +713,9 @@ TEST_F(AutocheckoutManagerTest, OnLoadedPageMetaDataNotInFlow) {
EXPECT_EQ(0U, process()->sink().message_count());
EXPECT_TRUE(
autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_FAILED));
}
TEST_F(AutocheckoutManagerTest,
@@ -748,8 +726,6 @@ TEST_F(AutocheckoutManagerTest,
AutofillMetrics::BUBBLE_COULD_BE_DISPLAYED)).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateStartOfFlowMetaData());
// Go to second page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::_)).Times(0);
autocheckout_manager_->OnLoadedPageMetaData(CreateInFlowMetaData());
EXPECT_EQ(0U, process()->sink().message_count());
}
@@ -757,30 +733,40 @@ TEST_F(AutocheckoutManagerTest,
TEST_F(AutocheckoutManagerTest, FullAutocheckoutFlow) {
// Test for progression through last page.
OpenRequestAutocompleteDialog();
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_STARTED));
// Go to second page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
EXPECT_CALL(*autofill_manager_delegate_, OnAutocheckoutSuccess()).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateInFlowMetaData());
EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_COMPLETED));
CheckFillFormsAndClickIpc();
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_STARTED));
// Go to third page.
- EXPECT_CALL(*autofill_manager_delegate_, UpdateProgressBar(1)).Times(1);
EXPECT_CALL(autocheckout_manager_->metric_logger(),
LogAutocheckoutBuyFlowMetric(
AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_SUCCESS)).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateEndOfFlowMetaData());
CheckFillFormsAndClickIpc();
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_COMPLETED));
EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow());
EXPECT_TRUE(autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_BILLING,
+ AUTOCHECKOUT_STEP_COMPLETED));
}
TEST_F(AutocheckoutManagerTest, CancelledAutocheckoutFlow) {
// Test for progression through last page.
OpenRequestAutocompleteDialog();
// Go to second page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(2.0/3.0))).Times(1);
autocheckout_manager_->OnLoadedPageMetaData(CreateInFlowMetaData());
EXPECT_TRUE(autocheckout_manager_->in_autocheckout_flow());
CheckFillFormsAndClickIpc();
@@ -790,8 +776,6 @@ TEST_F(AutocheckoutManagerTest, CancelledAutocheckoutFlow) {
EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow());
// Go to third page.
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::_)).Times(0);
EXPECT_CALL(autocheckout_manager_->metric_logger(),
LogAutocheckoutBuyFlowMetric(testing::_)).Times(0);
autocheckout_manager_->OnLoadedPageMetaData(CreateEndOfFlowMetaData());
@@ -813,8 +797,6 @@ TEST_F(AutocheckoutManagerTest, SinglePageFlow) {
FakeUserSubmittedFormStructure());
GURL frame_url;
content::SSLStatus ssl_status;
- EXPECT_CALL(*autofill_manager_delegate_,
- UpdateProgressBar(testing::DoubleEq(1))).Times(1);
EXPECT_CALL(autocheckout_manager_->metric_logger(),
LogAutocheckoutBuyFlowMetric(
AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED)).Times(1);
@@ -827,6 +809,15 @@ TEST_F(AutocheckoutManagerTest, SinglePageFlow) {
CheckFillFormsAndClickIpc();
EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow());
EXPECT_TRUE(autofill_manager_delegate_->request_autocomplete_dialog_open());
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_SHIPPING,
+ AUTOCHECKOUT_STEP_COMPLETED));
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_DELIVERY,
+ AUTOCHECKOUT_STEP_COMPLETED));
+ EXPECT_TRUE(autofill_manager_delegate_
+ ->AutocheckoutStepExistsWithStatus(AUTOCHECKOUT_STEP_BILLING,
+ AUTOCHECKOUT_STEP_COMPLETED));
}
} // namespace autofill
diff --git a/components/autofill/content/browser/autocheckout_page_meta_data.h b/components/autofill/content/browser/autocheckout_page_meta_data.h
index 8cdf3d3..6839d1b 100644
--- a/components/autofill/content/browser/autocheckout_page_meta_data.h
+++ b/components/autofill/content/browser/autocheckout_page_meta_data.h
@@ -5,9 +5,11 @@
#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_PAGE_META_DATA_H_
#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_PAGE_META_DATA_H_
+#include <map>
#include <vector>
#include "base/basictypes.h"
+#include "components/autofill/content/browser/autocheckout_steps.h"
#include "components/autofill/core/common/web_element_descriptor.h"
namespace autofill {
@@ -61,6 +63,11 @@ struct AutocheckoutPageMetaData {
// |click_elements_after_form_fill|.
WebElementDescriptor proceed_element_descriptor;
+ // Mapping of page numbers to the types of Autocheckout actions that will be
+ // performed on the given page of a multipage Autofill flow.
+ // If this form doesn't belong to such a flow, the map will be empty.
+ std::map<int, std::vector<AutocheckoutStepType> > page_types;
+
private:
DISALLOW_COPY_AND_ASSIGN(AutocheckoutPageMetaData);
};
diff --git a/components/autofill/content/browser/autocheckout_steps.h b/components/autofill/content/browser/autocheckout_steps.h
new file mode 100644
index 0000000..d46abcc
--- /dev/null
+++ b/components/autofill/content/browser/autocheckout_steps.h
@@ -0,0 +1,32 @@
+// 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_STEPS_H_
+#define COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_STEPS_H_
+
+namespace autofill {
+
+// Stages of a buy flow that may be encountered on an Autocheckout-supported
+// site, used primarily for display purposes.
+// Indexed for easy conversion from int values returned by Autofill server.
+enum AutocheckoutStepType {
+ AUTOCHECKOUT_STEP_MIN_VALUE = 1,
+ AUTOCHECKOUT_STEP_SHIPPING = AUTOCHECKOUT_STEP_MIN_VALUE,
+ AUTOCHECKOUT_STEP_DELIVERY = 2,
+ AUTOCHECKOUT_STEP_BILLING = 3,
+ AUTOCHECKOUT_STEP_PROXY_CARD = 4,
+ AUTOCHECKOUT_STEP_MAX_VALUE = AUTOCHECKOUT_STEP_PROXY_CARD,
+};
+
+// Possible statuses for the above step types, again used primarily for display.
+enum AutocheckoutStepStatus {
+ AUTOCHECKOUT_STEP_UNSTARTED,
+ AUTOCHECKOUT_STEP_STARTED,
+ AUTOCHECKOUT_STEP_COMPLETED,
+ AUTOCHECKOUT_STEP_FAILED,
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCHECKOUT_STEPS_H_