| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_system_host.h" | 5 #include "content/renderer/pepper/pepper_file_system_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/child/child_thread.h" | 9 #include "content/child/child_thread.h" |
| 10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
| 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "content/public/renderer/renderer_ppapi_host.h" | 13 #include "content/public/renderer/renderer_ppapi_host.h" |
| 14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
| 15 #include "ppapi/host/dispatch_host_message.h" | 15 #include "ppapi/host/dispatch_host_message.h" |
| 16 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
| 18 #include "ppapi/shared_impl/file_system_util.h" | 18 #include "ppapi/shared_impl/file_system_util.h" |
| 19 #include "ppapi/shared_impl/file_type_conversion.h" | 19 #include "ppapi/shared_impl/file_type_conversion.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
| 22 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
| 23 #include "webkit/common/fileapi/file_system_util.h" | 23 #include "webkit/common/fileapi/file_system_util.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 namespace { | |
| 28 | |
| 29 // TODO(nhiroki): Move this function somewhere else to be shared. | |
| 30 std::string IsolatedFileSystemTypeToRootName( | |
| 31 PP_IsolatedFileSystemType_Private type) { | |
| 32 switch (type) { | |
| 33 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID: | |
| 34 break; | |
| 35 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX: | |
| 36 return "crxfs"; | |
| 37 } | |
| 38 NOTREACHED() << type; | |
| 39 return std::string(); | |
| 40 } | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, | 27 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, |
| 45 PP_Instance instance, | 28 PP_Instance instance, |
| 46 PP_Resource resource, | 29 PP_Resource resource, |
| 47 PP_FileSystemType type) | 30 PP_FileSystemType type) |
| 48 : ResourceHost(host->GetPpapiHost(), instance, resource), | 31 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 49 renderer_ppapi_host_(host), | 32 renderer_ppapi_host_(host), |
| 50 type_(type), | 33 type_(type), |
| 51 opened_(false), | 34 opened_(false), |
| 52 called_open_(false), | 35 called_open_(false), |
| 53 weak_factory_(this) { | 36 weak_factory_(this) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Do a sanity check. | 132 // Do a sanity check. |
| 150 if (!fileapi::ValidateIsolatedFileSystemId(fsid)) | 133 if (!fileapi::ValidateIsolatedFileSystemId(fsid)) |
| 151 return PP_ERROR_BADARGUMENT; | 134 return PP_ERROR_BADARGUMENT; |
| 152 | 135 |
| 153 RenderView* view = | 136 RenderView* view = |
| 154 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); | 137 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); |
| 155 if (!view) | 138 if (!view) |
| 156 return PP_ERROR_FAILED; | 139 return PP_ERROR_FAILED; |
| 157 | 140 |
| 158 const GURL& url = view->GetWebView()->mainFrame()->document().url(); | 141 const GURL& url = view->GetWebView()->mainFrame()->document().url(); |
| 159 const std::string root_name = IsolatedFileSystemTypeToRootName(type); | 142 const std::string root_name = ppapi::IsolatedFileSystemTypeToRootName(type); |
| 160 if (root_name.empty()) | 143 if (root_name.empty()) |
| 161 return PP_ERROR_BADARGUMENT; | 144 return PP_ERROR_BADARGUMENT; |
| 162 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( | 145 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( |
| 163 url.GetOrigin(), fsid, root_name)); | 146 url.GetOrigin(), fsid, root_name)); |
| 164 opened_ = true; | 147 opened_ = true; |
| 165 return PP_OK; | 148 return PP_OK; |
| 166 } | 149 } |
| 167 | 150 |
| 168 } // namespace content | 151 } // namespace content |
| OLD | NEW |