Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp

Issue 2485803002: Use attach/detachLayoutTree to signal password counting (Closed)
Patch Set: fix DCHECK_GT Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/PasswordInputType.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp b/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
index 662db24915d98ea805fb867459fdc4fda593742a..b231fd00f1eb43c116332e101e173fbc2428ca8c 100644
--- a/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
@@ -44,58 +44,6 @@
namespace blink {
-namespace {
-
-class PasswordLayoutObject : public LayoutTextControlSingleLine {
- public:
- explicit PasswordLayoutObject(HTMLInputElement* element)
- : LayoutTextControlSingleLine(element) {
- Document& document = element->document();
- DCHECK(document.frame());
- if (document.isSecureContext()) {
- // The browser process only cares about passwords on pages where the
- // top-level URL is not secure. Secure contexts must have a top-level
- // URL that is secure, so there is no need to send notifications for
- // password fields in secure contexts.
- return;
- }
-
- document.incrementPasswordCount();
- if (document.passwordCount() > 1) {
- // Only send a message on the first visible password field; the
- // browser process doesn't care about the presence of additional
- // password fields beyond that.
- return;
- }
- mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
- document.frame()->interfaceProvider()->getInterface(
- mojo::GetProxy(&sensitiveInputServicePtr));
- sensitiveInputServicePtr->PasswordFieldVisibleInInsecureContext();
- }
-
- ~PasswordLayoutObject() override {}
-
- protected:
- void willBeDestroyed() override {
- LayoutTextControlSingleLine::willBeDestroyed();
- Document& document = inputElement()->document();
- DCHECK(document.frame());
- if (document.isSecureContext()) {
- return;
- }
- document.decrementPasswordCount();
- if (document.passwordCount() > 0)
- return;
-
- mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
- document.frame()->interfaceProvider()->getInterface(
- mojo::GetProxy(&sensitiveInputServicePtr));
- sensitiveInputServicePtr->AllPasswordFieldsInInsecureContextInvisible();
- }
-};
-
-} // namespace
-
InputType* PasswordInputType::create(HTMLInputElement& element) {
return new PasswordInputType(element);
}
@@ -139,9 +87,44 @@ void PasswordInputType::disableSecureTextInput() {
element().document().setUseSecureKeyboardEntryWhenActive(false);
}
-LayoutObject* PasswordInputType::createLayoutObject(
- const ComputedStyle& style) const {
- return new PasswordLayoutObject(&element());
+void PasswordInputType::onAttachWithLayoutObject() {
+ Document& document = element().document();
+ DCHECK(document.frame());
+ if (document.isSecureContext()) {
+ // The browser process only cares about passwords on pages where the
+ // top-level URL is not secure. Secure contexts must have a top-level
+ // URL that is secure, so there is no need to send notifications for
+ // password fields in secure contexts.
+ return;
+ }
+
+ document.incrementPasswordCount();
+ if (document.passwordCount() > 1) {
+ // Only send a message on the first visible password field; the
+ // browser process doesn't care about the presence of additional
+ // password fields beyond that.
+ return;
+ }
+ mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
+ document.frame()->interfaceProvider()->getInterface(
+ mojo::GetProxy(&sensitiveInputServicePtr));
+ sensitiveInputServicePtr->PasswordFieldVisibleInInsecureContext();
+}
+
+void PasswordInputType::onDetachWithLayoutObject() {
+ Document& document = element().document();
+ DCHECK(document.frame());
+ if (document.isSecureContext()) {
+ return;
+ }
+ document.decrementPasswordCount();
+ if (document.passwordCount() > 0)
+ return;
+
+ mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
+ document.frame()->interfaceProvider()->getInterface(
+ mojo::GetProxy(&sensitiveInputServicePtr));
+ sensitiveInputServicePtr->AllPasswordFieldsInInsecureContextInvisible();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/PasswordInputType.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698