Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1585)

Unified Diff: Source/modules/filesystem/DOMFileSystemBase.cpp

Issue 23537011: FileAPI: Add WebFileSystem::resolveURL (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/filesystem/DOMFileSystemBase.cpp
diff --git a/Source/modules/filesystem/DOMFileSystemBase.cpp b/Source/modules/filesystem/DOMFileSystemBase.cpp
index f63b5079e253f4b426f1f783e461923fa5088e05..702405139f474d81a655ccae8f9d3aba54b747f6 100644
--- a/Source/modules/filesystem/DOMFileSystemBase.cpp
+++ b/Source/modules/filesystem/DOMFileSystemBase.cpp
@@ -96,19 +96,34 @@ bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, FileSystemType& type
return false;
String typeString = url.innerURL()->path().substring(1);
- if (typeString == temporaryPathPrefix)
- type = FileSystemTypeTemporary;
- else if (typeString == persistentPathPrefix)
- type = FileSystemTypePersistent;
- else if (typeString == externalPathPrefix)
- type = FileSystemTypeExternal;
- else
+ if (!pathPrefixToFileSystemType(typeString, type))
return false;
filePath = decodeURLEscapeSequences(url.path());
return true;
}
+KURL DOMFileSystemBase::createFileSystemRootURL(const String& origin, FileSystemType type)
+{
+ String typeString;
+ if (type == FileSystemTypeTemporary)
+ typeString = temporaryPathPrefix;
+ else if (type == FileSystemTypePersistent)
+ typeString = persistentPathPrefix;
+ else if (type == FileSystemTypeExternal)
+ typeString = externalPathPrefix;
+ else
+ return KURL();
+
+ StringBuilder result;
+ result.append("filesystem:");
+ result.append(origin);
+ result.append("/");
+ result.append(typeString);
+ result.append("/");
abarth-chromium 2013/09/13 17:33:01 You should use use operator+ as follows: String r
nhiroki 2013/09/16 16:36:07 Done.
+ return KURL(ParsedURLString, result.toString());
+}
+
bool DOMFileSystemBase::supportsToURL() const
{
ASSERT(isValidType(m_type));
@@ -145,6 +160,39 @@ KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const
return url;
}
+bool DOMFileSystemBase::pathToAbsolutePath(FileSystemType type, const EntryBase* base, String path, String& absolutePath)
+{
+ ASSERT(base);
+
+ if (!DOMFilePath::isAbsolute(path))
+ path = DOMFilePath::append(base->fullPath(), path);
+ absolutePath = DOMFilePath::removeExtraParentReferences(path);
+
+ if ((type == FileSystemTypeTemporary || type == FileSystemTypePersistent) && !DOMFilePath::isValidPath(absolutePath))
+ return false;
+ return true;
abarth-chromium 2013/09/13 17:33:01 There's no need to write "return false" or "return
nhiroki 2013/09/16 16:36:07 Done.
+}
+
+bool DOMFileSystemBase::pathPrefixToFileSystemType(const String& pathPrefix, FileSystemType& type)
+{
+ if (pathPrefix == temporaryPathPrefix) {
+ type = FileSystemTypeTemporary;
+ return true;
+ }
+
+ if (pathPrefix == persistentPathPrefix) {
+ type = FileSystemTypePersistent;
+ return true;
+ }
+
+ if (pathPrefix == externalPathPrefix) {
+ type = FileSystemTypeExternal;
+ return true;
+ }
+
+ return false;
+}
+
bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, SynchronousType synchronousType)
{
OwnPtr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::create(successCallback, errorCallback, this));
@@ -182,19 +230,6 @@ static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En
return true;
}
-static bool pathToAbsolutePath(FileSystemType type, const EntryBase* base, String path, String& absolutePath)
-{
- ASSERT(base);
-
- if (!DOMFilePath::isAbsolute(path))
- path = DOMFilePath::append(base->fullPath(), path);
- absolutePath = DOMFilePath::removeExtraParentReferences(path);
-
- if ((type == FileSystemTypeTemporary || type == FileSystemTypePersistent) && !DOMFilePath::isValidPath(absolutePath))
- return false;
- return true;
-}
-
bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, SynchronousType synchronousType)
{
String destinationPath;

Powered by Google App Engine
This is Rietveld 408576698