[Chromium] Implement file support for DragData.
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2009 21:30:08 +0000 (21:30 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2009 21:30:08 +0000 (21:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=28896

Reviewed by Dimitri Glazkov.

* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::containsCompatibleContent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@47994 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/chromium/DragDataChromium.cpp

index bd5017e..69b984d 100644 (file)
@@ -1,3 +1,15 @@
+2009-09-02  Jian Li  <jianli@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        [Chromium] Implement file support for DragData.
+        https://bugs.webkit.org/show_bug.cgi?id=28896
+
+        * platform/chromium/DragDataChromium.cpp:
+        (WebCore::DragData::containsURL):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::containsCompatibleContent):
+
 2009-09-02  Kevin Watters  <kevinwatters@gmail.com>
 
         Reviewed by Kevin Ollivier.
index eaec025..7ca05e8 100644 (file)
@@ -34,6 +34,7 @@
 #include "Clipboard.h"
 #include "ClipboardChromium.h"
 #include "DocumentFragment.h"
+#include "FileSystem.h"
 #include "KURL.h"
 #include "markup.h"
 #include "NotImplemented.h"
@@ -56,18 +57,25 @@ PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) co
 
 bool DragData::containsURL() const
 {
-    return m_platformDragData->url.isValid();
+    return !asURL().isEmpty();
 }
 
 String DragData::asURL(String* title) const
 {
-    if (!m_platformDragData->url.isValid())
-        return String();
+    String url;
+    if (m_platformDragData->url.isValid())
+        url = m_platformDragData->url.string();
+    else if (m_platformDragData->filenames.size() == 1) {
+        String fileName = m_platformDragData->filenames[0];
+        // FIXME: Add isDirectory to FileSystem so that we can check if it is not a directory.
+        if (fileExists(fileName))
+            url = fileName;
+    }
  
     // |title| can be NULL
     if (title)
         *title = m_platformDragData->urlTitle;
-    return m_platformDragData->url.string();
+    return url;
 }
 
 bool DragData::containsFiles() const
@@ -112,7 +120,8 @@ bool DragData::containsCompatibleContent() const
     return containsPlainText()
         || containsURL()
         || containsHTML(m_platformDragData)
-        || containsColor();
+        || containsColor()
+        || containsFiles();
 }
 
 PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const