| 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_cache.h" | 5 #include "components/autofill/content/renderer/form_cache.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 8 #include <string> |
| 9 #include <utility> |
| 10 |
| 7 #include "base/logging.h" | 11 #include "base/logging.h" |
| 8 #include "base/macros.h" | 12 #include "base/macros.h" |
| 9 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 11 #include "components/autofill/content/renderer/form_autofill_util.h" | 15 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 12 #include "components/autofill/core/common/autofill_constants.h" | 16 #include "components/autofill/core/common/autofill_constants.h" |
| 13 #include "components/autofill/core/common/form_data_predictions.h" | 17 #include "components/autofill/core/common/form_data_predictions.h" |
| 14 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/platform/WebVector.h" | 20 #include "third_party/WebKit/public/platform/WebVector.h" |
| 17 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 18 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 19 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 23 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 20 #include "third_party/WebKit/public/web/WebFormElement.h" | 24 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 21 #include "third_party/WebKit/public/web/WebInputElement.h" | 25 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 26 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 23 #include "third_party/WebKit/public/web/WebSelectElement.h" | 27 #include "third_party/WebKit/public/web/WebSelectElement.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 25 | 29 |
| 26 using blink::WebConsoleMessage; | 30 using blink::WebConsoleMessage; |
| 27 using blink::WebDocument; | 31 using blink::WebDocument; |
| 28 using blink::WebElement; | 32 using blink::WebElement; |
| 29 using blink::WebFormControlElement; | 33 using blink::WebFormControlElement; |
| 30 using blink::WebFormElement; | 34 using blink::WebFormElement; |
| 31 using blink::WebFrame; | 35 using blink::WebLocalFrame; |
| 32 using blink::WebInputElement; | 36 using blink::WebInputElement; |
| 33 using blink::WebNode; | 37 using blink::WebNode; |
| 34 using blink::WebSelectElement; | 38 using blink::WebSelectElement; |
| 35 using blink::WebString; | 39 using blink::WebString; |
| 36 using blink::WebVector; | 40 using blink::WebVector; |
| 37 | 41 |
| 38 namespace autofill { | 42 namespace autofill { |
| 39 | 43 |
| 40 namespace { | 44 namespace { |
| 41 | 45 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // the required number of editable fields for the prediction routines to be a | 79 // the required number of editable fields for the prediction routines to be a |
| 76 // candidate for autofill. | 80 // candidate for autofill. |
| 77 return num_editable_elements >= kRequiredFieldsForPredictionRoutines || | 81 return num_editable_elements >= kRequiredFieldsForPredictionRoutines || |
| 78 (all_fields_are_passwords && | 82 (all_fields_are_passwords && |
| 79 num_editable_elements >= | 83 num_editable_elements >= |
| 80 kRequiredFieldsForFormsWithOnlyPasswordFields); | 84 kRequiredFieldsForFormsWithOnlyPasswordFields); |
| 81 } | 85 } |
| 82 | 86 |
| 83 } // namespace | 87 } // namespace |
| 84 | 88 |
| 85 FormCache::FormCache(const WebFrame& frame) : frame_(frame) { | 89 FormCache::FormCache(const WebLocalFrame& frame) : frame_(frame) {} |
| 86 } | |
| 87 | 90 |
| 88 FormCache::~FormCache() { | 91 FormCache::~FormCache() { |
| 89 } | 92 } |
| 90 | 93 |
| 91 std::vector<FormData> FormCache::ExtractNewForms() { | 94 std::vector<FormData> FormCache::ExtractNewForms() { |
| 92 std::vector<FormData> forms; | 95 std::vector<FormData> forms; |
| 93 WebDocument document = frame_.GetDocument(); | 96 WebDocument document = frame_.GetDocument(); |
| 94 if (document.IsNull()) | 97 if (document.IsNull()) |
| 95 return forms; | 98 return forms; |
| 96 | 99 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 const WebInputElement* input_element = ToWebInputElement(&element); | 373 const WebInputElement* input_element = ToWebInputElement(&element); |
| 371 if (form_util::IsCheckableElement(input_element)) { | 374 if (form_util::IsCheckableElement(input_element)) { |
| 372 initial_checked_state_.insert( | 375 initial_checked_state_.insert( |
| 373 std::make_pair(*input_element, input_element->IsChecked())); | 376 std::make_pair(*input_element, input_element->IsChecked())); |
| 374 } | 377 } |
| 375 } | 378 } |
| 376 } | 379 } |
| 377 } | 380 } |
| 378 | 381 |
| 379 } // namespace autofill | 382 } // namespace autofill |
| OLD | NEW |