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

Side by Side Diff: webkit/fileapi/file_system_util.cc

Issue 6810037: File API changes needed for safely passing user selected file entities from the file browser comp... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/file_system_util.h ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_util.h" 5 #include "webkit/fileapi/file_system_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "net/base/escape.h" 13 #include "net/base/escape.h"
14 #include "webkit/fileapi/file_system_types.h" 14 #include "webkit/fileapi/file_system_types.h"
15 15
16 namespace fileapi { 16 namespace fileapi {
17 17
18 static const char kPersistentDir[] = "/persistent/"; 18 const char kPersistentDir[] = "/persistent/";
19 static const char kTemporaryDir[] = "/temporary/"; 19 const char kTemporaryDir[] = "/temporary/";
20 static const char kLocalDir[] = "/local/"; 20 const char kExternalDir[] = "/external/";
21
22 const char kPersistentName[] = "Persistent";
23 const char kTemporaryName[] = "Temporary";
24 const char kExternalName[] = "External";
21 25
22 bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, 26 bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type,
23 FilePath* file_path) { 27 FilePath* file_path) {
24 GURL origin; 28 GURL origin;
25 FileSystemType file_system_type; 29 FileSystemType file_system_type;
26 30
27 if (url.scheme() != "filesystem") 31 if (url.scheme() != "filesystem")
28 return false; 32 return false;
29 33
30 std::string temp = url.path(); 34 std::string temp = url.path();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return false; 74 return false;
71 75
72 std::string path = UnescapeURLComponent(bare_url.path(), 76 std::string path = UnescapeURLComponent(bare_url.path(),
73 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); 77 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
74 if (path.compare(0, strlen(kPersistentDir), kPersistentDir) == 0) { 78 if (path.compare(0, strlen(kPersistentDir), kPersistentDir) == 0) {
75 file_system_type = kFileSystemTypePersistent; 79 file_system_type = kFileSystemTypePersistent;
76 path = path.substr(strlen(kPersistentDir)); 80 path = path.substr(strlen(kPersistentDir));
77 } else if (path.compare(0, strlen(kTemporaryDir), kTemporaryDir) == 0) { 81 } else if (path.compare(0, strlen(kTemporaryDir), kTemporaryDir) == 0) {
78 file_system_type = kFileSystemTypeTemporary; 82 file_system_type = kFileSystemTypeTemporary;
79 path = path.substr(strlen(kTemporaryDir)); 83 path = path.substr(strlen(kTemporaryDir));
80 } else if (path.compare(0, strlen(kLocalDir), kLocalDir) == 0) { 84 } else if (path.compare(0, strlen(kExternalDir), kExternalDir) == 0) {
81 file_system_type = kFileSystemTypeLocal; 85 file_system_type = kFileSystemTypeExternal;
82 path = path.substr(strlen(kLocalDir)); 86 path = path.substr(strlen(kExternalDir));
83 } else { 87 } else {
84 return false; 88 return false;
85 } 89 }
86 90
87 // Ensure the path is relative. 91 // Ensure the path is relative.
88 while (!path.empty() && path[0] == '/') 92 while (!path.empty() && path[0] == '/')
89 path.erase(0, 1); 93 path.erase(0, 1);
90 94
91 if (origin_url) 95 if (origin_url)
92 *origin_url = origin; 96 *origin_url = origin;
(...skipping 14 matching lines...) Expand all
107 const GURL& origin_url, fileapi::FileSystemType type) { 111 const GURL& origin_url, fileapi::FileSystemType type) {
108 std::string path("filesystem:"); 112 std::string path("filesystem:");
109 path += origin_url.spec(); 113 path += origin_url.spec();
110 switch (type) { 114 switch (type) {
111 case kFileSystemTypeTemporary: 115 case kFileSystemTypeTemporary:
112 path += (kTemporaryDir + 1); // We don't want the leading slash. 116 path += (kTemporaryDir + 1); // We don't want the leading slash.
113 break; 117 break;
114 case kFileSystemTypePersistent: 118 case kFileSystemTypePersistent:
115 path += (kPersistentDir + 1); // We don't want the leading slash. 119 path += (kPersistentDir + 1); // We don't want the leading slash.
116 break; 120 break;
117 case kFileSystemTypeLocal: 121 case kFileSystemTypeExternal:
118 path += (kLocalDir + 1); // We don't want the leading slash. 122 path += (kExternalDir + 1); // We don't want the leading slash.
119 break; 123 break;
120 default: 124 default:
121 NOTREACHED(); 125 NOTREACHED();
122 return GURL(); 126 return GURL();
123 } 127 }
124 return GURL(path); 128 return GURL(path);
125 } 129 }
126 130
127 } // namespace fileapi 131 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_util.h ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698