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

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

Issue 10572006: Fix GetOriginURLFromIdentifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to using isUnique. Created 8 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
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 std::string GetOriginIdentifierFromURL(const GURL& url) { 198 std::string GetOriginIdentifierFromURL(const GURL& url) {
199 WebKit::WebSecurityOrigin web_security_origin = 199 WebKit::WebSecurityOrigin web_security_origin =
200 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); 200 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec()));
201 return web_security_origin.databaseIdentifier().utf8(); 201 return web_security_origin.databaseIdentifier().utf8();
202 } 202 }
203 203
204 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier) { 204 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier) {
205 WebKit::WebSecurityOrigin web_security_origin = 205 WebKit::WebSecurityOrigin web_security_origin =
206 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( 206 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
207 UTF8ToUTF16(origin_identifier)); 207 UTF8ToUTF16(origin_identifier));
208 GURL origin_url(web_security_origin.toString());
209 208
210 // We need this work-around for file:/// URIs as 209 // We need this work-around for file:/// URIs as
211 // createFromDatabaseIdentifier returns empty origin_url for them. 210 // createFromDatabaseIdentifier returns null origin_url for them.
212 if (origin_url.spec().empty() && 211 if (web_security_origin.isUnique()) {
213 origin_identifier.find("file__") == 0) 212 if (origin_identifier.find("file__") == 0)
214 return GURL("file:///"); 213 return GURL("file:///");
215 return origin_url; 214 return GURL();
215 }
216
217 return GURL(web_security_origin.toString());
216 } 218 }
217 219
218 std::string GetFileSystemTypeString(FileSystemType type) { 220 std::string GetFileSystemTypeString(FileSystemType type) {
219 switch (type) { 221 switch (type) {
220 case kFileSystemTypeTemporary: 222 case kFileSystemTypeTemporary:
221 return fileapi::kTemporaryName; 223 return fileapi::kTemporaryName;
222 case kFileSystemTypePersistent: 224 case kFileSystemTypePersistent:
223 return fileapi::kPersistentName; 225 return fileapi::kPersistentName;
224 case kFileSystemTypeExternal: 226 case kFileSystemTypeExternal:
225 return fileapi::kExternalName; 227 return fileapi::kExternalName;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 308
307 *filesystem_id = filesystem_name.substr(pos + start_token.length(), 309 *filesystem_id = filesystem_name.substr(pos + start_token.length(),
308 std::string::npos); 310 std::string::npos);
309 if (filesystem_id->empty()) 311 if (filesystem_id->empty())
310 return false; 312 return false;
311 313
312 return true; 314 return true;
313 } 315 }
314 316
315 } // namespace fileapi 317 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698