| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/pepper/pepper_file_ref_renderer_host.h" | 5 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 PP_Instance instance, | 36 PP_Instance instance, |
| 37 PP_Resource resource, | 37 PP_Resource resource, |
| 38 const base::FilePath& external_path) | 38 const base::FilePath& external_path) |
| 39 : ResourceHost(host->GetPpapiHost(), instance, resource), | 39 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 40 file_system_type_(PP_FILESYSTEMTYPE_EXTERNAL), | 40 file_system_type_(PP_FILESYSTEMTYPE_EXTERNAL), |
| 41 external_path_(external_path) { | 41 external_path_(external_path) { |
| 42 if (!ppapi::IsValidExternalPath(external_path)) | 42 if (!ppapi::IsValidExternalPath(external_path)) |
| 43 file_system_type_ = PP_FILESYSTEMTYPE_INVALID; | 43 file_system_type_ = PP_FILESYSTEMTYPE_INVALID; |
| 44 } | 44 } |
| 45 | 45 |
| 46 PepperFileRefRendererHost::~PepperFileRefRendererHost() { | 46 PepperFileRefRendererHost::~PepperFileRefRendererHost() {} |
| 47 } | |
| 48 | 47 |
| 49 PP_FileSystemType PepperFileRefRendererHost::GetFileSystemType() const { | 48 PP_FileSystemType PepperFileRefRendererHost::GetFileSystemType() const { |
| 50 return file_system_type_; | 49 return file_system_type_; |
| 51 } | 50 } |
| 52 | 51 |
| 53 GURL PepperFileRefRendererHost::GetFileSystemURL() const { | 52 GURL PepperFileRefRendererHost::GetFileSystemURL() const { |
| 54 if (fs_host_.get() && fs_host_->IsOpened() && | 53 if (fs_host_.get() && fs_host_->IsOpened() && |
| 55 fs_host_->GetRootUrl().is_valid()) { | 54 fs_host_->GetRootUrl().is_valid()) { |
| 56 CHECK(!internal_path_.empty() && internal_path_[0] == '/'); | 55 CHECK(!internal_path_.empty() && internal_path_[0] == '/'); |
| 57 // We strip off the leading slash when passing the URL to Resolve(). | 56 // We strip off the leading slash when passing the URL to Resolve(). |
| 58 // Internal paths are required to be absolute, so we can require this. | 57 // Internal paths are required to be absolute, so we can require this. |
| 59 return fs_host_->GetRootUrl().Resolve( | 58 return fs_host_->GetRootUrl().Resolve( |
| 60 net::EscapePath(internal_path_.substr(1))); | 59 net::EscapePath(internal_path_.substr(1))); |
| 61 } | 60 } |
| 62 return GURL(); | 61 return GURL(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 base::FilePath PepperFileRefRendererHost::GetExternalFilePath() const { | 64 base::FilePath PepperFileRefRendererHost::GetExternalFilePath() const { |
| 66 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) | 65 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) |
| 67 return base::FilePath(); | 66 return base::FilePath(); |
| 68 return external_path_; | 67 return external_path_; |
| 69 } | 68 } |
| 70 | 69 |
| 71 int32_t PepperFileRefRendererHost::OnResourceMessageReceived( | 70 int32_t PepperFileRefRendererHost::OnResourceMessageReceived( |
| 72 const IPC::Message& msg, | 71 const IPC::Message& msg, |
| 73 ppapi::host::HostMessageContext* context) { | 72 ppapi::host::HostMessageContext* context) { |
| 74 // We don't handle any messages from the plugin in this host. | 73 // We don't handle any messages from the plugin in this host. |
| 75 NOTREACHED(); | 74 NOTREACHED(); |
| 76 return PP_ERROR_FAILED; | 75 return PP_ERROR_FAILED; |
| 77 } | 76 } |
| 78 | 77 |
| 79 bool PepperFileRefRendererHost::IsFileRefHost() { | 78 bool PepperFileRefRendererHost::IsFileRefHost() { return true; } |
| 80 return true; | |
| 81 } | |
| 82 | 79 |
| 83 } // namespace content | 80 } // namespace content |
| OLD | NEW |