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

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

Issue 6904063: String->URL cleanup, chromium-side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary WebURL constructors. Created 9 years, 6 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
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"
(...skipping 18 matching lines...) Expand all
29 29
30 bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, 30 bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type,
31 FilePath* file_path) { 31 FilePath* file_path) {
32 GURL origin; 32 GURL origin;
33 FileSystemType file_system_type; 33 FileSystemType file_system_type;
34 34
35 if (url.scheme() != "filesystem") 35 if (url.scheme() != "filesystem")
36 return false; 36 return false;
37 37
38 std::string temp = url.path(); 38 std::string temp = url.path();
39 // TODO(ericu) remove this code when that ceases to be true, which should be 39 // TODO(ericu) remove this code when that ceases to be true, which will be as
40 // soon. 40 // soon as the WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING macro goes into
41 // WebKit.
41 // On Windows, this will have backslashes for now. 42 // On Windows, this will have backslashes for now.
42 // url will look something like: 43 // url will look something like:
43 // filesystem:http://example.com/temporary/\dir\file.txt 44 // filesystem:http://example.com/temporary/\dir\file.txt
44 // temp will look something like: 45 // temp will look something like:
45 // http://example.com/temporary/\dir\file.txt 46 // http://example.com/temporary/\dir\file.txt
46 // On posix, url will look something like: 47 // On posix, url will look something like:
47 // filesystem:http://example.com/temporary/dir/file.txt 48 // filesystem:http://example.com/temporary/dir/file.txt
48 // temp will look something like: 49 // temp will look something like:
49 // http://example.com/temporary/dir/file.txt 50 // http://example.com/temporary/dir/file.txt
50 size_t pos = temp.find('\\'); 51 size_t pos = temp.find('\\');
51 for (; pos != std::string::npos; pos = temp.find('\\', pos + 1)) { 52 for (; pos != std::string::npos; pos = temp.find('\\', pos + 1)) {
52 temp[pos] = '/'; 53 temp[pos] = '/';
53 } 54 }
54 // TODO(ericu): This should probably be done elsewhere after the stackable 55 // TODO(ericu): This should probably be done elsewhere after the stackable
55 // layers are properly in. We're supposed to reject any paths that contain 56 // layers are properly in. We're supposed to reject any paths that contain
56 // '..' segments, but the GURL constructor is helpfully resolving them for us. 57 // '..' segments, but the GURL constructor is helpfully resolving them for us.
57 // Make sure there aren't any before we call it. 58 // Make sure there aren't any before we call it.
58 pos = temp.find(".."); 59 pos = temp.find("..");
59 for (; pos != std::string::npos; pos = temp.find("..", pos + 1)) { 60 for (; pos != std::string::npos; pos = temp.find("..", pos + 1)) {
60 if ((pos == 0 || temp[pos - 1] == '/') && 61 if ((pos == 0 || temp[pos - 1] == '/') &&
61 (pos == temp.length() - 2 || temp[pos + 2] == '/')) 62 (pos == temp.length() - 2 || temp[pos + 2] == '/'))
62 return false; 63 return false;
63 } 64 }
64 65
65 // bare_url will look something like: 66 // bare_url will look something like:
66 // http://example.com/temporary//dir/file.txt [on Windows; the double slash 67 // http://example.com/temporary/dir/file.txt.
67 // before dir will be single on posix].
68 GURL bare_url(temp); 68 GURL bare_url(temp);
69 69
70 // The input URL was malformed, bail out early. 70 // The input URL was malformed, bail out early.
71 if (bare_url.path().empty()) 71 if (bare_url.path().empty())
72 return false; 72 return false;
73 73
74 origin = bare_url.GetOrigin(); 74 origin = bare_url.GetOrigin();
75 75
76 // The input URL was malformed, bail out early. 76 // The input URL was malformed, bail out early.
77 if (origin.is_empty()) 77 if (origin.is_empty())
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 // We need this work-around for file:/// URIs as 172 // We need this work-around for file:/// URIs as
173 // createFromDatabaseIdentifier returns empty origin_url for them. 173 // createFromDatabaseIdentifier returns empty origin_url for them.
174 if (origin_url.spec().empty() && 174 if (origin_url.spec().empty() &&
175 origin_identifier.find("file__") == 0) 175 origin_identifier.find("file__") == 0)
176 return GURL("file:///"); 176 return GURL("file:///");
177 return origin_url; 177 return origin_url;
178 } 178 }
179 179
180 } // namespace fileapi 180 } // namespace fileapi
OLDNEW
« no previous file with comments | « content/common/file_system/webfilesystem_impl.cc ('k') | webkit/tools/test_shell/simple_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698