Title: [261966] trunk/Source
Revision
261966
Author
megan_gard...@apple.com
Date
2020-05-20 15:33:59 -0700 (Wed, 20 May 2020)

Log Message

Hide password echo when screen is being captured.
https://bugs.webkit.org/show_bug.cgi?id=212060
<rdar://problem/47653578>

Reviewed by Wenson Hsieh.

Source/WebCore:

When the screen is being captured, turn off the password echo.

* editing/InsertIntoTextNodeCommand.cpp:
(WebCore::InsertIntoTextNodeCommand::doApply):
* page/EditorClient.h:
(WebCore::EditorClient::isScreenCaptured const):

Source/WebKit:

Use the UIScreen state and notification to determine if the
screen is being shared or captured. This flag is for all
capture methods, Air Play, Screen Recording, etc. If the screen is
being captured, turn off the password echo to prevent the password from
being leaked.

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
(-[WKContentView _screenCapturedDidChange:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setIsScreenCaptured):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::isScreenCaptured const):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::isScreenCaptured const):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setIsScreenCaptured):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261965 => 261966)


--- trunk/Source/WebCore/ChangeLog	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebCore/ChangeLog	2020-05-20 22:33:59 UTC (rev 261966)
@@ -1,3 +1,18 @@
+2020-05-20  Megan Gardner  <megan_gard...@apple.com>
+
+        Hide password echo when screen is being captured.
+        https://bugs.webkit.org/show_bug.cgi?id=212060
+        <rdar://problem/47653578>
+
+        Reviewed by Wenson Hsieh.
+
+        When the screen is being captured, turn off the password echo. 
+
+        * editing/InsertIntoTextNodeCommand.cpp:
+        (WebCore::InsertIntoTextNodeCommand::doApply):
+        * page/EditorClient.h:
+        (WebCore::EditorClient::isScreenCaptured const):
+
 2020-05-20  ChangSeok Oh  <changs...@webkit.org>
 
         [GTK] Implement connected and disconnected events of GAMEPAD API with libmanette

Modified: trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp (261965 => 261966)


--- trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp	2020-05-20 22:33:59 UTC (rev 261966)
@@ -27,6 +27,8 @@
 #include "InsertIntoTextNodeCommand.h"
 
 #include "Document.h"
+#include "Editor.h"
+#include "EditorClient.h"
 #include "Frame.h"
 #include "RenderText.h"
 #include "Settings.h"
@@ -51,13 +53,14 @@
 void InsertIntoTextNodeCommand::doApply()
 {
     bool passwordEchoEnabled = document().settings().passwordEchoEnabled();
-    if (passwordEchoEnabled)
+    bool shouldSuppressPasswordEcho = document().editor().client()->shouldSuppressPasswordEcho();
+    if (passwordEchoEnabled && !shouldSuppressPasswordEcho)
         document().updateLayoutIgnorePendingStylesheets();
 
     if (!m_node->hasEditableStyle())
         return;
 
-    if (passwordEchoEnabled) {
+    if (passwordEchoEnabled && !shouldSuppressPasswordEcho) {
         if (RenderText* renderText = m_node->renderer())
             renderText->momentarilyRevealLastTypedCharacter(m_offset + m_text.length());
     }

Modified: trunk/Source/WebCore/page/EditorClient.h (261965 => 261966)


--- trunk/Source/WebCore/page/EditorClient.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebCore/page/EditorClient.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -71,6 +71,7 @@
     virtual bool shouldInsertText(const String&, Range*, EditorInsertAction) = 0;
     virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) = 0;
     virtual bool shouldRevealCurrentSelectionAfterInsertion() const { return true; };
+    virtual bool shouldSuppressPasswordEcho() const { return false; };
     
     virtual bool shouldApplyStyle(StyleProperties*, Range*) = 0;
     virtual void didApplyStyle() = 0;

Modified: trunk/Source/WebKit/ChangeLog (261965 => 261966)


--- trunk/Source/WebKit/ChangeLog	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/ChangeLog	2020-05-20 22:33:59 UTC (rev 261966)
@@ -1,3 +1,32 @@
+2020-05-20  Megan Gardner  <megan_gard...@apple.com>
+
+        Hide password echo when screen is being captured.
+        https://bugs.webkit.org/show_bug.cgi?id=212060
+        <rdar://problem/47653578>
+
+        Reviewed by Wenson Hsieh.
+
+        Use the UIScreen state and notification to determine if the
+        screen is being shared or captured. This flag is for all
+        capture methods, Air Play, Screen Recording, etc. If the screen is
+        being captured, turn off the password echo to prevent the password from
+        being leaked.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
+        (-[WKContentView _screenCapturedDidChange:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::setIsScreenCaptured):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::isScreenCaptured const):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::isScreenCaptured const):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::setIsScreenCaptured):
+
 2020-05-20  ChangSeok Oh  <changs...@webkit.org>
 
         [GTK] Implement connected and disconnected events of GAMEPAD API with libmanette

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (261965 => 261966)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2020-05-20 22:33:59 UTC (rev 261966)
@@ -107,6 +107,7 @@
     encoder << deviceOrientation;
     encoder << keyboardIsAttached;
     encoder << canShowWhileLocked;
+    encoder << isCapturingScreen;
 #endif
 #if PLATFORM(COCOA)
     encoder << smartInsertDeleteEnabled;
@@ -340,6 +341,8 @@
         return WTF::nullopt;
     if (!decoder.decode(parameters.canShowWhileLocked))
         return WTF::nullopt;
+    if (!decoder.decode(parameters.isCapturingScreen))
+        return WTF::nullopt;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (261965 => 261966)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -167,6 +167,7 @@
     int32_t deviceOrientation { 0 };
     bool keyboardIsAttached { false };
     bool canShowWhileLocked { false };
+    bool isCapturingScreen { false };
 #endif
 #if PLATFORM(COCOA)
     bool smartInsertDeleteEnabled;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (261965 => 261966)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -718,6 +718,8 @@
     void focusTextInputContextAndPlaceCaret(const WebCore::ElementContext&, const WebCore::IntPoint&, CompletionHandler<void(bool)>&&);
 
     void setShouldRevealCurrentSelectionAfterInsertion(bool);
+        
+    void setScreenIsBeingCaptured(bool);
 
     void insertTextPlaceholder(const WebCore::IntSize&, CompletionHandler<void(const Optional<WebCore::ElementContext>&)>&&);
     void removeTextPlaceholder(const WebCore::ElementContext&, CompletionHandler<void()>&&);

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (261965 => 261966)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -169,6 +169,7 @@
     _page->setIntrinsicDeviceScaleFactor(WebCore::screenScaleFactor([UIScreen mainScreen]));
     _page->setUseFixedLayout(true);
     _page->setDelegatesScrolling(true);
+    _page->setScreenIsBeingCaptured([[[self window] screen] isCaptured]);
 
 #if ENABLE(FULLSCREEN_API)
     _page->setFullscreenClient(makeUnique<WebKit::FullscreenClient>(self.webView));
@@ -208,6 +209,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:[UIApplication sharedApplication]];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:[UIApplication sharedApplication]];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_screenCapturedDidChange:) name:UIScreenCapturedDidChangeNotification object:[UIScreen mainScreen]];
 
 #if USE(UIKIT_KEYBOARD_ADDITIONS)
     if (WebCore::IOSApplication::isEvernote() && !linkedOnOrAfter(WebKit::SDKVersion::FirstWhereWKContentViewDoesNotOverrideKeyCommands))
@@ -771,6 +773,11 @@
         _page->applicationWillEnterForegroundForMedia();
 }
 
+- (void)_screenCapturedDidChange:(NSNotification *)notification
+{
+    _page->setScreenIsBeingCaptured([[[self window] screen] isCaptured]);
+}
+
 @end
 
 #pragma mark Printing

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261965 => 261966)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -896,6 +896,7 @@
 #endif
 
     _page->process().updateTextCheckerState();
+    _page->setScreenIsBeingCaptured([[[self window] screen] isCaptured]);
 
     _hasSetUpInteractions = YES;
 }

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (261965 => 261966)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -1581,6 +1581,12 @@
         send(Messages::WebPage::SetShouldRevealCurrentSelectionAfterInsertion(shouldRevealCurrentSelectionAfterInsertion));
 }
 
+void WebPageProxy::setScreenIsBeingCaptured(bool captured)
+{
+    if (hasRunningProcess())
+        send(Messages::WebPage::SetScreenIsBeingCaptured(captured));
+}
+
 void WebPageProxy::willOpenAppLink()
 {
     if (m_openingAppLinkActivity && m_openingAppLinkActivity->isValid())

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (261965 => 261966)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -188,6 +188,7 @@
     void updateStringForFind(const String&) final;
     bool shouldAllowSingleClickToChangeSelection(WebCore::Node&, const WebCore::VisibleSelection&) const final;
     bool shouldRevealCurrentSelectionAfterInsertion() const final;
+    bool shouldSuppressPasswordEcho() const final;
 #endif
 
     bool performTwoStepDrop(WebCore::DocumentFragment&, WebCore::Range&, bool isMove) final;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm (261965 => 261966)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -119,6 +119,11 @@
     return m_page->shouldRevealCurrentSelectionAfterInsertion();
 }
 
+bool WebEditorClient::shouldSuppressPasswordEcho() const
+{
+    return m_page->screenIsBeingCaptured() || m_page->hardwareKeyboardIsAttached();
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (261965 => 261966)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -667,6 +667,9 @@
     WebCore::FloatSize overrideScreenSize() const;
     int32_t deviceOrientation() const { return m_deviceOrientation; }
     void didReceiveMobileDocType(bool);
+    
+    bool screenIsBeingCaptured() const { return m_screenIsBeingCaptured; }
+    void setScreenIsBeingCaptured(bool);
 
     double minimumPageScaleFactor() const;
     double maximumPageScaleFactor() const;
@@ -1016,6 +1019,7 @@
     bool platformPrefersTextLegibilityBasedZoomScaling() const;
 
     void hardwareKeyboardAvailabilityChanged(bool keyboardIsAttached);
+    bool hardwareKeyboardIsAttached() const { return m_keyboardIsAttached; }
 
     void updateStringForFind(const String&);
     
@@ -1990,6 +1994,7 @@
     bool m_hasStablePageScaleFactor { true };
     bool m_isInStableState { true };
     bool m_shouldRevealCurrentSelectionAfterInsertion { true };
+    bool m_screenIsBeingCaptured { false };
     MonotonicTime m_oldestNonStableUpdateVisibleContentRectsTimestamp;
     Seconds m_estimatedLatency { 0 };
     WebCore::FloatSize m_screenSize;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (261965 => 261966)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-05-20 22:33:59 UTC (rev 261966)
@@ -52,6 +52,8 @@
     SetDeviceOrientation(int32_t deviceOrientation)
     SetOverrideViewportArguments(Optional<WebCore::ViewportArguments> arguments)
     DynamicViewportSizeUpdate(WebCore::FloatSize viewLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, double minimumEffectiveDeviceWidth, uint64_t dynamicViewportSizeUpdateID)
+    
+    SetScreenIsBeingCaptured(bool captured)
 
     HandleTap(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, WebKit::TransactionID lastLayerTreeTransactionId)
     PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point, bool shouldRequestMagnificationInformation)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (261965 => 261966)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -4292,6 +4292,11 @@
     scheduleFullEditorStateUpdate();
 }
 
+void WebPage::setScreenIsBeingCaptured(bool captured)
+{
+    m_screenIsBeingCaptured = captured;
+}
+
 void WebPage::textInputContextsInRect(FloatRect searchRect, CompletionHandler<void(const Vector<ElementContext>&)>&& completionHandler)
 {
     auto contexts = m_page->editableElementsInRect(searchRect).map([&] (const auto& element) {

Modified: trunk/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m (261965 => 261966)


--- trunk/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m	2020-05-20 22:33:59 UTC (rev 261966)
@@ -268,6 +268,11 @@
 }
 #endif
 
+- (BOOL)shouldSuppressPasswordEcho
+{
+    return NO;
+}
+
 - (BOOL)hasRichlyEditableSelection
 {
     return NO;

Modified: trunk/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h (261965 => 261966)


--- trunk/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -128,6 +128,8 @@
 
 - (BOOL)shouldRevealCurrentSelectionAfterInsertion;
 
+- (BOOL)shouldSuppressPasswordEcho;
+
 #if ENABLE_ORIENTATION_EVENTS
 - (int)deviceOrientation;
 #endif

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h (261965 => 261966)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -149,8 +149,8 @@
     RefPtr<WebCore::DocumentFragment> documentFragmentFromDelegate(int index) final;
     bool performsTwoStepPaste(WebCore::DocumentFragment*) final;
     void updateStringForFind(const String&) final { }
-
     bool shouldRevealCurrentSelectionAfterInsertion() const final;
+    bool shouldSuppressPasswordEcho() const final;
 #endif
 
     bool performTwoStepDrop(WebCore::DocumentFragment&, WebCore::Range& destination, bool isMove) final;

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (261965 => 261966)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -830,6 +830,13 @@
     return true;
 }
 
+bool WebEditorClient::shouldSuppressPasswordEcho() const
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(shouldSuppressPasswordEcho)])
+        return [[m_webView _UIKitDelegateForwarder] shouldSuppressPasswordEcho];
+    return false;
+}
+
 RefPtr<WebCore::DocumentFragment> WebEditorClient::documentFragmentFromDelegate(int index)
 {
     if ([[m_webView _editingDelegateForwarder] respondsToSelector:@selector(documentFragmentForPasteboardItemAtIndex:)]) {

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (261965 => 261966)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-05-20 22:33:59 UTC (rev 261966)
@@ -1525,6 +1525,8 @@
 #if ENABLE(ORIENTATION_EVENTS)
     _private->deviceOrientation = [[self _UIKitDelegateForwarder] deviceOrientation];
 #endif
+    if ([[self _UIKitDelegateForwarder] respondsToSelector:@selector(shouldSuppressPasswordEcho)])
+        _private->shouldSuppressPasswordEcho = [[self _UIKitDelegateForwarder] shouldSuppressPasswordEcho];
 #endif
 
     if ([[NSUserDefaults standardUserDefaults] objectForKey:WebSmartInsertDeleteEnabled])

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebViewData.h (261965 => 261966)


--- trunk/Source/WebKitLegacy/mac/WebView/WebViewData.h	2020-05-20 22:33:35 UTC (rev 261965)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebViewData.h	2020-05-20 22:33:59 UTC (rev 261966)
@@ -245,6 +245,7 @@
 #if ENABLE(ORIENTATION_EVENTS)
     NSUInteger deviceOrientation;
 #endif
+    BOOL shouldSuppressPasswordEcho;
 #endif
     BOOL shouldCloseWithWindow;
     BOOL mainFrameDocumentReady;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to