Changeset 58378 in webkit


Ignore:
Timestamp:
Apr 27, 2010 10:21:33 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-27 Daniel Cheng <dcheng@chromium.org>

Reviewed by Jian Li.

[Chromium] Filter out URLs with a file scheme from text/uri-list when dragging.
https://bugs.webkit.org/show_bug.cgi?id=38227

Unfortunately, the simple fix of not populating the drag data with file URLs doesn't work
since the default drop handling uses the drag data URL to navigate to dropped files/URLs.
For now, we hack around the problem in the Chromium platform, but the proper long term
solution is to change DragController::performDrag to check dragData::asFilenames().

No new tests.

  • platform/chromium/ClipboardChromium.cpp: (WebCore::ClipboardChromium::getData): (WebCore::ClipboardChromium::types):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58375 r58378  
     12010-04-27  Daniel Cheng  <dcheng@chromium.org>
     2
     3        Reviewed by Jian Li.
     4
     5        [Chromium] Filter out URLs with a file scheme from text/uri-list when dragging.
     6        https://bugs.webkit.org/show_bug.cgi?id=38227
     7
     8        Unfortunately, the simple fix of not populating the drag data with file URLs doesn't work
     9        since the default drop handling uses the drag data URL to navigate to dropped files/URLs.
     10        For now, we hack around the problem in the Chromium platform, but the proper long term
     11        solution is to change DragController::performDrag to check dragData::asFilenames().
     12
     13        No new tests.
     14
     15        * platform/chromium/ClipboardChromium.cpp:
     16        (WebCore::ClipboardChromium::getData):
     17        (WebCore::ClipboardChromium::types):
     18
    1192010-04-27  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/WebCore/platform/chromium/ClipboardChromium.cpp

    r58276 r58378  
    163163        return String();
    164164
     165    // Hack for URLs. file URLs are used internally for drop's default action, but we don't want
     166    // to expose them to the page, so we filter them out here.
    165167    case ClipboardDataTypeURIList:
    166168        {
     
    168170            for (size_t i = 0; i < m_dataObject->uriList.size(); ++i) {
    169171                const String& uri = m_dataObject->uriList[i];
     172                if (protocolIs(uri, "file"))
     173                    continue;
    170174                ASSERT(!uri.isEmpty());
    171175                if (!text.isEmpty())
     
    181185        // In case of a previous setData('text/uri-list'), setData() has already
    182186        // prepared the 'url' member, so we can just retrieve it here.
    183         if (!m_dataObject->url.isEmpty()) {
     187        if (!m_dataObject->url.isEmpty() && !m_dataObject->url.isLocalFile()) {
    184188            success = true;
    185189            return m_dataObject->url.string();
     
    317321        results.add("Files");
    318322
    319     if (m_dataObject->url.isValid()) {
     323    // Hack for URLs. file URLs are used internally for drop's default action, but we don't want
     324    // to expose them to the page, so we filter them out here.
     325    if (m_dataObject->url.isValid() && !m_dataObject->url.isLocalFile()) {
    320326        ASSERT(!m_dataObject->uriList.isEmpty());
    321327        results.add("URL");
     
    323329
    324330    if (!m_dataObject->uriList.isEmpty()) {
    325         // Note that even if the URI list is not empty, it may not actually
    326         // contain a valid URL, so we can't return "URL" here.
    327         results.add("text/uri-list");
     331        // Verify that the URI list contains at least one non-file URL.
     332        for (Vector<String>::const_iterator it = m_dataObject->uriList.begin();
     333             it != m_dataObject->uriList.end(); ++it) {
     334            if (!protocolIs(*it, "file")) {
     335                // Note that even if the URI list is not empty, it may not actually
     336                // contain a valid URL, so we can't return "URL" here.
     337                results.add("text/uri-list");
     338                break;
     339            }
     340        }
    328341    }
    329342
Note: See TracChangeset for help on using the changeset viewer.