Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_PAGE_META_DATA_H_
      6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_PAGE_META_DATA_H_
      7 
      8 #include <map>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "components/autofill/content/browser/autocheckout_steps.h"
     13 #include "components/autofill/core/common/web_element_descriptor.h"
     14 
     15 namespace autofill {
     16 
     17 // Container for multipage Autocheckout data.
     18 struct AutocheckoutPageMetaData {
     19   AutocheckoutPageMetaData();
     20   ~AutocheckoutPageMetaData();
     21 
     22   // Returns true if the Autofill server says that the current page is start of
     23   // a multipage Autofill flow.
     24   bool IsStartOfAutofillableFlow() const;
     25 
     26   // Returns true if the Autofill server says that the current page is in a
     27   // multipage Autofill flow.
     28   bool IsInAutofillableFlow() const;
     29 
     30   // Returns true if the Autofill server says that the current page is the end
     31   // of a multipage Autofill flow.
     32   bool IsEndOfAutofillableFlow() const;
     33 
     34   // Page number of the multipage Autofill flow this form belongs to
     35   // (zero-indexed). If this form doesn't belong to any autofill flow, it is set
     36   // to -1.
     37   int current_page_number;
     38 
     39   // Total number of pages in the multipage Autofill flow. If this form doesn't
     40   // belong to any autofill flow, it is set to -1.
     41   int total_pages;
     42 
     43   // Whether ajaxy form changes that occur on this page during an Autocheckout
     44   // flow should be ignored.
     45   bool ignore_ajax;
     46 
     47   // A list of elements to click before filling form fields. Elements have to be
     48   // clicked in order.
     49   std::vector<WebElementDescriptor> click_elements_before_form_fill;
     50 
     51   // A list of elements to click after filling form fields, and before clicking
     52   // page_advance_button. Elements have to be clicked in order.
     53   std::vector<WebElementDescriptor> click_elements_after_form_fill;
     54 
     55   // The proceed element of the multipage Autofill flow. It can be empty
     56   // if current page is the last page of a flow or isn't a member of a flow.
     57   //
     58   // We do expect page navigation when click on |proceed_element_descriptor|,
     59   // and report an error if it doesn't. Oppositely, we do not expect page
     60   // navigation when click elements in |click_elements_before_form_fill| and
     61   // |click_elements_after_form_fill|. Because of this behavior difference and
     62   // |proceed_element_descriptor| is optional, we separate it from
     63   // |click_elements_after_form_fill|.
     64   WebElementDescriptor proceed_element_descriptor;
     65 
     66   // Mapping of page numbers to the types of Autocheckout actions that will be
     67   // performed on the given page of a multipage Autofill flow.
     68   // If this form doesn't belong to such a flow, the map will be empty.
     69   std::map<int, std::vector<AutocheckoutStepType> > page_types;
     70 
     71  private:
     72   DISALLOW_COPY_AND_ASSIGN(AutocheckoutPageMetaData);
     73 };
     74 
     75 }  // namespace autofill
     76 
     77 #endif  // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_PAGE_META_DATA_H_
     78