| OLD | NEW |
| 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/plugins/ppapi/ppb_file_ref_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 6 | 6 |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 const std::string& path) { | 170 const std::string& path) { |
| 171 PluginInstance* plugin_instance = | 171 PluginInstance* plugin_instance = |
| 172 ResourceHelper::PPInstanceToPluginInstance(instance); | 172 ResourceHelper::PPInstanceToPluginInstance(instance); |
| 173 if (!plugin_instance || !plugin_instance->delegate()) | 173 if (!plugin_instance || !plugin_instance->delegate()) |
| 174 return 0; | 174 return 0; |
| 175 | 175 |
| 176 PP_FileSystemType type = | 176 PP_FileSystemType type = |
| 177 plugin_instance->delegate()->GetFileSystemType(instance, pp_file_system); | 177 plugin_instance->delegate()->GetFileSystemType(instance, pp_file_system); |
| 178 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && | 178 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
| 179 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && | 179 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
| 180 type != PP_FILESYSTEMTYPE_EXTERNAL) | 180 type != PP_FILESYSTEMTYPE_EXTERNAL && |
| 181 type != PP_FILESYSTEMTYPE_ISOLATED) |
| 181 return 0; | 182 return 0; |
| 182 | 183 |
| 183 PPB_FileRef_CreateInfo info; | 184 PPB_FileRef_CreateInfo info; |
| 184 info.resource = HostResource::MakeInstanceOnly(instance); | 185 info.resource = HostResource::MakeInstanceOnly(instance); |
| 185 info.file_system_plugin_resource = pp_file_system; | 186 info.file_system_plugin_resource = pp_file_system; |
| 186 info.file_system_type = type; | 187 info.file_system_type = type; |
| 187 | 188 |
| 188 // Validate the path. | 189 // Validate the path. |
| 189 info.path = path; | 190 info.path = path; |
| 190 if (!IsValidLocalPath(info.path)) | 191 if (!IsValidLocalPath(info.path)) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) { | 325 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) { |
| 325 NOTREACHED(); | 326 NOTREACHED(); |
| 326 return base::FilePath(); | 327 return base::FilePath(); |
| 327 } | 328 } |
| 328 return external_file_system_path_; | 329 return external_file_system_path_; |
| 329 } | 330 } |
| 330 | 331 |
| 331 GURL PPB_FileRef_Impl::GetFileSystemURL() const { | 332 GURL PPB_FileRef_Impl::GetFileSystemURL() const { |
| 332 if (GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALPERSISTENT && | 333 if (GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
| 333 GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY && | 334 GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
| 334 GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) { | 335 GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL && |
| 336 GetFileSystemType() != PP_FILESYSTEMTYPE_ISOLATED) { |
| 335 NOTREACHED(); | 337 NOTREACHED(); |
| 336 return GURL(); | 338 return GURL(); |
| 337 } | 339 } |
| 338 | 340 |
| 339 const std::string& virtual_path = GetCreateInfo().path; | 341 const std::string& virtual_path = GetCreateInfo().path; |
| 340 CHECK(!virtual_path.empty()); // Should always be at least "/". | 342 CHECK(!virtual_path.empty()); // Should always be at least "/". |
| 341 | 343 |
| 342 // Since |virtual_path_| starts with a '/', it looks like an absolute path. | 344 // Since |virtual_path_| starts with a '/', it looks like an absolute path. |
| 343 // We need to trim off the '/' before calling Resolve, as FileSystem URLs | 345 // We need to trim off the '/' before calling Resolve, as FileSystem URLs |
| 344 // start with a storage type identifier that looks like a path segment. | 346 // start with a storage type identifier that looks like a path segment. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 delegate->GetFileSystemType(pp_instance(), | 407 delegate->GetFileSystemType(pp_instance(), |
| 406 file_system_)))) | 408 file_system_)))) |
| 407 return PP_ERROR_FAILED; | 409 return PP_ERROR_FAILED; |
| 408 | 410 |
| 409 } | 411 } |
| 410 return PP_OK_COMPLETIONPENDING; | 412 return PP_OK_COMPLETIONPENDING; |
| 411 } | 413 } |
| 412 | 414 |
| 413 } // namespace ppapi | 415 } // namespace ppapi |
| 414 } // namespace webkit | 416 } // namespace webkit |
| OLD | NEW |