Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 242643004: Support drag and drop of files with filesystem: URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix SEGV during tests Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_view_host_impl.cc
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index fd4ee683016471bfd86533d4bedc4192abdd02fe..f0ffc4c33b458e519d943844cb3fe6a844ac04a2 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -63,6 +63,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_iterator.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_constants.h"
@@ -783,6 +784,26 @@ void RenderViewHostImpl::DragTargetDragEnter(
}
filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id);
+ fileapi::FileSystemContext* file_system_context =
+ BrowserContext::GetStoragePartition(
+ GetProcess()->GetBrowserContext(),
+ GetSiteInstance())->GetFileSystemContext();
+ for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) {
+ fileapi::FileSystemURL file_system_url =
kinuko 2014/04/21 06:08:27 Could we have a brief comment to note that this UR
hashimoto 2014/04/21 08:12:46 Done.
+ file_system_context->CrackURL(filtered_data.file_system_files[i].url);
+
+ std::string register_name;
+ std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
+ file_system_url.type(), file_system_url.path(), &register_name);
+ policy->GrantReadFileSystem(renderer_id, filesystem_id);
+
+ filtered_data.file_system_files[i].url = GURL(
+ fileapi::GetIsolatedFileSystemRootURIString(
+ file_system_url.origin(),
+ filesystem_id,
+ std::string()).append(register_name));
+ }
+
Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
screen_pt, operations_allowed,
key_modifiers));
@@ -1366,6 +1387,19 @@ void RenderViewHostImpl::OnStartDragging(
if (policy->CanReadFile(GetProcess()->GetID(), it->path))
filtered_data.filenames.push_back(*it);
}
+
+ fileapi::FileSystemContext* file_system_context =
+ BrowserContext::GetStoragePartition(
+ GetProcess()->GetBrowserContext(),
+ GetSiteInstance())->GetFileSystemContext();
+ filtered_data.file_system_files.clear();
+ for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) {
+ fileapi::FileSystemURL file_system_url =
+ file_system_context->CrackURL(drop_data.file_system_files[i].url);
+ if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url))
+ filtered_data.file_system_files.push_back(drop_data.file_system_files[i]);
kinuko 2014/04/21 03:31:39 This is where we start drag operation, is it right
+ }
+
float scale = ui::GetImageScale(GetScaleFactorForView(GetView()));
gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale));
view->StartDragging(filtered_data, drag_operations_mask, image,
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698