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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2515373003: Post tasks for sensitive input visibility notifications (Closed)
Patch Set: dcheng, haraken comments round 2 Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 #include "platform/ScriptForbiddenScope.h" 234 #include "platform/ScriptForbiddenScope.h"
235 #include "platform/network/ContentSecurityPolicyParsers.h" 235 #include "platform/network/ContentSecurityPolicyParsers.h"
236 #include "platform/network/HTTPParsers.h" 236 #include "platform/network/HTTPParsers.h"
237 #include "platform/scroll/ScrollbarTheme.h" 237 #include "platform/scroll/ScrollbarTheme.h"
238 #include "platform/text/PlatformLocale.h" 238 #include "platform/text/PlatformLocale.h"
239 #include "platform/text/SegmentedString.h" 239 #include "platform/text/SegmentedString.h"
240 #include "platform/tracing/TraceEvent.h" 240 #include "platform/tracing/TraceEvent.h"
241 #include "platform/weborigin/OriginAccessEntry.h" 241 #include "platform/weborigin/OriginAccessEntry.h"
242 #include "platform/weborigin/SchemeRegistry.h" 242 #include "platform/weborigin/SchemeRegistry.h"
243 #include "platform/weborigin/SecurityOrigin.h" 243 #include "platform/weborigin/SecurityOrigin.h"
244 #include "public/platform/InterfaceProvider.h"
244 #include "public/platform/Platform.h" 245 #include "public/platform/Platform.h"
245 #include "public/platform/WebAddressSpace.h" 246 #include "public/platform/WebAddressSpace.h"
246 #include "public/platform/WebFrameScheduler.h" 247 #include "public/platform/WebFrameScheduler.h"
247 #include "public/platform/WebPrerenderingSupport.h" 248 #include "public/platform/WebPrerenderingSupport.h"
248 #include "public/platform/WebScheduler.h" 249 #include "public/platform/WebScheduler.h"
250 #include "public/platform/modules/sensitive_input_visibility/sensitive_input_vis ibility_service.mojom-blink.h"
249 #include "wtf/AutoReset.h" 251 #include "wtf/AutoReset.h"
250 #include "wtf/CurrentTime.h" 252 #include "wtf/CurrentTime.h"
251 #include "wtf/DateMath.h" 253 #include "wtf/DateMath.h"
252 #include "wtf/Functional.h" 254 #include "wtf/Functional.h"
253 #include "wtf/HashFunctions.h" 255 #include "wtf/HashFunctions.h"
254 #include "wtf/PtrUtil.h" 256 #include "wtf/PtrUtil.h"
255 #include "wtf/StdLibExtras.h" 257 #include "wtf/StdLibExtras.h"
256 #include "wtf/text/CharacterNames.h" 258 #include "wtf/text/CharacterNames.h"
257 #include "wtf/text/StringBuffer.h" 259 #include "wtf/text/StringBuffer.h"
258 #include "wtf/text/TextEncodingRegistry.h" 260 #include "wtf/text/TextEncodingRegistry.h"
(...skipping 4063 matching lines...) Expand 10 before | Expand all | Expand 10 after
4322 4324
4323 const OriginAccessEntry& Document::accessEntryFromURL() { 4325 const OriginAccessEntry& Document::accessEntryFromURL() {
4324 if (!m_accessEntryFromURL) { 4326 if (!m_accessEntryFromURL) {
4325 m_accessEntryFromURL = wrapUnique( 4327 m_accessEntryFromURL = wrapUnique(
4326 new OriginAccessEntry(url().protocol(), url().host(), 4328 new OriginAccessEntry(url().protocol(), url().host(),
4327 OriginAccessEntry::AllowRegisterableDomains)); 4329 OriginAccessEntry::AllowRegisterableDomains));
4328 } 4330 }
4329 return *m_accessEntryFromURL; 4331 return *m_accessEntryFromURL;
4330 } 4332 }
4331 4333
4334 void Document::sendSensitiveInputVisibility() {
4335 if (m_sensitiveInputVisibilityTask.isActive())
4336 return;
4337
4338 m_sensitiveInputVisibilityTask =
4339 TaskRunnerHelper::get(TaskType::Internal, this)
4340 ->postCancellableTask(
4341 BLINK_FROM_HERE,
4342 WTF::bind(&Document::sendSensitiveInputVisibilityInternal,
4343 wrapWeakPersistent(this)));
4344 }
4345
4346 void Document::sendSensitiveInputVisibilityInternal() {
4347 if (!frame())
4348 return;
4349
4350 mojom::blink::SensitiveInputVisibilityServicePtr sensitiveInputServicePtr;
4351 frame()->interfaceProvider()->getInterface(
4352 mojo::GetProxy(&sensitiveInputServicePtr));
4353 if (m_passwordCount > 0) {
4354 sensitiveInputServicePtr->PasswordFieldVisibleInInsecureContext();
4355 return;
4356 }
4357 sensitiveInputServicePtr->AllPasswordFieldsInInsecureContextInvisible();
4358 }
4359
4332 void Document::registerEventFactory( 4360 void Document::registerEventFactory(
4333 std::unique_ptr<EventFactoryBase> eventFactory) { 4361 std::unique_ptr<EventFactoryBase> eventFactory) {
4334 DCHECK(!eventFactories().contains(eventFactory.get())); 4362 DCHECK(!eventFactories().contains(eventFactory.get()));
4335 eventFactories().add(std::move(eventFactory)); 4363 eventFactories().add(std::move(eventFactory));
4336 } 4364 }
4337 4365
4338 Event* Document::createEvent(ExecutionContext* executionContext, 4366 Event* Document::createEvent(ExecutionContext* executionContext,
4339 const String& eventType, 4367 const String& eventType,
4340 ExceptionState& exceptionState) { 4368 ExceptionState& exceptionState) {
4341 Event* event = nullptr; 4369 Event* event = nullptr;
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after
6399 6427
6400 PropertyRegistry* Document::propertyRegistry() { 6428 PropertyRegistry* Document::propertyRegistry() {
6401 // TODO(timloh): When the flag is removed, return a reference instead. 6429 // TODO(timloh): When the flag is removed, return a reference instead.
6402 if (!m_propertyRegistry && RuntimeEnabledFeatures::cssVariables2Enabled()) 6430 if (!m_propertyRegistry && RuntimeEnabledFeatures::cssVariables2Enabled())
6403 m_propertyRegistry = PropertyRegistry::create(); 6431 m_propertyRegistry = PropertyRegistry::create();
6404 return m_propertyRegistry; 6432 return m_propertyRegistry;
6405 } 6433 }
6406 6434
6407 void Document::incrementPasswordCount() { 6435 void Document::incrementPasswordCount() {
6408 ++m_passwordCount; 6436 ++m_passwordCount;
6437 if (isSecureContext() || m_passwordCount != 1) {
6438 // The browser process only cares about passwords on pages where the
6439 // top-level URL is not secure. Secure contexts must have a top-level
6440 // URL that is secure, so there is no need to send notifications for
6441 // password fields in secure contexts.
6442 //
6443 // Also, only send a message on the first visible password field; the
6444 // browser process doesn't care about the presence of additional
6445 // password fields beyond that.
6446 return;
6447 }
6448 sendSensitiveInputVisibility();
6409 } 6449 }
6410 6450
6411 void Document::decrementPasswordCount() { 6451 void Document::decrementPasswordCount() {
6412 DCHECK_GT(m_passwordCount, 0u); 6452 DCHECK_GT(m_passwordCount, 0u);
6413 --m_passwordCount; 6453 --m_passwordCount;
6414 } 6454 if (isSecureContext() || m_passwordCount > 0)
6415 6455 return;
6416 unsigned Document::passwordCount() const { 6456 sendSensitiveInputVisibility();
6417 return m_passwordCount;
6418 } 6457 }
6419 6458
6420 DEFINE_TRACE(Document) { 6459 DEFINE_TRACE(Document) {
6421 visitor->trace(m_importsController); 6460 visitor->trace(m_importsController);
6422 visitor->trace(m_docType); 6461 visitor->trace(m_docType);
6423 visitor->trace(m_implementation); 6462 visitor->trace(m_implementation);
6424 visitor->trace(m_autofocusElement); 6463 visitor->trace(m_autofocusElement);
6425 visitor->trace(m_focusedElement); 6464 visitor->trace(m_focusedElement);
6426 visitor->trace(m_sequentialFocusNavigationStartingPoint); 6465 visitor->trace(m_sequentialFocusNavigationStartingPoint);
6427 visitor->trace(m_hoverNode); 6466 visitor->trace(m_hoverNode);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
6522 } 6561 }
6523 6562
6524 void showLiveDocumentInstances() { 6563 void showLiveDocumentInstances() {
6525 WeakDocumentSet& set = liveDocumentSet(); 6564 WeakDocumentSet& set = liveDocumentSet();
6526 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6565 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6527 for (Document* document : set) 6566 for (Document* document : set)
6528 fprintf(stderr, "- Document %p URL: %s\n", document, 6567 fprintf(stderr, "- Document %p URL: %s\n", document,
6529 document->url().getString().utf8().data()); 6568 document->url().getString().utf8().data());
6530 } 6569 }
6531 #endif 6570 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/html/forms/PasswordInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698