Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / autofill / data_model_wrapper.h
index 3cb5661..837da34 100644 (file)
@@ -5,16 +5,25 @@
 #ifndef CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
 #define CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
 
+#include <vector>
+
 #include "base/compiler_specific.h"
 #include "base/strings/string16.h"
 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
 #include "components/autofill/content/browser/wallet/wallet_items.h"
 #include "components/autofill/core/browser/field_types.h"
+#include "components/autofill/core/browser/form_structure.h"
 
 namespace gfx {
 class Image;
 }
 
+namespace i18n {
+namespace addressinput {
+struct AddressData;
+}
+}
+
 namespace autofill {
 
 class AutofillDataModel;
@@ -60,39 +69,26 @@ class DataModelWrapper {
   virtual bool GetDisplayText(base::string16* vertically_compact,
                               base::string16* horizontally_compact);
 
+  // Returns the BCP 47 language code that should be used for formatting the
+  // data for display.
+  virtual const std::string& GetLanguageCode() const = 0;
+
   // Fills in |form_structure| with the data that this model contains. |inputs|
   // and |comparator| are used to determine whether each field in the
   // FormStructure should be filled in or left alone. Returns whether any fields
   // in |form_structure| were found to be matching.
   bool FillFormStructure(
-      const DetailInputs& inputs,
-      const InputFieldComparator& compare,
+      const std::vector<ServerFieldType>& types,
+      const FormStructure::InputFieldComparator& compare,
       FormStructure* form_structure) const;
 
  protected:
   DataModelWrapper();
 
  private:
-  // Formats address data into a single string using |separator| between
-  // fields.
-  base::string16 GetAddressDisplayText(const base::string16& separator);
-
   DISALLOW_COPY_AND_ASSIGN(DataModelWrapper);
 };
 
-// A DataModelWrapper that does not hold data and does nothing when told to
-// fill in a form.
-class EmptyDataModelWrapper : public DataModelWrapper {
- public:
-  EmptyDataModelWrapper();
-  virtual ~EmptyDataModelWrapper();
-
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-
- protected:
-  DISALLOW_COPY_AND_ASSIGN(EmptyDataModelWrapper);
-};
-
 // A DataModelWrapper for Autofill profiles.
 class AutofillProfileWrapper : public DataModelWrapper {
  public:
@@ -100,11 +96,11 @@ class AutofillProfileWrapper : public DataModelWrapper {
   AutofillProfileWrapper(const AutofillProfile* profile,
                          const AutofillType& variant_type,
                          size_t variant);
-  virtual ~AutofillProfileWrapper();
+  ~AutofillProfileWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-  virtual base::string16 GetInfoForDisplay(const AutofillType& type) const
-      OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  base::string16 GetInfoForDisplay(const AutofillType& type) const override;
+  const std::string& GetLanguageCode() const override;
 
  protected:
   // Returns the variant that should be used when dealing with an element that
@@ -126,9 +122,9 @@ class AutofillProfileWrapper : public DataModelWrapper {
 class AutofillShippingAddressWrapper : public AutofillProfileWrapper {
  public:
   explicit AutofillShippingAddressWrapper(const AutofillProfile* profile);
-  virtual ~AutofillShippingAddressWrapper();
+  ~AutofillShippingAddressWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(AutofillShippingAddressWrapper);
@@ -138,12 +134,13 @@ class AutofillShippingAddressWrapper : public AutofillProfileWrapper {
 class AutofillCreditCardWrapper : public DataModelWrapper {
  public:
   explicit AutofillCreditCardWrapper(const CreditCard* card);
-  virtual ~AutofillCreditCardWrapper();
+  ~AutofillCreditCardWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-  virtual gfx::Image GetIcon() OVERRIDE;
-  virtual bool GetDisplayText(base::string16* vertically_compact,
-                              base::string16* horizontally_compact) OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  gfx::Image GetIcon() override;
+  bool GetDisplayText(base::string16* vertically_compact,
+                      base::string16* horizontally_compact) override;
+  const std::string& GetLanguageCode() const override;
 
  private:
   const CreditCard* card_;
@@ -155,13 +152,13 @@ class AutofillCreditCardWrapper : public DataModelWrapper {
 class WalletAddressWrapper : public DataModelWrapper {
  public:
   explicit WalletAddressWrapper(const wallet::Address* address);
-  virtual ~WalletAddressWrapper();
+  ~WalletAddressWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-  virtual base::string16 GetInfoForDisplay(const AutofillType& type) const
-      OVERRIDE;
-  virtual bool GetDisplayText(base::string16* vertically_compact,
-                              base::string16* horizontally_compact) OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  base::string16 GetInfoForDisplay(const AutofillType& type) const override;
+  bool GetDisplayText(base::string16* vertically_compact,
+                      base::string16* horizontally_compact) override;
+  const std::string& GetLanguageCode() const override;
 
  private:
   const wallet::Address* address_;
@@ -174,14 +171,14 @@ class WalletInstrumentWrapper : public DataModelWrapper {
  public:
   explicit WalletInstrumentWrapper(
       const wallet::WalletItems::MaskedInstrument* instrument);
-  virtual ~WalletInstrumentWrapper();
+  ~WalletInstrumentWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-  virtual base::string16 GetInfoForDisplay(const AutofillType& type) const
-      OVERRIDE;
-  virtual gfx::Image GetIcon() OVERRIDE;
-  virtual bool GetDisplayText(base::string16* vertically_compact,
-                              base::string16* horizontally_compact) OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  base::string16 GetInfoForDisplay(const AutofillType& type) const override;
+  gfx::Image GetIcon() override;
+  bool GetDisplayText(base::string16* vertically_compact,
+                      base::string16* horizontally_compact) override;
+  const std::string& GetLanguageCode() const override;
 
  private:
   const wallet::WalletItems::MaskedInstrument* instrument_;
@@ -193,11 +190,12 @@ class WalletInstrumentWrapper : public DataModelWrapper {
 class FullWalletBillingWrapper : public DataModelWrapper {
  public:
   explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet);
-  virtual ~FullWalletBillingWrapper();
+  ~FullWalletBillingWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
-  virtual bool GetDisplayText(base::string16* vertically_compact,
-                              base::string16* horizontally_compact) OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  bool GetDisplayText(base::string16* vertically_compact,
+                      base::string16* horizontally_compact) override;
+  const std::string& GetLanguageCode() const override;
 
  private:
   wallet::FullWallet* full_wallet_;
@@ -209,9 +207,10 @@ class FullWalletBillingWrapper : public DataModelWrapper {
 class FullWalletShippingWrapper : public DataModelWrapper {
  public:
   explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet);
-  virtual ~FullWalletShippingWrapper();
+  ~FullWalletShippingWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  const std::string& GetLanguageCode() const override;
 
  private:
   wallet::FullWallet* full_wallet_;
@@ -219,18 +218,20 @@ class FullWalletShippingWrapper : public DataModelWrapper {
   DISALLOW_COPY_AND_ASSIGN(FullWalletShippingWrapper);
 };
 
-// A DataModelWrapper to copy the output of one section to the input of another.
-class DetailOutputWrapper : public DataModelWrapper {
+// A DataModelWrapper for ::i18n::addressinput::AddressData objects.
+class I18nAddressDataWrapper : public DataModelWrapper {
  public:
-  explicit DetailOutputWrapper(const DetailOutputMap& outputs);
-  virtual ~DetailOutputWrapper();
+  explicit I18nAddressDataWrapper(
+      const ::i18n::addressinput::AddressData* address);
+  ~I18nAddressDataWrapper() override;
 
-  virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
+  base::string16 GetInfo(const AutofillType& type) const override;
+  const std::string& GetLanguageCode() const override;
 
  private:
-  const DetailOutputMap& outputs_;
+  const ::i18n::addressinput::AddressData* address_;
 
-  DISALLOW_COPY_AND_ASSIGN(DetailOutputWrapper);
+  DISALLOW_COPY_AND_ASSIGN(I18nAddressDataWrapper);
 };
 
 }  // namespace autofill