| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/content/renderer/form_autofill_util.h" | 5 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 bool HasTagName(const WebNode& node, const WebKit::WebString& tag) { | 81 bool HasTagName(const WebNode& node, const WebKit::WebString& tag) { |
| 82 return node.isElementNode() && node.toConst<WebElement>().hasTagName(tag); | 82 return node.isElementNode() && node.toConst<WebElement>().hasTagName(tag); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool IsAutofillableElement(const WebFormControlElement& element) { | 85 bool IsAutofillableElement(const WebFormControlElement& element) { |
| 86 const WebInputElement* input_element = toWebInputElement(&element); | 86 const WebInputElement* input_element = toWebInputElement(&element); |
| 87 return IsAutofillableInputElement(input_element) || IsSelectElement(element); | 87 return IsAutofillableInputElement(input_element) || IsSelectElement(element); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool IsAutocheckoutEnabled() { | |
| 91 return base::FieldTrialList::FindFullName("Autocheckout") == "Yes" || | |
| 92 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 93 switches::kEnableExperimentalFormFilling); | |
| 94 } | |
| 95 | |
| 96 // Check whether the given field satisfies the REQUIRE_AUTOCOMPLETE requirement. | 90 // Check whether the given field satisfies the REQUIRE_AUTOCOMPLETE requirement. |
| 97 // When Autocheckout is enabled, this requirement is enforced in the browser | |
| 98 // process rather than in the renderer process, and hence all fields are | |
| 99 // considered to satisfy this requirement. | |
| 100 bool SatisfiesRequireAutocomplete(const WebInputElement& input_element) { | 91 bool SatisfiesRequireAutocomplete(const WebInputElement& input_element) { |
| 101 return input_element.autoComplete() || IsAutocheckoutEnabled(); | 92 return input_element.autoComplete(); |
| 102 } | 93 } |
| 103 | 94 |
| 104 // Appends |suffix| to |prefix| so that any intermediary whitespace is collapsed | 95 // Appends |suffix| to |prefix| so that any intermediary whitespace is collapsed |
| 105 // to a single space. If |force_whitespace| is true, then the resulting string | 96 // to a single space. If |force_whitespace| is true, then the resulting string |
| 106 // is guaranteed to have a space between |prefix| and |suffix|. Otherwise, the | 97 // is guaranteed to have a space between |prefix| and |suffix|. Otherwise, the |
| 107 // result includes a space only if |prefix| has trailing whitespace or |suffix| | 98 // result includes a space only if |prefix| has trailing whitespace or |suffix| |
| 108 // has leading whitespace. | 99 // has leading whitespace. |
| 109 // A few examples: | 100 // A few examples: |
| 110 // * CombineAndCollapseWhitespace("foo", "bar", false) -> "foobar" | 101 // * CombineAndCollapseWhitespace("foo", "bar", false) -> "foobar" |
| 111 // * CombineAndCollapseWhitespace("foo", "bar", true) -> "foo bar" | 102 // * CombineAndCollapseWhitespace("foo", "bar", true) -> "foo bar" |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 continue; | 1041 continue; |
| 1051 | 1042 |
| 1052 if (input_element->isAutofilled()) | 1043 if (input_element->isAutofilled()) |
| 1053 return true; | 1044 return true; |
| 1054 } | 1045 } |
| 1055 | 1046 |
| 1056 return false; | 1047 return false; |
| 1057 } | 1048 } |
| 1058 | 1049 |
| 1059 } // namespace autofill | 1050 } // namespace autofill |
| OLD | NEW |