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 13class GURL; 14 15namespace autofill { 16 17struct FormData; 18struct FormFieldData; 19struct 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. 26extern const size_t kMaxDataLength; 27 28// The maximum list size supported by Autofill. 29extern 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. 34bool IsValidString(const std::string& str); 35bool IsValidString16(const base::string16& str); 36bool IsValidGURL(const GURL& url); 37bool IsValidFormFieldData(const FormFieldData& field); 38bool IsValidFormData(const FormData& form); 39bool IsValidPasswordFormFillData(const PasswordFormFillData& form); 40bool IsValidString16Vector(const std::vector<base::string16>& v); 41bool IsValidFormDataVector(const std::vector<FormData>& v); 42 43} // namespace autofill 44 45#endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_DATA_VALIDATION_H_ 46