| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 // access the given files. | 609 // access the given files. |
| 610 fileapi::IsolatedContext::FileInfoSet files; | 610 fileapi::IsolatedContext::FileInfoSet files; |
| 611 for (std::vector<WebDropData::FileInfo>::iterator iter( | 611 for (std::vector<WebDropData::FileInfo>::iterator iter( |
| 612 filtered_data.filenames.begin()); | 612 filtered_data.filenames.begin()); |
| 613 iter != filtered_data.filenames.end(); ++iter) { | 613 iter != filtered_data.filenames.end(); ++iter) { |
| 614 // A dragged file may wind up as the value of an input element, or it | 614 // A dragged file may wind up as the value of an input element, or it |
| 615 // may be used as the target of a navigation instead. We don't know | 615 // may be used as the target of a navigation instead. We don't know |
| 616 // which will happen at this point, so generously grant both access | 616 // which will happen at this point, so generously grant both access |
| 617 // and request permissions to the specific file to cover both cases. | 617 // and request permissions to the specific file to cover both cases. |
| 618 // We do not give it the permission to request all file:// URLs. | 618 // We do not give it the permission to request all file:// URLs. |
| 619 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); | 619 base::FilePath path = |
| 620 base::FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); |
| 620 | 621 |
| 621 // Make sure we have the same display_name as the one we register. | 622 // Make sure we have the same display_name as the one we register. |
| 622 if (iter->display_name.empty()) { | 623 if (iter->display_name.empty()) { |
| 623 std::string name; | 624 std::string name; |
| 624 files.AddPath(path, &name); | 625 files.AddPath(path, &name); |
| 625 iter->display_name = UTF8ToUTF16(name); | 626 iter->display_name = UTF8ToUTF16(name); |
| 626 } else { | 627 } else { |
| 627 files.AddPathWithName(path, UTF16ToUTF8(iter->display_name)); | 628 files.AddPathWithName(path, UTF16ToUTF8(iter->display_name)); |
| 628 } | 629 } |
| 629 | 630 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 for (size_t i = 0; i < files.size(); ++i) { | 859 for (size_t i = 0; i < files.size(); ++i) { |
| 859 const ui::SelectedFileInfo& file = files[i]; | 860 const ui::SelectedFileInfo& file = files[i]; |
| 860 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( | 861 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( |
| 861 GetProcess()->GetID(), file.local_path, permissions); | 862 GetProcess()->GetID(), file.local_path, permissions); |
| 862 } | 863 } |
| 863 Send(new ViewMsg_RunFileChooserResponse(GetRoutingID(), files)); | 864 Send(new ViewMsg_RunFileChooserResponse(GetRoutingID(), files)); |
| 864 } | 865 } |
| 865 | 866 |
| 866 void RenderViewHostImpl::DirectoryEnumerationFinished( | 867 void RenderViewHostImpl::DirectoryEnumerationFinished( |
| 867 int request_id, | 868 int request_id, |
| 868 const std::vector<FilePath>& files) { | 869 const std::vector<base::FilePath>& files) { |
| 869 // Grant the security access requested to the given files. | 870 // Grant the security access requested to the given files. |
| 870 for (std::vector<FilePath>::const_iterator file = files.begin(); | 871 for (std::vector<base::FilePath>::const_iterator file = files.begin(); |
| 871 file != files.end(); ++file) { | 872 file != files.end(); ++file) { |
| 872 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 873 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 873 GetProcess()->GetID(), *file); | 874 GetProcess()->GetID(), *file); |
| 874 } | 875 } |
| 875 Send(new ViewMsg_EnumerateDirectoryResponse(GetRoutingID(), | 876 Send(new ViewMsg_EnumerateDirectoryResponse(GetRoutingID(), |
| 876 request_id, | 877 request_id, |
| 877 files)); | 878 files)); |
| 878 } | 879 } |
| 879 | 880 |
| 880 void RenderViewHostImpl::LoadStateChanged( | 881 void RenderViewHostImpl::LoadStateChanged( |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it | 1477 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it |
| 1477 // doesn't have read permissions for. | 1478 // doesn't have read permissions for. |
| 1478 // 2. We initiate a native DnD operation. | 1479 // 2. We initiate a native DnD operation. |
| 1479 // 3. DnD operation immediately ends since mouse is not held down. DnD events | 1480 // 3. DnD operation immediately ends since mouse is not held down. DnD events |
| 1480 // still fire though, which causes read permissions to be granted to the | 1481 // still fire though, which causes read permissions to be granted to the |
| 1481 // renderer for any file paths in the drop. | 1482 // renderer for any file paths in the drop. |
| 1482 filtered_data.filenames.clear(); | 1483 filtered_data.filenames.clear(); |
| 1483 for (std::vector<WebDropData::FileInfo>::const_iterator it = | 1484 for (std::vector<WebDropData::FileInfo>::const_iterator it = |
| 1484 drop_data.filenames.begin(); | 1485 drop_data.filenames.begin(); |
| 1485 it != drop_data.filenames.end(); ++it) { | 1486 it != drop_data.filenames.end(); ++it) { |
| 1486 FilePath path(FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->path))); | 1487 base::FilePath path(base::FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->path))); |
| 1487 if (policy->CanReadFile(GetProcess()->GetID(), path)) | 1488 if (policy->CanReadFile(GetProcess()->GetID(), path)) |
| 1488 filtered_data.filenames.push_back(*it); | 1489 filtered_data.filenames.push_back(*it); |
| 1489 } | 1490 } |
| 1490 ui::ScaleFactor scale_factor = GetScaleFactorForView(GetView()); | 1491 ui::ScaleFactor scale_factor = GetScaleFactorForView(GetView()); |
| 1491 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale_factor)); | 1492 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale_factor)); |
| 1492 view->StartDragging(filtered_data, drag_operations_mask, image, | 1493 view->StartDragging(filtered_data, drag_operations_mask, image, |
| 1493 bitmap_offset_in_dip, event_info); | 1494 bitmap_offset_in_dip, event_info); |
| 1494 } | 1495 } |
| 1495 | 1496 |
| 1496 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { | 1497 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 GetRoutingID(), snapshot_id, snapshot_size, png)); | 2071 GetRoutingID(), snapshot_id, snapshot_size, png)); |
| 2071 return; | 2072 return; |
| 2072 } | 2073 } |
| 2073 } | 2074 } |
| 2074 | 2075 |
| 2075 Send(new ViewMsg_WindowSnapshotCompleted( | 2076 Send(new ViewMsg_WindowSnapshotCompleted( |
| 2076 GetRoutingID(), snapshot_id, gfx::Size(), png)); | 2077 GetRoutingID(), snapshot_id, gfx::Size(), png)); |
| 2077 } | 2078 } |
| 2078 | 2079 |
| 2079 } // namespace content | 2080 } // namespace content |
| OLD | NEW |