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