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

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

Issue 2378503002: Observe visibility of password inputs, for HTTP-bad phase 1 (Closed)
Patch Set: fix browser-side binding Created 4 years, 3 months 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
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 a2453cbdf41c9e27cfa9d9ff688359a1f745c3a4..e11d64f62181e0e4232e5236f4c8bd14c58901aa 100644
--- a/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
@@ -33,8 +33,11 @@
#include "core/InputTypeNames.h"
#include "core/dom/Document.h"
+#include "core/frame/LocalFrame.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/forms/FormController.h"
+#include "public/platform/InterfaceProvider.h"
+#include "public/platform/modules/sensitive_input_visibility/sensitive_input_visibility_service.mojom-blink.h"
#include "wtf/Assertions.h"
#include "wtf/PassRefPtr.h"
@@ -45,6 +48,19 @@ InputType* PasswordInputType::create(HTMLInputElement& element)
return new PasswordInputType(element);
}
+DEFINE_TRACE(PasswordInputType)
+{
+ visitor->trace(m_visibilityObserver);
+ BaseTextInputType::trace(visitor);
+}
+
+PasswordInputType::PasswordInputType(HTMLInputElement& element)
+ : BaseTextInputType(element)
+ , m_visibilityObserver(new ElementVisibilityObserver(&element, WTF::bind(&PasswordInputType::onVisibilityChanged, wrapWeakPersistent(this))))
+{
+ m_visibilityObserver->start();
+}
+
void PasswordInputType::countUsage()
{
countUsageIfVisible(UseCounter::InputTypePassword);
@@ -92,4 +108,13 @@ void PasswordInputType::disableSecureTextInput()
element().document().setUseSecureKeyboardEntryWhenActive(false);
}
+void PasswordInputType::onVisibilityChanged(bool isVisible)
+{
+ if (!isVisible || !element().document().frame())
+ return;
+ mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
+ element().document().frame()->interfaceProvider()->getInterface(mojo::GetProxy(&sensitiveInputServicePtr));
+ sensitiveInputServicePtr->PasswordFieldVisible();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698