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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "net/url_request/url_request_context_getter.h" | 74 #include "net/url_request/url_request_context_getter.h" |
75 #include "third_party/skia/include/core/SkBitmap.h" | 75 #include "third_party/skia/include/core/SkBitmap.h" |
76 #include "ui/base/touch/touch_device.h" | 76 #include "ui/base/touch/touch_device.h" |
77 #include "ui/base/touch/touch_enabled.h" | 77 #include "ui/base/touch/touch_enabled.h" |
78 #include "ui/base/ui_base_switches.h" | 78 #include "ui/base/ui_base_switches.h" |
79 #include "ui/gfx/image/image_skia.h" | 79 #include "ui/gfx/image/image_skia.h" |
80 #include "ui/gfx/native_widget_types.h" | 80 #include "ui/gfx/native_widget_types.h" |
81 #include "ui/native_theme/native_theme_switches.h" | 81 #include "ui/native_theme/native_theme_switches.h" |
82 #include "ui/shell_dialogs/selected_file_info.h" | 82 #include "ui/shell_dialogs/selected_file_info.h" |
83 #include "url/url_constants.h" | 83 #include "url/url_constants.h" |
84 #include "webkit/browser/fileapi/isolated_context.h" | 84 #include "storage/browser/fileapi/isolated_context.h" |
85 | 85 |
86 #if defined(OS_MACOSX) | 86 #if defined(OS_MACOSX) |
87 #include "content/browser/renderer_host/popup_menu_helper_mac.h" | 87 #include "content/browser/renderer_host/popup_menu_helper_mac.h" |
88 #elif defined(OS_WIN) | 88 #elif defined(OS_WIN) |
89 #include "base/win/win_util.h" | 89 #include "base/win/win_util.h" |
90 #endif | 90 #endif |
91 | 91 |
92 #if defined(ENABLE_BROWSER_CDMS) | 92 #if defined(ENABLE_BROWSER_CDMS) |
93 #include "content/browser/media/media_web_contents_observer.h" | 93 #include "content/browser/media/media_web_contents_observer.h" |
94 #endif | 94 #endif |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 // The URL could have been cobbled together from any highlighted text string, | 639 // The URL could have been cobbled together from any highlighted text string, |
640 // and can't be interpreted as a capability. | 640 // and can't be interpreted as a capability. |
641 DropData filtered_data(drop_data); | 641 DropData filtered_data(drop_data); |
642 GetProcess()->FilterURL(true, &filtered_data.url); | 642 GetProcess()->FilterURL(true, &filtered_data.url); |
643 if (drop_data.did_originate_from_renderer) { | 643 if (drop_data.did_originate_from_renderer) { |
644 filtered_data.filenames.clear(); | 644 filtered_data.filenames.clear(); |
645 } | 645 } |
646 | 646 |
647 // The filenames vector, on the other hand, does represent a capability to | 647 // The filenames vector, on the other hand, does represent a capability to |
648 // access the given files. | 648 // access the given files. |
649 fileapi::IsolatedContext::FileInfoSet files; | 649 storage::IsolatedContext::FileInfoSet files; |
650 for (std::vector<ui::FileInfo>::iterator iter( | 650 for (std::vector<ui::FileInfo>::iterator iter( |
651 filtered_data.filenames.begin()); | 651 filtered_data.filenames.begin()); |
652 iter != filtered_data.filenames.end(); | 652 iter != filtered_data.filenames.end(); |
653 ++iter) { | 653 ++iter) { |
654 // A dragged file may wind up as the value of an input element, or it | 654 // A dragged file may wind up as the value of an input element, or it |
655 // may be used as the target of a navigation instead. We don't know | 655 // may be used as the target of a navigation instead. We don't know |
656 // which will happen at this point, so generously grant both access | 656 // which will happen at this point, so generously grant both access |
657 // and request permissions to the specific file to cover both cases. | 657 // and request permissions to the specific file to cover both cases. |
658 // We do not give it the permission to request all file:// URLs. | 658 // We do not give it the permission to request all file:// URLs. |
659 | 659 |
(...skipping 12 matching lines...) Expand all Loading... |
672 // If the renderer already has permission to read these paths, we don't need | 672 // If the renderer already has permission to read these paths, we don't need |
673 // to re-grant them. This prevents problems with DnD for files in the CrOS | 673 // to re-grant them. This prevents problems with DnD for files in the CrOS |
674 // file manager--the file manager already had read/write access to those | 674 // file manager--the file manager already had read/write access to those |
675 // directories, but dragging a file would cause the read/write access to be | 675 // directories, but dragging a file would cause the read/write access to be |
676 // overwritten with read-only access, making them impossible to delete or | 676 // overwritten with read-only access, making them impossible to delete or |
677 // rename until the renderer was killed. | 677 // rename until the renderer was killed. |
678 if (!policy->CanReadFile(renderer_id, iter->path)) | 678 if (!policy->CanReadFile(renderer_id, iter->path)) |
679 policy->GrantReadFile(renderer_id, iter->path); | 679 policy->GrantReadFile(renderer_id, iter->path); |
680 } | 680 } |
681 | 681 |
682 fileapi::IsolatedContext* isolated_context = | 682 storage::IsolatedContext* isolated_context = |
683 fileapi::IsolatedContext::GetInstance(); | 683 storage::IsolatedContext::GetInstance(); |
684 DCHECK(isolated_context); | 684 DCHECK(isolated_context); |
685 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( | 685 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( |
686 files); | 686 files); |
687 if (!filesystem_id.empty()) { | 687 if (!filesystem_id.empty()) { |
688 // Grant the permission iff the ID is valid. | 688 // Grant the permission iff the ID is valid. |
689 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 689 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
690 } | 690 } |
691 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id); | 691 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id); |
692 | 692 |
693 fileapi::FileSystemContext* file_system_context = | 693 storage::FileSystemContext* file_system_context = |
694 BrowserContext::GetStoragePartition( | 694 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), |
695 GetProcess()->GetBrowserContext(), | 695 GetSiteInstance()) |
696 GetSiteInstance())->GetFileSystemContext(); | 696 ->GetFileSystemContext(); |
697 for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) { | 697 for (size_t i = 0; i < filtered_data.file_system_files.size(); ++i) { |
698 fileapi::FileSystemURL file_system_url = | 698 storage::FileSystemURL file_system_url = |
699 file_system_context->CrackURL(filtered_data.file_system_files[i].url); | 699 file_system_context->CrackURL(filtered_data.file_system_files[i].url); |
700 | 700 |
701 std::string register_name; | 701 std::string register_name; |
702 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( | 702 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( |
703 file_system_url.type(), file_system_url.filesystem_id(), | 703 file_system_url.type(), file_system_url.filesystem_id(), |
704 file_system_url.path(), ®ister_name); | 704 file_system_url.path(), ®ister_name); |
705 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 705 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
706 | 706 |
707 // Note: We are using the origin URL provided by the sender here. It may be | 707 // Note: We are using the origin URL provided by the sender here. It may be |
708 // different from the receiver's. | 708 // different from the receiver's. |
709 filtered_data.file_system_files[i].url = GURL( | 709 filtered_data.file_system_files[i].url = |
710 fileapi::GetIsolatedFileSystemRootURIString( | 710 GURL(storage::GetIsolatedFileSystemRootURIString( |
711 file_system_url.origin(), | 711 file_system_url.origin(), filesystem_id, std::string()) |
712 filesystem_id, | 712 .append(register_name)); |
713 std::string()).append(register_name)); | |
714 } | 713 } |
715 | 714 |
716 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, | 715 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, |
717 screen_pt, operations_allowed, | 716 screen_pt, operations_allowed, |
718 key_modifiers)); | 717 key_modifiers)); |
719 } | 718 } |
720 | 719 |
721 void RenderViewHostImpl::DragTargetDragOver( | 720 void RenderViewHostImpl::DragTargetDragOver( |
722 const gfx::Point& client_pt, | 721 const gfx::Point& client_pt, |
723 const gfx::Point& screen_pt, | 722 const gfx::Point& screen_pt, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 // renderer for any file paths in the drop. | 1194 // renderer for any file paths in the drop. |
1196 filtered_data.filenames.clear(); | 1195 filtered_data.filenames.clear(); |
1197 for (std::vector<ui::FileInfo>::const_iterator it = | 1196 for (std::vector<ui::FileInfo>::const_iterator it = |
1198 drop_data.filenames.begin(); | 1197 drop_data.filenames.begin(); |
1199 it != drop_data.filenames.end(); | 1198 it != drop_data.filenames.end(); |
1200 ++it) { | 1199 ++it) { |
1201 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) | 1200 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) |
1202 filtered_data.filenames.push_back(*it); | 1201 filtered_data.filenames.push_back(*it); |
1203 } | 1202 } |
1204 | 1203 |
1205 fileapi::FileSystemContext* file_system_context = | 1204 storage::FileSystemContext* file_system_context = |
1206 BrowserContext::GetStoragePartition( | 1205 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), |
1207 GetProcess()->GetBrowserContext(), | 1206 GetSiteInstance()) |
1208 GetSiteInstance())->GetFileSystemContext(); | 1207 ->GetFileSystemContext(); |
1209 filtered_data.file_system_files.clear(); | 1208 filtered_data.file_system_files.clear(); |
1210 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) { | 1209 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) { |
1211 fileapi::FileSystemURL file_system_url = | 1210 storage::FileSystemURL file_system_url = |
1212 file_system_context->CrackURL(drop_data.file_system_files[i].url); | 1211 file_system_context->CrackURL(drop_data.file_system_files[i].url); |
1213 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) | 1212 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) |
1214 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]); | 1213 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]); |
1215 } | 1214 } |
1216 | 1215 |
1217 float scale = GetScaleFactorForView(GetView()); | 1216 float scale = GetScaleFactorForView(GetView()); |
1218 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); | 1217 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); |
1219 view->StartDragging(filtered_data, drag_operations_mask, image, | 1218 view->StartDragging(filtered_data, drag_operations_mask, image, |
1220 bitmap_offset_in_dip, event_info); | 1219 bitmap_offset_in_dip, event_info); |
1221 } | 1220 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1567 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1569 | 1568 |
1570 frame_tree->ResetForMainFrameSwap(); | 1569 frame_tree->ResetForMainFrameSwap(); |
1571 } | 1570 } |
1572 | 1571 |
1573 void RenderViewHostImpl::SelectWordAroundCaret() { | 1572 void RenderViewHostImpl::SelectWordAroundCaret() { |
1574 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1573 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1575 } | 1574 } |
1576 | 1575 |
1577 } // namespace content | 1576 } // namespace content |
OLD | NEW |