form_group.h revision 731df977c0511bca2206b5f333555b1205ff1f43
1// Copyright (c) 2010 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 CHROME_BROWSER_AUTOFILL_FORM_GROUP_H_ 6#define CHROME_BROWSER_AUTOFILL_FORM_GROUP_H_ 7#pragma once 8 9#include <vector> 10 11#include "base/string16.h" 12#include "base/string_util.h" 13#include "chrome/browser/autofill/autofill_type.h" 14#include "chrome/browser/autofill/field_types.h" 15 16// This class is an interface for collections of form fields, grouped by type. 17// The information in objects of this class is managed by the 18// PersonalDataManager. 19class FormGroup { 20 public: 21 virtual ~FormGroup() {} 22 23 // Returns a clone of this object. 24 virtual FormGroup* Clone() const = 0; 25 26 // Used to determine the type of a field based on the text that a user enters 27 // into the field. The field types can then be reported back to the server. 28 // This method is additive on |possible_types|. 29 virtual void GetPossibleFieldTypes(const string16& text, 30 FieldTypeSet* possible_types) const = 0; 31 32 // Returns a set of AutoFillFieldTypes for which this FormGroup has non-empty 33 // data. 34 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const = 0; 35 36 // Returns the string that should be auto-filled into a text field given the 37 // type of that field. 38 virtual string16 GetFieldText(const AutoFillType& type) const = 0; 39 40 // Returns the text for preview. 41 virtual string16 GetPreviewText(const AutoFillType& type) const; 42 43 // Used to determine if the text being typed into a field matches the 44 // information in this FormGroup object. This is used by the preview 45 // functionality. |matched_text| will be populated with all of the possible 46 // matches given the type. This method is additive on |matched_text|. 47 virtual void FindInfoMatches(const AutoFillType& type, 48 const string16& info, 49 std::vector<string16>* matched_text) const = 0; 50 51 // Used to populate this FormGroup object with data. 52 virtual void SetInfo(const AutoFillType& type, const string16& value) = 0; 53 54 // Returns the label for this FormGroup item. This should be overridden for 55 // form group items that implement a label. 56 virtual const string16& Label() const; 57 58 // Returns true if the field data in |form_group| does not match the field 59 // data in this FormGroup. 60 virtual bool operator!=(const FormGroup& form_group) const; 61 62 // Returns true if the data in this FormGroup is a subset of the data in 63 // |form_group|. 64 bool IsSubsetOf(const FormGroup& form_group) const; 65 66 // Returns true if the values of the intersection of the available field types 67 // are equal. If the intersection is empty, the method returns false. 68 bool IntersectionOfTypesHasEqualValues(const FormGroup& form_group) const; 69 70 // Merges the field data in |form_group| with this FormGroup. 71 void MergeWith(const FormGroup& form_group); 72}; 73 74#endif // CHROME_BROWSER_AUTOFILL_FORM_GROUP_H_ 75