[chromium] DragData::asURL should return file URL.
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Sep 2009 18:13:00 +0000 (18:13 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Sep 2009 18:13:00 +0000 (18:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=29109

Reviewed by David Levin.

Tested by LayoutTests/fast/events/drag-to-navigate.html.

* platform/FileSystem.h:
* platform/chromium/ChromiumBridge.h:
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::asURL):
* platform/chromium/FileSystemChromium.cpp:
(WebCore::getAbsolutePath):
(WebCore::isDirectory):
(WebCore::filePathToURL):

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

WebCore/ChangeLog
WebCore/platform/FileSystem.h
WebCore/platform/chromium/ChromiumBridge.h
WebCore/platform/chromium/DragDataChromium.cpp
WebCore/platform/chromium/FileSystemChromium.cpp

index 90771bc..7b8cda3 100644 (file)
@@ -1,3 +1,21 @@
+2009-09-28  Jian Li  <jianli@chromium.org>
+
+        Reviewed by David Levin.
+
+        [chromium] DragData::asURL should return file URL.
+        https://bugs.webkit.org/show_bug.cgi?id=29109
+
+        Tested by LayoutTests/fast/events/drag-to-navigate.html.
+
+        * platform/FileSystem.h:
+        * platform/chromium/ChromiumBridge.h:
+        * platform/chromium/DragDataChromium.cpp:
+        (WebCore::DragData::asURL):
+        * platform/chromium/FileSystemChromium.cpp:
+        (WebCore::getAbsolutePath):
+        (WebCore::isDirectory):
+        (WebCore::filePathToURL):
+
 2009-09-28  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Reviewed by David Levin.
index 958eb73..110204b 100644 (file)
@@ -49,6 +49,7 @@
 #include <wtf/Platform.h>
 #include <wtf/Vector.h>
 
+#include "KURL.h"
 #include "PlatformString.h"
 
 typedef const struct __CFData* CFDataRef;
@@ -172,6 +173,9 @@ String filenameForDisplay(const String&);
 
 #if PLATFORM(CHROMIUM)
 String pathGetDisplayFileName(const String&);
+String getAbsolutePath(const String&);
+bool isDirectory(const String&);
+KURL filePathToURL(const String&);
 #endif
 
 } // namespace WebCore
index 0505d07..1afcc23 100644 (file)
@@ -96,6 +96,9 @@ namespace WebCore {
         static String directoryName(const String& path);
         static String pathByAppendingComponent(const String& path, const String& component);
         static bool makeAllDirectories(const String& path);
+        static String getAbsolutePath(const String&);
+        static bool isDirectory(const String&);
+        static KURL filePathToURL(const String&);
 
         // Font ---------------------------------------------------------------
 #if PLATFORM(WIN_OS)
index 7ca05e8..4083b80 100644 (file)
@@ -67,9 +67,9 @@ String DragData::asURL(String* title) const
         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;
+        fileName = getAbsolutePath(fileName);
+        if (fileExists(fileName) && !isDirectory(fileName))
+            url = filePathToURL(fileName).string();
     }
  
     // |title| can be NULL
index 30674d9..9e7424d 100644 (file)
@@ -77,4 +77,19 @@ bool fileExists(const String& path)
     return ChromiumBridge::fileExists(path);
 }
 
+String getAbsolutePath(const String& path)
+{
+    return ChromiumBridge::getAbsolutePath(path);
+}
+
+bool isDirectory(const String& path)
+{
+    return ChromiumBridge::isDirectory(path);
+}
+
+KURL filePathToURL(const String& path)
+{
+    return ChromiumBridge::filePathToURL(path);
+}
+
 } // namespace WebCore