| OLD | NEW |
| 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 "base/utf_string_conversions.h" |
| 12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 14 #include "webkit/fileapi/file_system_types.h" | 18 #include "webkit/fileapi/file_system_types.h" |
| 15 | 19 |
| 16 namespace fileapi { | 20 namespace fileapi { |
| 17 | 21 |
| 18 const char kPersistentDir[] = "/persistent/"; | 22 const char kPersistentDir[] = "/persistent/"; |
| 19 const char kTemporaryDir[] = "/temporary/"; | 23 const char kTemporaryDir[] = "/temporary/"; |
| 20 const char kExternalDir[] = "/external/"; | 24 const char kExternalDir[] = "/external/"; |
| 21 | 25 |
| 22 const char kPersistentName[] = "Persistent"; | 26 const char kPersistentName[] = "Persistent"; |
| 23 const char kTemporaryName[] = "Temporary"; | 27 const char kTemporaryName[] = "Temporary"; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 switch (type) { | 148 switch (type) { |
| 145 case kFileSystemTypeTemporary: | 149 case kFileSystemTypeTemporary: |
| 146 return quota::kStorageTypeTemporary; | 150 return quota::kStorageTypeTemporary; |
| 147 case kFileSystemTypePersistent: | 151 case kFileSystemTypePersistent: |
| 148 return quota::kStorageTypePersistent; | 152 return quota::kStorageTypePersistent; |
| 149 default: | 153 default: |
| 150 return quota::kStorageTypeUnknown; | 154 return quota::kStorageTypeUnknown; |
| 151 } | 155 } |
| 152 } | 156 } |
| 153 | 157 |
| 158 // TODO(kinuko): Merge these two methods (conversion methods between |
| 159 // origin url <==> identifier) with the ones in the database module. |
| 160 std::string GetOriginIdentifierFromURL(const GURL& url) { |
| 161 WebKit::WebSecurityOrigin web_security_origin = |
| 162 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); |
| 163 return web_security_origin.databaseIdentifier().utf8(); |
| 164 } |
| 165 |
| 166 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier) { |
| 167 WebKit::WebSecurityOrigin web_security_origin = |
| 168 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( |
| 169 UTF8ToUTF16(origin_identifier)); |
| 170 GURL origin_url(web_security_origin.toString()); |
| 171 |
| 172 // We need this work-around for file:/// URIs as |
| 173 // createFromDatabaseIdentifier returns empty origin_url for them. |
| 174 if (origin_url.spec().empty() && |
| 175 origin_identifier.find("file__") == 0) |
| 176 return GURL("file:///"); |
| 177 return origin_url; |
| 178 } |
| 179 |
| 154 } // namespace fileapi | 180 } // namespace fileapi |
| OLD | NEW |