OLD | NEW |
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 // The URL could have been cobbled together from any highlighted text string, | 613 // The URL could have been cobbled together from any highlighted text string, |
614 // and can't be interpreted as a capability. | 614 // and can't be interpreted as a capability. |
615 DropData filtered_data(drop_data); | 615 DropData filtered_data(drop_data); |
616 GetProcess()->FilterURL(true, &filtered_data.url); | 616 GetProcess()->FilterURL(true, &filtered_data.url); |
617 if (drop_data.did_originate_from_renderer) { | 617 if (drop_data.did_originate_from_renderer) { |
618 filtered_data.filenames.clear(); | 618 filtered_data.filenames.clear(); |
619 } | 619 } |
620 | 620 |
621 // The filenames vector, on the other hand, does represent a capability to | 621 // The filenames vector, on the other hand, does represent a capability to |
622 // access the given files. | 622 // access the given files. |
623 fileapi::IsolatedContext::FileInfoSet files; | 623 storage::IsolatedContext::FileInfoSet files; |
624 for (std::vector<ui::FileInfo>::iterator iter( | 624 for (std::vector<ui::FileInfo>::iterator iter( |
625 filtered_data.filenames.begin()); | 625 filtered_data.filenames.begin()); |
626 iter != filtered_data.filenames.end(); | 626 iter != filtered_data.filenames.end(); |
627 ++iter) { | 627 ++iter) { |
628 // A dragged file may wind up as the value of an input element, or it | 628 // A dragged file may wind up as the value of an input element, or it |
629 // may be used as the target of a navigation instead. We don't know | 629 // may be used as the target of a navigation instead. We don't know |
630 // which will happen at this point, so generously grant both access | 630 // which will happen at this point, so generously grant both access |
631 // and request permissions to the specific file to cover both cases. | 631 // and request permissions to the specific file to cover both cases. |
632 // We do not give it the permission to request all file:// URLs. | 632 // We do not give it the permission to request all file:// URLs. |
633 | 633 |
(...skipping 12 matching lines...) Expand all Loading... |
646 // If the renderer already has permission to read these paths, we don't need | 646 // If the renderer already has permission to read these paths, we don't need |
647 // to re-grant them. This prevents problems with DnD for files in the CrOS | 647 // to re-grant them. This prevents problems with DnD for files in the CrOS |
648 // file manager--the file manager already had read/write access to those | 648 // file manager--the file manager already had read/write access to those |
649 // directories, but dragging a file would cause the read/write access to be | 649 // directories, but dragging a file would cause the read/write access to be |
650 // overwritten with read-only access, making them impossible to delete or | 650 // overwritten with read-only access, making them impossible to delete or |
651 // rename until the renderer was killed. | 651 // rename until the renderer was killed. |
652 if (!policy->CanReadFile(renderer_id, iter->path)) | 652 if (!policy->CanReadFile(renderer_id, iter->path)) |
653 policy->GrantReadFile(renderer_id, iter->path); | 653 policy->GrantReadFile(renderer_id, iter->path); |
654 } | 654 } |
655 | 655 |
656 fileapi::IsolatedContext* isolated_context = | 656 storage::IsolatedContext* isolated_context = |
657 fileapi::IsolatedContext::GetInstance(); | 657 storage::IsolatedContext::GetInstance(); |
658 DCHECK(isolated_context); | 658 DCHECK(isolated_context); |
659 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( | 659 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( |
660 files); | 660 files); |
661 if (!filesystem_id.empty()) { | 661 if (!filesystem_id.empty()) { |
662 // Grant the permission iff the ID is valid. | 662 // Grant the permission iff the ID is valid. |
663 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 663 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
664 } | 664 } |
665 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id); | 665 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id); |
666 | 666 |
667 fileapi::FileSystemContext* file_system_context = | 667 storage::FileSystemContext* file_system_context = |
668 BrowserContext::GetStoragePartition( | 668 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), |
669 GetProcess()->GetBrowserContext(), | 669 GetSiteInstance()) |
670 GetSiteInstance())->GetFileSystemContext(); | 670 ->GetFileSystemContext(); |
671 for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) { | 671 for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) { |
672 fileapi::FileSystemURL file_system_url = | 672 storage::FileSystemURL file_system_url = |
673 file_system_context->CrackURL(filtered_data.file_system_files[i].url); | 673 file_system_context->CrackURL(filtered_data.file_system_files[i].url); |
674 | 674 |
675 std::string register_name; | 675 std::string register_name; |
676 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( | 676 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( |
677 file_system_url.type(), file_system_url.filesystem_id(), | 677 file_system_url.type(), file_system_url.filesystem_id(), |
678 file_system_url.path(), ®ister_name); | 678 file_system_url.path(), ®ister_name); |
679 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 679 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
680 | 680 |
681 // Note: We are using the origin URL provided by the sender here. It may be | 681 // Note: We are using the origin URL provided by the sender here. It may be |
682 // different from the receiver's. | 682 // different from the receiver's. |
683 filtered_data.file_system_files[i].url = GURL( | 683 filtered_data.file_system_files[i].url = |
684 fileapi::GetIsolatedFileSystemRootURIString( | 684 GURL(storage::GetIsolatedFileSystemRootURIString( |
685 file_system_url.origin(), | 685 file_system_url.origin(), filesystem_id, std::string()) |
686 filesystem_id, | 686 .append(register_name)); |
687 std::string()).append(register_name)); | |
688 } | 687 } |
689 | 688 |
690 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, | 689 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, |
691 screen_pt, operations_allowed, | 690 screen_pt, operations_allowed, |
692 key_modifiers)); | 691 key_modifiers)); |
693 } | 692 } |
694 | 693 |
695 void RenderViewHostImpl::DragTargetDragOver( | 694 void RenderViewHostImpl::DragTargetDragOver( |
696 const gfx::Point& client_pt, | 695 const gfx::Point& client_pt, |
697 const gfx::Point& screen_pt, | 696 const gfx::Point& screen_pt, |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 // renderer for any file paths in the drop. | 1151 // renderer for any file paths in the drop. |
1153 filtered_data.filenames.clear(); | 1152 filtered_data.filenames.clear(); |
1154 for (std::vector<ui::FileInfo>::const_iterator it = | 1153 for (std::vector<ui::FileInfo>::const_iterator it = |
1155 drop_data.filenames.begin(); | 1154 drop_data.filenames.begin(); |
1156 it != drop_data.filenames.end(); | 1155 it != drop_data.filenames.end(); |
1157 ++it) { | 1156 ++it) { |
1158 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) | 1157 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) |
1159 filtered_data.filenames.push_back(*it); | 1158 filtered_data.filenames.push_back(*it); |
1160 } | 1159 } |
1161 | 1160 |
1162 fileapi::FileSystemContext* file_system_context = | 1161 storage::FileSystemContext* file_system_context = |
1163 BrowserContext::GetStoragePartition( | 1162 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), |
1164 GetProcess()->GetBrowserContext(), | 1163 GetSiteInstance()) |
1165 GetSiteInstance())->GetFileSystemContext(); | 1164 ->GetFileSystemContext(); |
1166 filtered_data.file_system_files.clear(); | 1165 filtered_data.file_system_files.clear(); |
1167 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) { | 1166 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) { |
1168 fileapi::FileSystemURL file_system_url = | 1167 storage::FileSystemURL file_system_url = |
1169 file_system_context->CrackURL(drop_data.file_system_files[i].url); | 1168 file_system_context->CrackURL(drop_data.file_system_files[i].url); |
1170 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) | 1169 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) |
1171 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]); | 1170 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]); |
1172 } | 1171 } |
1173 | 1172 |
1174 float scale = GetScaleFactorForView(GetView()); | 1173 float scale = GetScaleFactorForView(GetView()); |
1175 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); | 1174 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); |
1176 view->StartDragging(filtered_data, drag_operations_mask, image, | 1175 view->StartDragging(filtered_data, drag_operations_mask, image, |
1177 bitmap_offset_in_dip, event_info); | 1176 bitmap_offset_in_dip, event_info); |
1178 } | 1177 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1523 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1525 | 1524 |
1526 frame_tree->ResetForMainFrameSwap(); | 1525 frame_tree->ResetForMainFrameSwap(); |
1527 } | 1526 } |
1528 | 1527 |
1529 void RenderViewHostImpl::SelectWordAroundCaret() { | 1528 void RenderViewHostImpl::SelectWordAroundCaret() { |
1530 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1529 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1531 } | 1530 } |
1532 | 1531 |
1533 } // namespace content | 1532 } // namespace content |
OLD | NEW |