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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/public/browser/browser_accessibility_state.h" 56 #include "content/public/browser/browser_accessibility_state.h"
57 #include "content/public/browser/browser_context.h" 57 #include "content/public/browser/browser_context.h"
58 #include "content/public/browser/browser_message_filter.h" 58 #include "content/public/browser/browser_message_filter.h"
59 #include "content/public/browser/content_browser_client.h" 59 #include "content/public/browser/content_browser_client.h"
60 #include "content/public/browser/native_web_keyboard_event.h" 60 #include "content/public/browser/native_web_keyboard_event.h"
61 #include "content/public/browser/notification_details.h" 61 #include "content/public/browser/notification_details.h"
62 #include "content/public/browser/notification_service.h" 62 #include "content/public/browser/notification_service.h"
63 #include "content/public/browser/notification_types.h" 63 #include "content/public/browser/notification_types.h"
64 #include "content/public/browser/render_frame_host.h" 64 #include "content/public/browser/render_frame_host.h"
65 #include "content/public/browser/render_widget_host_iterator.h" 65 #include "content/public/browser/render_widget_host_iterator.h"
66 #include "content/public/browser/storage_partition.h"
66 #include "content/public/browser/user_metrics.h" 67 #include "content/public/browser/user_metrics.h"
67 #include "content/public/common/bindings_policy.h" 68 #include "content/public/common/bindings_policy.h"
68 #include "content/public/common/content_constants.h" 69 #include "content/public/common/content_constants.h"
69 #include "content/public/common/content_switches.h" 70 #include "content/public/common/content_switches.h"
70 #include "content/public/common/context_menu_params.h" 71 #include "content/public/common/context_menu_params.h"
71 #include "content/public/common/drop_data.h" 72 #include "content/public/common/drop_data.h"
72 #include "content/public/common/result_codes.h" 73 #include "content/public/common/result_codes.h"
73 #include "content/public/common/url_constants.h" 74 #include "content/public/common/url_constants.h"
74 #include "content/public/common/url_utils.h" 75 #include "content/public/common/url_utils.h"
75 #include "net/base/filename_util.h" 76 #include "net/base/filename_util.h"
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 fileapi::IsolatedContext::GetInstance(); 777 fileapi::IsolatedContext::GetInstance();
777 DCHECK(isolated_context); 778 DCHECK(isolated_context);
778 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( 779 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem(
779 files); 780 files);
780 if (!filesystem_id.empty()) { 781 if (!filesystem_id.empty()) {
781 // Grant the permission iff the ID is valid. 782 // Grant the permission iff the ID is valid.
782 policy->GrantReadFileSystem(renderer_id, filesystem_id); 783 policy->GrantReadFileSystem(renderer_id, filesystem_id);
783 } 784 }
784 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id); 785 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id);
785 786
787 fileapi::FileSystemContext* file_system_context =
788 BrowserContext::GetStoragePartition(
789 GetProcess()->GetBrowserContext(),
790 GetSiteInstance())->GetFileSystemContext();
791 for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) {
792 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.
793 file_system_context->CrackURL(filtered_data.file_system_files[i].url);
794
795 std::string register_name;
796 std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
797 file_system_url.type(), file_system_url.path(), &register_name);
798 policy->GrantReadFileSystem(renderer_id, filesystem_id);
799
800 filtered_data.file_system_files[i].url = GURL(
801 fileapi::GetIsolatedFileSystemRootURIString(
802 file_system_url.origin(),
803 filesystem_id,
804 std::string()).append(register_name));
805 }
806
786 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 807 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
787 screen_pt, operations_allowed, 808 screen_pt, operations_allowed,
788 key_modifiers)); 809 key_modifiers));
789 } 810 }
790 811
791 void RenderViewHostImpl::DragTargetDragOver( 812 void RenderViewHostImpl::DragTargetDragOver(
792 const gfx::Point& client_pt, 813 const gfx::Point& client_pt,
793 const gfx::Point& screen_pt, 814 const gfx::Point& screen_pt,
794 WebDragOperationsMask operations_allowed, 815 WebDragOperationsMask operations_allowed,
795 int key_modifiers) { 816 int key_modifiers) {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 // still fire though, which causes read permissions to be granted to the 1380 // still fire though, which causes read permissions to be granted to the
1360 // renderer for any file paths in the drop. 1381 // renderer for any file paths in the drop.
1361 filtered_data.filenames.clear(); 1382 filtered_data.filenames.clear();
1362 for (std::vector<ui::FileInfo>::const_iterator it = 1383 for (std::vector<ui::FileInfo>::const_iterator it =
1363 drop_data.filenames.begin(); 1384 drop_data.filenames.begin();
1364 it != drop_data.filenames.end(); 1385 it != drop_data.filenames.end();
1365 ++it) { 1386 ++it) {
1366 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) 1387 if (policy->CanReadFile(GetProcess()->GetID(), it->path))
1367 filtered_data.filenames.push_back(*it); 1388 filtered_data.filenames.push_back(*it);
1368 } 1389 }
1390
1391 fileapi::FileSystemContext* file_system_context =
1392 BrowserContext::GetStoragePartition(
1393 GetProcess()->GetBrowserContext(),
1394 GetSiteInstance())->GetFileSystemContext();
1395 filtered_data.file_system_files.clear();
1396 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) {
1397 fileapi::FileSystemURL file_system_url =
1398 file_system_context->CrackURL(drop_data.file_system_files[i].url);
1399 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url))
1400 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
1401 }
1402
1369 float scale = ui::GetImageScale(GetScaleFactorForView(GetView())); 1403 float scale = ui::GetImageScale(GetScaleFactorForView(GetView()));
1370 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); 1404 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale));
1371 view->StartDragging(filtered_data, drag_operations_mask, image, 1405 view->StartDragging(filtered_data, drag_operations_mask, image,
1372 bitmap_offset_in_dip, event_info); 1406 bitmap_offset_in_dip, event_info);
1373 } 1407 }
1374 1408
1375 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { 1409 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) {
1376 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 1410 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
1377 if (view) 1411 if (view)
1378 view->UpdateDragCursor(current_op); 1412 view->UpdateDragCursor(current_op);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 return true; 1812 return true;
1779 } 1813 }
1780 1814
1781 void RenderViewHostImpl::AttachToFrameTree() { 1815 void RenderViewHostImpl::AttachToFrameTree() {
1782 FrameTree* frame_tree = delegate_->GetFrameTree(); 1816 FrameTree* frame_tree = delegate_->GetFrameTree();
1783 1817
1784 frame_tree->ResetForMainFrameSwap(); 1818 frame_tree->ResetForMainFrameSwap();
1785 } 1819 }
1786 1820
1787 } // namespace content 1821 } // namespace content
OLDNEW
« 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