| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 iter != filtered_data.filenames.end(); ++iter) { | 535 iter != filtered_data.filenames.end(); ++iter) { |
| 536 // A dragged file may wind up as the value of an input element, or it | 536 // A dragged file may wind up as the value of an input element, or it |
| 537 // may be used as the target of a navigation instead. We don't know | 537 // may be used as the target of a navigation instead. We don't know |
| 538 // which will happen at this point, so generously grant both access | 538 // which will happen at this point, so generously grant both access |
| 539 // and request permissions to the specific file to cover both cases. | 539 // and request permissions to the specific file to cover both cases. |
| 540 // We do not give it the permission to request all file:// URLs. | 540 // We do not give it the permission to request all file:// URLs. |
| 541 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); | 541 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); |
| 542 | 542 |
| 543 // Make sure we have the same display_name as the one we register. | 543 // Make sure we have the same display_name as the one we register. |
| 544 if (iter->display_name.empty()) { | 544 if (iter->display_name.empty()) { |
| 545 std::string name = files.AddPath(path); | 545 std::string name; |
| 546 files.AddPath(path, &name); |
| 546 iter->display_name = UTF8ToUTF16(name); | 547 iter->display_name = UTF8ToUTF16(name); |
| 547 } else { | 548 } else { |
| 548 files.AddPathWithName(path, UTF16ToUTF8(iter->display_name)); | 549 files.AddPathWithName(path, UTF16ToUTF8(iter->display_name)); |
| 549 } | 550 } |
| 550 | 551 |
| 551 policy->GrantRequestSpecificFileURL(renderer_id, | 552 policy->GrantRequestSpecificFileURL(renderer_id, |
| 552 net::FilePathToFileURL(path)); | 553 net::FilePathToFileURL(path)); |
| 553 | 554 |
| 554 // If the renderer already has permission to read these paths, we don't need | 555 // If the renderer already has permission to read these paths, we don't need |
| 555 // to re-grant them. This prevents problems with DnD for files in the CrOS | 556 // to re-grant them. This prevents problems with DnD for files in the CrOS |
| 556 // file manager--the file manager already had read/write access to those | 557 // file manager--the file manager already had read/write access to those |
| 557 // directories, but dragging a file would cause the read/write access to be | 558 // directories, but dragging a file would cause the read/write access to be |
| 558 // overwritten with read-only access, making them impossible to delete or | 559 // overwritten with read-only access, making them impossible to delete or |
| 559 // rename until the renderer was killed. | 560 // rename until the renderer was killed. |
| 560 if (!policy->CanReadFile(renderer_id, path)) { | 561 if (!policy->CanReadFile(renderer_id, path)) { |
| 561 policy->GrantReadFile(renderer_id, path); | 562 policy->GrantReadFile(renderer_id, path); |
| 562 // Allow dragged directories to be enumerated by the child process. | 563 // Allow dragged directories to be enumerated by the child process. |
| 563 // Note that we can't tell a file from a directory at this point. | 564 // Note that we can't tell a file from a directory at this point. |
| 564 policy->GrantReadDirectory(renderer_id, path); | 565 policy->GrantReadDirectory(renderer_id, path); |
| 565 } | 566 } |
| 566 } | 567 } |
| 567 | 568 |
| 568 fileapi::IsolatedContext* isolated_context = | 569 fileapi::IsolatedContext* isolated_context = |
| 569 fileapi::IsolatedContext::GetInstance(); | 570 fileapi::IsolatedContext::GetInstance(); |
| 570 DCHECK(isolated_context); | 571 DCHECK(isolated_context); |
| 571 std::string filesystem_id = isolated_context->RegisterFileSystem(files); | 572 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( |
| 573 files); |
| 572 if (!filesystem_id.empty()) { | 574 if (!filesystem_id.empty()) { |
| 573 // Grant the permission iff the ID is valid. | 575 // Grant the permission iff the ID is valid. |
| 574 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 576 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
| 575 } | 577 } |
| 576 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); | 578 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); |
| 577 | 579 |
| 578 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, | 580 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, |
| 579 screen_pt, operations_allowed, | 581 screen_pt, operations_allowed, |
| 580 key_modifiers)); | 582 key_modifiers)); |
| 581 } | 583 } |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 // can cause navigations to be ignored in OnMsgNavigate. | 1883 // can cause navigations to be ignored in OnMsgNavigate. |
| 1882 is_waiting_for_beforeunload_ack_ = false; | 1884 is_waiting_for_beforeunload_ack_ = false; |
| 1883 is_waiting_for_unload_ack_ = false; | 1885 is_waiting_for_unload_ack_ = false; |
| 1884 } | 1886 } |
| 1885 | 1887 |
| 1886 void RenderViewHostImpl::ClearPowerSaveBlockers() { | 1888 void RenderViewHostImpl::ClearPowerSaveBlockers() { |
| 1887 STLDeleteValues(&power_save_blockers_); | 1889 STLDeleteValues(&power_save_blockers_); |
| 1888 } | 1890 } |
| 1889 | 1891 |
| 1890 } // namespace content | 1892 } // namespace content |
| OLD | NEW |