File: autofill_constants.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (138 lines) | stat: -rw-r--r-- 6,443 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Contains constants specific to the Autofill component.

#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CONSTANTS_H_
#define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CONSTANTS_H_

#include <stddef.h>  // For size_t

#include "base/time/time.h"

namespace autofill {

// The origin of a CreditCard created or modified in the settings page.
extern const char kSettingsOrigin[];

// The maximum number of `FieldLogEvent` objects that we store per field. We
// assume that fields that would have more than this number of events are not
// interesting for Autofill's purpose.
inline constexpr size_t kMaxLogEventsPerField = 1000;

// The maximum number of Addresses and CreditCards considered while trying to
// determine the possible field types of AutofillField's by looking at the
// submitted value.
inline constexpr size_t kMaxDataConsideredForPossibleTypes = 10;

// The maximum number of Autofill fill operations that Autofill is allowed to
// store in history so that they can be undone later.
inline constexpr size_t kMaxStorableFieldFillHistory = 400;

// The number of fields required by Autofill to execute its heuristic and
// crowd-sourcing query/upload routines.
inline constexpr size_t kMinRequiredFieldsForHeuristics = 3;
inline constexpr size_t kMinRequiredFieldsForQuery = 1;
inline constexpr size_t kMinRequiredFieldsForUpload = 1;

// Set a conservative upper bound on the number of forms we are willing to
// cache, simply to prevent unbounded memory consumption.
inline constexpr size_t kAutofillManagerMaxFormCacheSize = 100;

// The maximum number of form fields we are willing to extract, due to
// computational costs. Several examples of forms with lots of fields that are
// not relevant to Autofill: (1) the Netflix queue; (2) the Amazon wishlist;
// (3) router configuration pages; and (4) other configuration pages, e.g. for
// Google code project settings.
// Copied to components/autofill/ios/form_util/resources/fill.ts.
inline constexpr size_t kMaxExtractableFields = 200;

// The maximum number of form fields we are willing to extract, due to
// computational costs.
inline constexpr size_t kMaxExtractableChildFrames = 20;

// The maximum string length supported by Autofill. In particular, this is used
// for the length of field values.
// Truncating strings is to prevent a malicious site from DOS'ing the browser
// (crbug.com/49332).
// This limit prevents sending overly large strings via IPC to the browser
// process.
// This is `unsigned` because blink::WebFormControlElement uses `unsigned` for
// selection indices, not `size_t`.
inline constexpr unsigned kMaxStringLength = 1024;

// The maximum string length of selected text in contenteditables, textareas,
// and text-mode inputs.
// TODO(crbug.com/40941660): Reduce the value.
inline constexpr size_t kMaxSelectedTextLength = 50 * kMaxStringLength;

// The maximum list size supported by Autofill.
// Allow enough space for all countries (roughly 300 distinct values) and all
// timezones (roughly 400 distinct values), plus some extra wiggle room.
// This limit prevents sending overly large strings via IPC to the browser
// process.
inline constexpr size_t kMaxListSize = 512;

// The maximum number of allowed calls to CreditCard::GetMatchingTypes() and
// AutofillProfile::GetMatchingTypeAndValidities().
// If #fields * (#profiles + #credit-cards) exceeds this number, type matching
// and voting is omitted.
// The rationale is that for a form with |kMaxExtractableFields| = 200 fields,
// this still allows for 25 profiles plus credit cards.
inline constexpr size_t kMaxTypeMatchingCalls = 5000;

// The minimum number of fields in a form that contains only password fields to
// upload the form to and request predictions from the Autofill servers.
inline constexpr size_t kRequiredFieldsForFormsWithOnlyPasswordFields = 2;

// A refill happens only within `kLimitBeforeRefill` of the original fill.
inline constexpr base::TimeDelta kLimitBeforeRefill = base::Seconds(1);

// Constants for the soft/hard deletion of Autofill data.
inline constexpr base::TimeDelta kDisusedDataModelTimeDelta = base::Days(180);
inline constexpr base::TimeDelta kDisusedDataModelDeletionTimeDelta =
    base::Days(395);

// Defines for how long recently submitted profile fragments are retained in
// memory for multi-step imports.
inline constexpr base::TimeDelta kMultiStepImportTTL = base::Minutes(5);

// Returns if the entry with the given |use_date| is deletable? (i.e. has not
// been used for a long time).
bool IsAutofillEntryWithUseDateDeletable(base::Time use_date);

// The period after which autocomplete entries should be cleaned-up in days.
// Equivalent to roughly 14 months.
inline constexpr base::TimeDelta kAutocompleteRetentionPolicyPeriod =
    base::Days(14 * 31);

// Limits the number of times the value of a specific type can be filled into a
// form.
// Credit card numbers are sometimes distributed between up to 19 individual
// fields. Therefore, credit cards need a higher limit.
// State fields are effectively unlimited because there are sometimes hidden
// fields select boxes, each with a list of states for one specific countries,
// which are displayed only upon country selection.
inline constexpr size_t kTypeValueFormFillingLimit = 9;
inline constexpr size_t kCreditCardTypeValueFormFillingLimit = 19;
inline constexpr size_t kStateTypeValueFormFillingLimit = 1000;

// Limits the number of profiles from the list of matching profiles for
// suggestions that Autofill will keep after deduplication. Remaining profiles
// will be dropped.
inline constexpr size_t kMaxDeduplicatedProfilesForSuggestion = 10;

// Limits the number of profiles used to generate suggestions when triggering
// Autofill via manual fallback. When using manual fallback, filters such as
// prefix matching and the last time a profile was used used are not applied.
inline constexpr size_t kMaxDisplayedAddressSuggestions = 10;

// Limits the number of profiles from the list of stored profiles that Autofill
// will keep after prefix matching with a field's contents to show as
// suggestions. Remaining profiles will be dropped.
inline constexpr size_t kMaxPrefixMatchedProfilesForSuggestion = 50;

}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CONSTANTS_H_