Index: components/autofill/content/renderer/form_cache.cc |
diff --git a/components/autofill/content/renderer/form_cache.cc b/components/autofill/content/renderer/form_cache.cc |
index 716e895e03ac9b3fa4fc65622ab01965ccd8ef13..be18bf017c23a36183ea280b6d965ceb56803621 100644 |
--- a/components/autofill/content/renderer/form_cache.cc |
+++ b/components/autofill/content/renderer/form_cache.cc |
@@ -15,6 +15,7 @@ |
#include "grit/components_strings.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/platform/WebVector.h" |
+#include "third_party/WebKit/public/web/WebConsoleMessage.h" |
#include "third_party/WebKit/public/web/WebDocument.h" |
#include "third_party/WebKit/public/web/WebFormControlElement.h" |
#include "third_party/WebKit/public/web/WebFormElement.h" |
@@ -25,6 +26,7 @@ |
#include "third_party/WebKit/public/web/WebTextAreaElement.h" |
#include "ui/base/l10n/l10n_util.h" |
+using blink::WebConsoleMessage; |
using blink::WebDocument; |
using blink::WebFormControlElement; |
using blink::WebFormElement; |
@@ -80,6 +82,11 @@ void FormCache::ExtractNewForms(const WebFrame& frame, |
WebVector<WebFormElement> web_forms; |
document.forms(web_forms); |
+ // We log an error message for deprecated attributes, but only the first time |
Ilya Sherman
2014/06/10 00:40:40
nit: "We log" -> "Log"
Evan Stade
2014/06/12 01:49:47
Done.
|
+ // the form is parsed. |
+ bool log_deprecation_messages = |
+ parsed_forms_.find(&frame) == parsed_forms_.end(); |
+ |
size_t num_fields_seen = 0; |
for (size_t i = 0; i < web_forms.size(); ++i) { |
WebFormElement form_element = web_forms[i]; |
@@ -92,6 +99,23 @@ void FormCache::ExtractNewForms(const WebFrame& frame, |
for (size_t j = 0; j < control_elements.size(); ++j) { |
WebFormControlElement element = control_elements[j]; |
+ if (log_deprecation_messages) { |
+ std::string autocomplete_attribute = |
+ base::UTF16ToUTF8(element.getAttribute("autocomplete")); |
+ |
+ static const char* deprecated[] = { "region", "locality" }; |
Ilya Sherman
2014/06/10 00:40:40
nit: "const char*" -> "const char* const"
Evan Stade
2014/06/12 01:49:46
Done.
|
+ for (size_t i = 0; i < arraysize(deprecated); ++i) { |
+ if (autocomplete_attribute.find(deprecated[i]) != std::string::npos) { |
+ WebConsoleMessage console_message = WebConsoleMessage( |
+ WebConsoleMessage::LevelLog, |
Ilya Sherman
2014/06/10 00:40:40
Wouldn't LevelWarning or LevelError be more approp
Evan Stade
2014/06/12 01:49:46
yea, I think warning is correct
|
+ WebString(base::ASCIIToUTF16(std::string("autocomplete='") + |
+ deprecated[i] + "' is deprecated and will soon be ignored. " |
+ "See http://goo.gl/YjeSsW"))); |
+ element.document().frame()->addMessageToConsole(console_message); |
+ } |
+ } |
+ } |
+ |
// Save original values of <select> elements so we can restore them |
// when |ClearFormWithNode()| is invoked. |
if (IsSelectElement(element)) { |