Changeset 227282 in webkit


Ignore:
Timestamp:
Jan 21, 2018 10:41:05 PM (6 years ago)
Author:
rniwa@webkit.org
Message:

Turning off custom pasteboard data doesn't actually turn it off in WK2
https://bugs.webkit.org/show_bug.cgi?id=181920
<rdar://problem/36686429>

Reviewed by Wenson Hsieh.

Source/WebCore:

Replaced the global settings for custom pasteboard data by regular runtime enabled flags.

  • dom/DataTransfer.cpp:

(WebCore::DataTransfer::getDataForItem const):
(WebCore::DataTransfer::shouldSuppressGetAndSetDataToAvoidExposingFilePaths const):
(WebCore::DataTransfer::setDataFromItemList):
(WebCore::DataTransfer::types const):
(WebCore::DataTransfer::commitToPasteboard):

  • dom/DataTransferItemList.cpp:

(WebCore::shouldExposeTypeInItemList):

  • editing/Editor.cpp:

(WebCore::createDataTransferForClipboardEvent):

  • editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::createFragmentAndAddResources):
(WebCore::WebContentReader::readWebArchive):

  • page/DeprecatedGlobalSettings.cpp:

(WebCore::DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled): Deleted.

  • page/DeprecatedGlobalSettings.h:

(WebCore::DeprecatedGlobalSettings::setCustomPasteboardDataEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::customPasteboardDataEnabled): Deleted.

  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::setCustomPasteboardDataEnabled):
(WebCore::RuntimeEnabledFeatures::customPasteboardDataEnabled const):

  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setCustomPasteboardDataEnabled):

Source/WebKit:

Moved the code to decide when to enable custom pasteboard data from WebCore
since we never enable this feature in WebKit1.

  • Shared/WebPreferences.yaml:
  • Shared/WebPreferencesDefaultValues.cpp:

(defaultCustomPasteboardDataEnabled): Added.

  • Shared/WebPreferencesDefaultValues.h:

Source/WebKitLegacy/mac:

Always disable custom pasteboard data in WebKit1. See r226156 for details.

  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):

  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r227281 r227282  
     12018-01-21  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Turning off custom pasteboard data doesn't actually turn it off in WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=181920
     5        <rdar://problem/36686429>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Replaced the global settings for custom pasteboard data by regular runtime enabled flags.
     10
     11        * dom/DataTransfer.cpp:
     12        (WebCore::DataTransfer::getDataForItem const):
     13        (WebCore::DataTransfer::shouldSuppressGetAndSetDataToAvoidExposingFilePaths const):
     14        (WebCore::DataTransfer::setDataFromItemList):
     15        (WebCore::DataTransfer::types const):
     16        (WebCore::DataTransfer::commitToPasteboard):
     17        * dom/DataTransferItemList.cpp:
     18        (WebCore::shouldExposeTypeInItemList):
     19        * editing/Editor.cpp:
     20        (WebCore::createDataTransferForClipboardEvent):
     21        * editing/cocoa/WebContentReaderCocoa.mm:
     22        (WebCore::createFragmentAndAddResources):
     23        (WebCore::WebContentReader::readWebArchive):
     24        * page/DeprecatedGlobalSettings.cpp:
     25        (WebCore::DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled): Deleted.
     26        * page/DeprecatedGlobalSettings.h:
     27        (WebCore::DeprecatedGlobalSettings::setCustomPasteboardDataEnabled): Deleted.
     28        (WebCore::DeprecatedGlobalSettings::customPasteboardDataEnabled): Deleted.
     29        * page/RuntimeEnabledFeatures.h:
     30        (WebCore::RuntimeEnabledFeatures::setCustomPasteboardDataEnabled):
     31        (WebCore::RuntimeEnabledFeatures::customPasteboardDataEnabled const):
     32        * testing/InternalSettings.cpp:
     33        (WebCore::InternalSettings::Backup::Backup):
     34        (WebCore::InternalSettings::Backup::restoreTo):
     35        (WebCore::InternalSettings::setCustomPasteboardDataEnabled):
     36
    1372018-01-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    238
  • trunk/Source/WebCore/dom/DataTransfer.cpp

    r225117 r227282  
    3131#include "DataTransferItem.h"
    3232#include "DataTransferItemList.h"
    33 #include "DeprecatedGlobalSettings.h"
    3433#include "DocumentFragment.h"
    3534#include "DragData.h"
     
    4241#include "Image.h"
    4342#include "Pasteboard.h"
     43#include "RuntimeEnabledFeatures.h"
    4444#include "Settings.h"
    4545#include "StaticPasteboard.h"
     
    158158    }
    159159
    160     if (!DeprecatedGlobalSettings::customPasteboardDataEnabled())
     160    if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled())
    161161        return m_pasteboard->readString(lowercaseType);
    162162
     
    189189bool DataTransfer::shouldSuppressGetAndSetDataToAvoidExposingFilePaths() const
    190190{
    191     if (!forFileDrag() && !DeprecatedGlobalSettings::customPasteboardDataEnabled())
     191    if (!forFileDrag() && !RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled())
    192192        return false;
    193193    return m_pasteboard->containsFiles();
     
    213213    RELEASE_ASSERT(is<StaticPasteboard>(*m_pasteboard));
    214214
    215     if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     215    if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    216216        m_pasteboard->writeString(type, data);
    217217        return;
     
    275275        return { };
    276276   
    277     if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     277    if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    278278        auto types = m_pasteboard->typesForLegacyUnsafeBindings();
    279279        ASSERT(!types.contains("Files"));
     
    383383    ASSERT(is<StaticPasteboard>(*m_pasteboard) && !is<StaticPasteboard>(nativePasteboard));
    384384    PasteboardCustomData customData = downcast<StaticPasteboard>(*m_pasteboard).takeCustomData();
    385     if (DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     385    if (RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    386386        customData.origin = m_originIdentifier;
    387387        nativePasteboard.writeCustomData(customData);
  • trunk/Source/WebCore/dom/DataTransferItemList.cpp

    r223728 r227282  
    2828
    2929#include "DataTransferItem.h"
    30 #include "DeprecatedGlobalSettings.h"
    3130#include "FileList.h"
    3231#include "Pasteboard.h"
     32#include "RuntimeEnabledFeatures.h"
    3333#include "Settings.h"
    3434
     
    5757static bool shouldExposeTypeInItemList(const String& type)
    5858{
    59     return DeprecatedGlobalSettings::customPasteboardDataEnabled() || Pasteboard::isSafeTypeForDOMToReadAndWrite(type);
     59    return RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled() || Pasteboard::isSafeTypeForDOMToReadAndWrite(type);
    6060}
    6161
  • trunk/Source/WebCore/editing/Editor.cpp

    r227068 r227282  
    3939#include "DataTransfer.h"
    4040#include "DeleteSelectionCommand.h"
    41 #include "DeprecatedGlobalSettings.h"
    4241#include "DictationAlternative.h"
    4342#include "DictationCommand.h"
     
    8483#include "ReplaceRangeWithTextCommand.h"
    8584#include "ReplaceSelectionCommand.h"
     85#include "RuntimeEnabledFeatures.h"
    8686#include "Settings.h"
    8787#include "ShadowRoot.h"
     
    361361        return DataTransfer::createForCopyAndPaste(document, DataTransfer::StoreMode::ReadWrite, std::make_unique<StaticPasteboard>());
    362362    case ClipboardEventKind::PasteAsPlainText:
    363         if (DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     363        if (RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    364364            auto plainTextType = ASCIILiteral("text/plain");
    365365            auto plainText = Pasteboard::createForCopyAndPaste()->readString(plainTextType);
  • trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r227084 r227282  
    3232#import "CachedResourceLoader.h"
    3333#import "DOMURL.h"
    34 #import "DeprecatedGlobalSettings.h"
    3534#import "Document.h"
    3635#import "DocumentFragment.h"
     
    327326        return nullptr;
    328327
    329     if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     328    if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    330329        if (DocumentLoader* loader = frame.loader().documentLoader()) {
    331330            for (auto& resource : fragmentAndResources.resources)
     
    458457        return false;
    459458   
    460     if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
     459    if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) {
    461460        fragment = createFragmentFromMarkup(*frame.document(), result->markup, result->mainResource->url(), DisallowScriptingAndPluginContent);
    462461        if (DocumentLoader* loader = frame.loader().documentLoader())
  • trunk/Source/WebCore/page/DeprecatedGlobalSettings.cpp

    r226156 r227282  
    4040#endif
    4141
    42 #if PLATFORM(COCOA)
    43 #include <wtf/spi/darwin/dyldSPI.h>
    44 #endif
    45 
    4642namespace WebCore {
    4743
     
    8379#endif
    8480bool DeprecatedGlobalSettings::gManageAudioSession = false;
    85 bool DeprecatedGlobalSettings::gCustomPasteboardDataEnabled = false;
    86 
    87 bool DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled()
    88 {
    89     if (!isInWebProcess())
    90         return false;
    91 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300
    92     return IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
    93 #elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
    94     return MacApplication::isSafari() || dyld_get_program_sdk_version() > DYLD_MACOSX_VERSION_10_13;
    95 #elif PLATFORM(MAC)
    96     return MacApplication::isSafari();
    97 #else
    98     return false;
    99 #endif
    100 }
    10181
    10282#if PLATFORM(WIN)
  • trunk/Source/WebCore/page/DeprecatedGlobalSettings.h

    r223720 r227282  
    109109    static bool shouldManageAudioSessionCategory() { return gManageAudioSession; }
    110110#endif
    111 
    112     static void setCustomPasteboardDataEnabled(bool enabled) { gCustomPasteboardDataEnabled = enabled; }
    113     static bool customPasteboardDataEnabled() { return gCustomPasteboardDataEnabled; }
    114     WEBCORE_EXPORT static bool defaultCustomPasteboardDataEnabled();
    115111   
    116112#if ENABLE(MEDIA_STREAM)
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r227079 r227282  
    8383    bool dataTransferItemsEnabled() const { return m_areDataTransferItemsEnabled; }
    8484
     85    void setCustomPasteboardDataEnabled(bool isEnabled) { m_isCustomPasteboardDataEnabled = isEnabled; }
     86    bool customPasteboardDataEnabled() const { return m_isCustomPasteboardDataEnabled; }
     87
    8588#if ENABLE(ATTACHMENT_ELEMENT)
    8689    void setAttachmentElementEnabled(bool areEnabled) { m_isAttachmentElementEnabled = areEnabled; }
     
    263266    bool m_isDirectoryUploadEnabled { false };
    264267    bool m_areDataTransferItemsEnabled { false };
     268    bool m_isCustomPasteboardDataEnabled { false };
    265269    bool m_inputEventsEnabled { true };
    266270
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r226211 r227282  
    120120    , m_shouldManageAudioSessionCategory(DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
    121121#endif
    122     , m_customPasteboardDataEnabled(DeprecatedGlobalSettings::customPasteboardDataEnabled())
     122    , m_customPasteboardDataEnabled(RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled())
    123123{
    124124}
     
    217217    RuntimeEnabledFeatures::sharedFeatures().setScreenCaptureEnabled(m_setScreenCaptureEnabled);
    218218#endif
     219    RuntimeEnabledFeatures::sharedFeatures().setCustomPasteboardDataEnabled(m_customPasteboardDataEnabled);
    219220
    220221#if USE(AUDIO_SESSION)
    221222    DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(m_shouldManageAudioSessionCategory);
    222223#endif
    223     DeprecatedGlobalSettings::setCustomPasteboardDataEnabled(m_customPasteboardDataEnabled);
    224224}
    225225
     
    880880ExceptionOr<void> InternalSettings::setCustomPasteboardDataEnabled(bool enabled)
    881881{
    882     DeprecatedGlobalSettings::setCustomPasteboardDataEnabled(enabled);
     882    RuntimeEnabledFeatures::sharedFeatures().setCustomPasteboardDataEnabled(enabled);
    883883    return { };
    884884}
  • trunk/Source/WebKit/ChangeLog

    r227281 r227282  
     12018-01-21  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Turning off custom pasteboard data doesn't actually turn it off in WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=181920
     5        <rdar://problem/36686429>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Moved the code to decide when to enable custom pasteboard data from WebCore
     10        since we never enable this feature in WebKit1.
     11
     12        * Shared/WebPreferences.yaml:
     13        * Shared/WebPreferencesDefaultValues.cpp:
     14        (defaultCustomPasteboardDataEnabled): Added.
     15        * Shared/WebPreferencesDefaultValues.h:
     16
    1172018-01-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    218
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r227240 r227282  
    780780CustomPasteboardDataEnabled:
    781781  type: bool
    782   defaultValue: WebCore::DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled()
     782  defaultValue: defaultCustomPasteboardDataEnabled()
    783783  humanReadableName: "Custom pateboard data"
    784784  humanReadableDescription: "Enable custom clipboard types and better security model for clipboard API."
    785   webcoreBinding: DeprecatedGlobalSettings
     785  webcoreBinding: RuntimeEnabledFeatures
    786786
    787787WebVREnabled:
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r227240 r227282  
    2626#include "config.h"
    2727#include "WebPreferencesDefaultValues.h"
     28#import <WebCore/RuntimeApplicationChecks.h>
     29
     30#if PLATFORM(COCOA)
     31#include <wtf/spi/darwin/dyldSPI.h>
     32#endif
    2833
    2934#if PLATFORM(IOS)
     
    3944#endif
    4045}
     46
     47bool defaultCustomPasteboardDataEnabled()
     48{
     49#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300
     50    return WebCore::IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
     51#elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
     52    return WebCore::MacApplication::isSafari() || dyld_get_program_sdk_version() > DYLD_MACOSX_VERSION_10_13;
     53#elif PLATFORM(MAC)
     54    return WebCore::MacApplication::isSafari();
     55#else
     56    return false;
     57#endif
     58}
     59
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r227240 r227282  
    187187
    188188bool defaultPassiveTouchListenersAsDefaultOnDocument();
     189bool defaultCustomPasteboardDataEnabled();
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r227281 r227282  
     12018-01-21  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Turning off custom pasteboard data doesn't actually turn it off in WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=181920
     5        <rdar://problem/36686429>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Always disable custom pasteboard data in WebKit1. See r226156 for details.
     10
     11        * WebView/WebPreferences.mm:
     12        (+[WebPreferences initialize]):
     13        * WebView/WebView.mm:
     14        (-[WebView _preferencesChanged:]):
     15
    1162018-01-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    217
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm

    r227079 r227282  
    623623        [NSNumber numberWithBool:YES], WebKitCustomElementsEnabledPreferenceKey,
    624624        [NSNumber numberWithBool:YES], WebKitDataTransferItemsEnabledPreferenceKey,
    625         [NSNumber numberWithBool:DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled()], WebKitCustomPasteboardDataEnabledPreferenceKey,
     625        [NSNumber numberWithBool:NO], WebKitCustomPasteboardDataEnabledPreferenceKey,
    626626        [NSNumber numberWithBool:YES], WebKitModernMediaControlsEnabledPreferenceKey,
    627627#if ENABLE(WEBGL2)
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r227240 r227282  
    29952995    RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled([preferences customElementsEnabled]);
    29962996    RuntimeEnabledFeatures::sharedFeatures().setDataTransferItemsEnabled([preferences dataTransferItemsEnabled]);
     2997    RuntimeEnabledFeatures::sharedFeatures().setCustomPasteboardDataEnabled([preferences customPasteboardDataEnabled]);
    29972998
    29982999#if ENABLE(ATTACHMENT_ELEMENT)
     
    30733074    [WAKView _setInterpolationQuality:[preferences _interpolationQuality]];
    30743075#endif
    3075 
    3076     DeprecatedGlobalSettings::setCustomPasteboardDataEnabled([preferences customPasteboardDataEnabled]);
    30773076
    30783077#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
Note: See TracChangeset for help on using the changeset viewer.