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

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

Issue 2468833002: Count visible password fields on a page (Closed)
Patch Set: fix comment wrapping 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
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 2909d1d4ec4c30a54271c51860fddfe85f6dfeaa..5b1fb2efbae533fa03424345ed8d21170c608764 100644
--- a/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp
@@ -36,6 +36,7 @@
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/forms/FormController.h"
+#include "core/layout/LayoutTextControlSingleLine.h"
#include "public/platform/InterfaceProvider.h"
#include "public/platform/modules/sensitive_input_visibility/sensitive_input_visibility_service.mojom-blink.h"
#include "wtf/Assertions.h"
@@ -43,6 +44,34 @@
namespace blink {
+namespace {
+
+class PasswordLayoutObject : public LayoutTextControlSingleLine {
+ public:
+ PasswordLayoutObject(HTMLInputElement* element)
+ : LayoutTextControlSingleLine(element) {}
+ ~PasswordLayoutObject() override {}
+
+ protected:
+ void willBeDestroyed() override {
+ LayoutTextControlSingleLine::willBeDestroyed();
+ LocalFrame* frame = inputElement()->document().frame();
+ if (inputElement()->document().isSecureContext() || !frame)
+ return;
+
+ frame->decrementPasswordCount();
+ if (frame->passwordCount() > 0)
+ return;
+
+ mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
+ frame->interfaceProvider()->getInterface(
+ mojo::GetProxy(&sensitiveInputServicePtr));
+ sensitiveInputServicePtr->AllPasswordFieldsInInsecureContextInvisible();
+ }
+};
+
+} // namespace
+
InputType* PasswordInputType::create(HTMLInputElement& element) {
return new PasswordInputType(element);
}
@@ -88,7 +117,7 @@ void PasswordInputType::disableSecureTextInput() {
LayoutObject* PasswordInputType::createLayoutObject(
const ComputedStyle& style) const {
- LayoutObject* layoutObject = TextFieldInputType::createLayoutObject(style);
+ LayoutObject* layoutObject = new PasswordLayoutObject(&element());
Document& document = element().document();
if (document.isSecureContext() || !layoutObject) {
// The browser process only cares about passwords on pages where the
@@ -98,6 +127,9 @@ LayoutObject* PasswordInputType::createLayoutObject(
return layoutObject;
}
+ if (document.frame())
+ document.frame()->incrementPasswordCount();
dcheng 2016/11/01 18:13:43 Also, for symmetry, can we increment / decrement t
estark 2016/11/01 18:32:26 Done. (I moved the Mojo IPC in to the layout objec
+
mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
element().document().frame()->interfaceProvider()->getInterface(
mojo::GetProxy(&sensitiveInputServicePtr));

Powered by Google App Engine
This is Rietveld 408576698