Commit 8a8b11d5 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58378 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6d26e81d
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):
2010-04-27 Simon Fraser <simon.fraser@apple.com>
 
Reviewed by the inimitable Dan Bernstein.
......@@ -162,11 +162,15 @@ String ClipboardChromium::getData(const String& type, bool& success) const
case ClipboardDataTypeNone:
return String();
// Hack for URLs. file URLs are used internally for drop's default action, but we don't want
// to expose them to the page, so we filter them out here.
case ClipboardDataTypeURIList:
{
String text;
for (size_t i = 0; i < m_dataObject->uriList.size(); ++i) {
const String& uri = m_dataObject->uriList[i];
if (protocolIs(uri, "file"))
continue;
ASSERT(!uri.isEmpty());
if (!text.isEmpty())
text.append(textMIMETypeLineSeparator);
......@@ -180,7 +184,7 @@ String ClipboardChromium::getData(const String& type, bool& success) const
case ClipboardDataTypeURL:
// In case of a previous setData('text/uri-list'), setData() has already
// prepared the 'url' member, so we can just retrieve it here.
if (!m_dataObject->url.isEmpty()) {
if (!m_dataObject->url.isEmpty() && !m_dataObject->url.isLocalFile()) {
success = true;
return m_dataObject->url.string();
}
......@@ -316,15 +320,24 @@ HashSet<String> ClipboardChromium::types() const
if (!m_dataObject->filenames.isEmpty())
results.add("Files");
if (m_dataObject->url.isValid()) {
// Hack for URLs. file URLs are used internally for drop's default action, but we don't want
// to expose them to the page, so we filter them out here.
if (m_dataObject->url.isValid() && !m_dataObject->url.isLocalFile()) {
ASSERT(!m_dataObject->uriList.isEmpty());
results.add("URL");
}
if (!m_dataObject->uriList.isEmpty()) {
// Note that even if the URI list is not empty, it may not actually
// contain a valid URL, so we can't return "URL" here.
results.add("text/uri-list");
// Verify that the URI list contains at least one non-file URL.
for (Vector<String>::const_iterator it = m_dataObject->uriList.begin();
it != m_dataObject->uriList.end(); ++it) {
if (!protocolIs(*it, "file")) {
// Note that even if the URI list is not empty, it may not actually
// contain a valid URL, so we can't return "URL" here.
results.add("text/uri-list");
break;
}
}
}
if (!m_dataObject->plainText.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment