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_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
29 #include "base/trace_event/trace_event.h" | 29 #include "base/trace_event/trace_event.h" |
30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
31 #include "cc/base/switches.h" | 31 #include "cc/base/switches.h" |
32 #include "cc/output/compositor_frame.h" | 32 #include "cc/output/compositor_frame.h" |
33 #include "components/display_compositor/host_shared_bitmap_manager.h" | 33 #include "components/display_compositor/host_shared_bitmap_manager.h" |
34 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 34 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
35 #include "content/browser/bad_message.h" | 35 #include "content/browser/bad_message.h" |
36 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 36 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
37 #include "content/browser/child_process_security_policy_impl.h" | 37 #include "content/browser/child_process_security_policy_impl.h" |
| 38 #include "content/browser/fileapi/browser_file_system_helper.h" |
38 #include "content/browser/gpu/compositor_util.h" | 39 #include "content/browser/gpu/compositor_util.h" |
39 #include "content/browser/renderer_host/dip_util.h" | 40 #include "content/browser/renderer_host/dip_util.h" |
40 #include "content/browser/renderer_host/frame_metadata_util.h" | 41 #include "content/browser/renderer_host/frame_metadata_util.h" |
41 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 42 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
42 #include "content/browser/renderer_host/input/input_router_impl.h" | 43 #include "content/browser/renderer_host/input/input_router_impl.h" |
43 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 44 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
44 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 45 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
45 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 46 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
46 #include "content/browser/renderer_host/input/timeout_monitor.h" | 47 #include "content/browser/renderer_host/input/timeout_monitor.h" |
47 #include "content/browser/renderer_host/input/touch_emulator.h" | 48 #include "content/browser/renderer_host/input/touch_emulator.h" |
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 } | 2507 } |
2507 | 2508 |
2508 BrowserAccessibilityManager* | 2509 BrowserAccessibilityManager* |
2509 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2510 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2510 return delegate_ ? | 2511 return delegate_ ? |
2511 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2512 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2512 } | 2513 } |
2513 | 2514 |
2514 void RenderWidgetHostImpl::GrantFileAccessFromDropData(DropData* drop_data) { | 2515 void RenderWidgetHostImpl::GrantFileAccessFromDropData(DropData* drop_data) { |
2515 DCHECK_EQ(GetRoutingID(), drop_data->view_id); | 2516 DCHECK_EQ(GetRoutingID(), drop_data->view_id); |
2516 const int renderer_id = GetProcess()->GetID(); | 2517 RenderProcessHost* process = GetProcess(); |
2517 ChildProcessSecurityPolicyImpl* policy = | 2518 PrepareDropDataForChildProcess( |
2518 ChildProcessSecurityPolicyImpl::GetInstance(); | 2519 drop_data, ChildProcessSecurityPolicyImpl::GetInstance(), |
2519 | 2520 process->GetID(), process->GetStoragePartition()->GetFileSystemContext()); |
2520 #if defined(OS_CHROMEOS) | |
2521 // The externalfile:// scheme is used in Chrome OS to open external files in a | |
2522 // browser tab. | |
2523 if (drop_data->url.SchemeIs(content::kExternalFileScheme)) | |
2524 policy->GrantRequestURL(renderer_id, drop_data->url); | |
2525 #endif | |
2526 | |
2527 // The filenames vector represents a capability to access the given files. | |
2528 storage::IsolatedContext::FileInfoSet files; | |
2529 for (auto& filename : drop_data->filenames) { | |
2530 // Make sure we have the same display_name as the one we register. | |
2531 if (filename.display_name.empty()) { | |
2532 std::string name; | |
2533 files.AddPath(filename.path, &name); | |
2534 filename.display_name = base::FilePath::FromUTF8Unsafe(name); | |
2535 } else { | |
2536 files.AddPathWithName(filename.path, | |
2537 filename.display_name.AsUTF8Unsafe()); | |
2538 } | |
2539 // A dragged file may wind up as the value of an input element, or it | |
2540 // may be used as the target of a navigation instead. We don't know | |
2541 // which will happen at this point, so generously grant both access | |
2542 // and request permissions to the specific file to cover both cases. | |
2543 // We do not give it the permission to request all file:// URLs. | |
2544 policy->GrantRequestSpecificFileURL(renderer_id, | |
2545 net::FilePathToFileURL(filename.path)); | |
2546 | |
2547 // If the renderer already has permission to read these paths, we don't need | |
2548 // to re-grant them. This prevents problems with DnD for files in the CrOS | |
2549 // file manager--the file manager already had read/write access to those | |
2550 // directories, but dragging a file would cause the read/write access to be | |
2551 // overwritten with read-only access, making them impossible to delete or | |
2552 // rename until the renderer was killed. | |
2553 if (!policy->CanReadFile(renderer_id, filename.path)) | |
2554 policy->GrantReadFile(renderer_id, filename.path); | |
2555 } | |
2556 | |
2557 storage::IsolatedContext* isolated_context = | |
2558 storage::IsolatedContext::GetInstance(); | |
2559 DCHECK(isolated_context); | |
2560 | |
2561 if (!files.fileset().empty()) { | |
2562 std::string filesystem_id = | |
2563 isolated_context->RegisterDraggedFileSystem(files); | |
2564 if (!filesystem_id.empty()) { | |
2565 // Grant the permission iff the ID is valid. | |
2566 policy->GrantReadFileSystem(renderer_id, filesystem_id); | |
2567 } | |
2568 drop_data->filesystem_id = base::UTF8ToUTF16(filesystem_id); | |
2569 } | |
2570 | |
2571 storage::FileSystemContext* file_system_context = | |
2572 GetProcess()->GetStoragePartition()->GetFileSystemContext(); | |
2573 for (auto& file_system_file : drop_data->file_system_files) { | |
2574 storage::FileSystemURL file_system_url = | |
2575 file_system_context->CrackURL(file_system_file.url); | |
2576 | |
2577 std::string register_name; | |
2578 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( | |
2579 file_system_url.type(), file_system_url.filesystem_id(), | |
2580 file_system_url.path(), ®ister_name); | |
2581 | |
2582 if (!filesystem_id.empty()) { | |
2583 // Grant the permission iff the ID is valid. | |
2584 policy->GrantReadFileSystem(renderer_id, filesystem_id); | |
2585 } | |
2586 | |
2587 // Note: We are using the origin URL provided by the sender here. It may be | |
2588 // different from the receiver's. | |
2589 file_system_file.url = | |
2590 GURL(storage::GetIsolatedFileSystemRootURIString( | |
2591 file_system_url.origin(), filesystem_id, std::string()) | |
2592 .append(register_name)); | |
2593 file_system_file.filesystem_id = filesystem_id; | |
2594 } | |
2595 } | 2521 } |
2596 | 2522 |
2597 void RenderWidgetHostImpl::RequestCompositionUpdates(bool immediate_request, | 2523 void RenderWidgetHostImpl::RequestCompositionUpdates(bool immediate_request, |
2598 bool monitor_updates) { | 2524 bool monitor_updates) { |
2599 if (!immediate_request && monitor_updates == monitoring_composition_info_) | 2525 if (!immediate_request && monitor_updates == monitoring_composition_info_) |
2600 return; | 2526 return; |
2601 monitoring_composition_info_ = monitor_updates; | 2527 monitoring_composition_info_ = monitor_updates; |
2602 Send(new InputMsg_RequestCompositionUpdates(routing_id_, immediate_request, | 2528 Send(new InputMsg_RequestCompositionUpdates(routing_id_, immediate_request, |
2603 monitor_updates)); | 2529 monitor_updates)); |
2604 } | 2530 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 RenderProcessHost* rph = GetProcess(); | 2657 RenderProcessHost* rph = GetProcess(); |
2732 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); | 2658 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); |
2733 i != messages.end(); ++i) { | 2659 i != messages.end(); ++i) { |
2734 rph->OnMessageReceived(*i); | 2660 rph->OnMessageReceived(*i); |
2735 if (i->dispatch_error()) | 2661 if (i->dispatch_error()) |
2736 rph->OnBadMessageReceived(*i); | 2662 rph->OnBadMessageReceived(*i); |
2737 } | 2663 } |
2738 } | 2664 } |
2739 | 2665 |
2740 } // namespace content | 2666 } // namespace content |
OLD | NEW |