1 // Copyright 2014 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_CORE_COMMON_AUTOFILL_DATA_VALIDATION_H_ 6 #define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_DATA_VALIDATION_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/strings/string16.h" 12 13 class GURL; 14 15 namespace autofill { 16 17 struct FormData; 18 struct FormFieldData; 19 struct PasswordFormFillData; 20 21 // Constants to enforce data size caps, so as to avoid sending overly large 22 // messages over IPC or trying to act on potentialy corrupted data within the 23 // browser process: 24 25 // The maximum string size supported by Autofill. 26 extern const size_t kMaxDataLength; 27 28 // The maximum list size supported by Autofill. 29 extern const size_t kMaxListSize; 30 31 // Functions to verify whether the objects passed to them satisfy basic sanity 32 // checks, including being capped to the maximums defined by the constants 33 // above. 34 bool IsValidString(const std::string& str); 35 bool IsValidString16(const base::string16& str); 36 bool IsValidGURL(const GURL& url); 37 bool IsValidFormFieldData(const FormFieldData& field); 38 bool IsValidFormData(const FormData& form); 39 bool IsValidPasswordFormFillData(const PasswordFormFillData& form); 40 bool IsValidString16Vector(const std::vector<base::string16>& v); 41 bool IsValidFormDataVector(const std::vector<FormData>& v); 42 43 } // namespace autofill 44 45 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_DATA_VALIDATION_H_ 46