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_type_conversion.h" | 18 #include "ppapi/shared_impl/file_type_conversion.h" |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 19 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebElement.h" | |
21 #include "third_party/WebKit/public/web/WebFrame.h" | 20 #include "third_party/WebKit/public/web/WebFrame.h" |
22 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
23 #include "third_party/WebKit/public/web/WebView.h" | 21 #include "third_party/WebKit/public/web/WebView.h" |
24 #include "webkit/common/fileapi/file_system_util.h" | 22 #include "webkit/common/fileapi/file_system_util.h" |
25 | 23 |
26 namespace content { | 24 namespace content { |
27 | 25 |
28 namespace { | 26 namespace { |
29 | 27 |
30 bool LooksLikeAGuid(const std::string& fsid) { | 28 bool LooksLikeAGuid(const std::string& fsid) { |
31 const size_t kExpectedFsIdSize = 32; | 29 const size_t kExpectedFsIdSize = 32; |
32 if (fsid.size() != kExpectedFsIdSize) | 30 if (fsid.size() != kExpectedFsIdSize) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: | 122 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: |
125 file_system_type = fileapi::kFileSystemTypePersistent; | 123 file_system_type = fileapi::kFileSystemTypePersistent; |
126 break; | 124 break; |
127 case PP_FILESYSTEMTYPE_EXTERNAL: | 125 case PP_FILESYSTEMTYPE_EXTERNAL: |
128 file_system_type = fileapi::kFileSystemTypeExternal; | 126 file_system_type = fileapi::kFileSystemTypeExternal; |
129 break; | 127 break; |
130 default: | 128 default: |
131 return PP_ERROR_FAILED; | 129 return PP_ERROR_FAILED; |
132 } | 130 } |
133 | 131 |
134 PepperPluginInstance* plugin_instance = | 132 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); |
135 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 133 if (!document_url.is_valid()) |
136 if (!plugin_instance) | |
137 return PP_ERROR_FAILED; | 134 return PP_ERROR_FAILED; |
138 | 135 |
139 FileSystemDispatcher* file_system_dispatcher = | 136 FileSystemDispatcher* file_system_dispatcher = |
140 ChildThread::current()->file_system_dispatcher(); | 137 ChildThread::current()->file_system_dispatcher(); |
141 reply_context_ = context->MakeReplyMessageContext(); | 138 reply_context_ = context->MakeReplyMessageContext(); |
142 file_system_dispatcher->OpenFileSystem( | 139 file_system_dispatcher->OpenFileSystem( |
143 GURL(plugin_instance->GetContainer()->element().document().url()). | 140 document_url.GetOrigin(), |
144 GetOrigin(), | |
145 file_system_type, | 141 file_system_type, |
146 base::Bind(&PepperFileSystemHost::DidOpenFileSystem, | 142 base::Bind(&PepperFileSystemHost::DidOpenFileSystem, |
147 weak_factory_.GetWeakPtr()), | 143 weak_factory_.GetWeakPtr()), |
148 base::Bind(&PepperFileSystemHost::DidFailOpenFileSystem, | 144 base::Bind(&PepperFileSystemHost::DidFailOpenFileSystem, |
149 weak_factory_.GetWeakPtr())); | 145 weak_factory_.GetWeakPtr())); |
150 return PP_OK_COMPLETIONPENDING; | 146 return PP_OK_COMPLETIONPENDING; |
151 } | 147 } |
152 | 148 |
153 int32_t PepperFileSystemHost::OnHostMsgInitIsolatedFileSystem( | 149 int32_t PepperFileSystemHost::OnHostMsgInitIsolatedFileSystem( |
154 ppapi::host::HostMessageContext* context, | 150 ppapi::host::HostMessageContext* context, |
(...skipping 10 matching lines...) Expand all Loading... |
165 if (!view) | 161 if (!view) |
166 return PP_ERROR_FAILED; | 162 return PP_ERROR_FAILED; |
167 const GURL& url = view->GetWebView()->mainFrame()->document().url(); | 163 const GURL& url = view->GetWebView()->mainFrame()->document().url(); |
168 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( | 164 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( |
169 url.GetOrigin(), fsid, "crxfs")); | 165 url.GetOrigin(), fsid, "crxfs")); |
170 opened_ = true; | 166 opened_ = true; |
171 return PP_OK; | 167 return PP_OK; |
172 } | 168 } |
173 | 169 |
174 } // namespace content | 170 } // namespace content |
OLD | NEW |