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

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: Inline ctor & dtor 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 =
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 // Note: We are using the origin URL provided by the sender here. It may be
801 // different from the receiver's.
802 filtered_data.file_system_files[i].url = GURL(
803 fileapi::GetIsolatedFileSystemRootURIString(
804 file_system_url.origin(),
805 filesystem_id,
806 std::string()).append(register_name));
807 }
808
786 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 809 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
787 screen_pt, operations_allowed, 810 screen_pt, operations_allowed,
788 key_modifiers)); 811 key_modifiers));
789 } 812 }
790 813
791 void RenderViewHostImpl::DragTargetDragOver( 814 void RenderViewHostImpl::DragTargetDragOver(
792 const gfx::Point& client_pt, 815 const gfx::Point& client_pt,
793 const gfx::Point& screen_pt, 816 const gfx::Point& screen_pt,
794 WebDragOperationsMask operations_allowed, 817 WebDragOperationsMask operations_allowed,
795 int key_modifiers) { 818 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 1382 // still fire though, which causes read permissions to be granted to the
1360 // renderer for any file paths in the drop. 1383 // renderer for any file paths in the drop.
1361 filtered_data.filenames.clear(); 1384 filtered_data.filenames.clear();
1362 for (std::vector<ui::FileInfo>::const_iterator it = 1385 for (std::vector<ui::FileInfo>::const_iterator it =
1363 drop_data.filenames.begin(); 1386 drop_data.filenames.begin();
1364 it != drop_data.filenames.end(); 1387 it != drop_data.filenames.end();
1365 ++it) { 1388 ++it) {
1366 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) 1389 if (policy->CanReadFile(GetProcess()->GetID(), it->path))
1367 filtered_data.filenames.push_back(*it); 1390 filtered_data.filenames.push_back(*it);
1368 } 1391 }
1392
1393 fileapi::FileSystemContext* file_system_context =
1394 BrowserContext::GetStoragePartition(
1395 GetProcess()->GetBrowserContext(),
1396 GetSiteInstance())->GetFileSystemContext();
1397 filtered_data.file_system_files.clear();
1398 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) {
1399 fileapi::FileSystemURL file_system_url =
1400 file_system_context->CrackURL(drop_data.file_system_files[i].url);
1401 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url))
1402 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]);
1403 }
1404
1369 float scale = ui::GetImageScale(GetScaleFactorForView(GetView())); 1405 float scale = ui::GetImageScale(GetScaleFactorForView(GetView()));
1370 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); 1406 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale));
1371 view->StartDragging(filtered_data, drag_operations_mask, image, 1407 view->StartDragging(filtered_data, drag_operations_mask, image,
1372 bitmap_offset_in_dip, event_info); 1408 bitmap_offset_in_dip, event_info);
1373 } 1409 }
1374 1410
1375 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { 1411 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) {
1376 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 1412 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
1377 if (view) 1413 if (view)
1378 view->UpdateDragCursor(current_op); 1414 view->UpdateDragCursor(current_op);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 return true; 1814 return true;
1779 } 1815 }
1780 1816
1781 void RenderViewHostImpl::AttachToFrameTree() { 1817 void RenderViewHostImpl::AttachToFrameTree() {
1782 FrameTree* frame_tree = delegate_->GetFrameTree(); 1818 FrameTree* frame_tree = delegate_->GetFrameTree();
1783 1819
1784 frame_tree->ResetForMainFrameSwap(); 1820 frame_tree->ResetForMainFrameSwap();
1785 } 1821 }
1786 1822
1787 } // namespace content 1823 } // 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