Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 #include "content/public/browser/ax_event_notification_details.h" | 64 #include "content/public/browser/ax_event_notification_details.h" |
| 65 #include "content/public/browser/browser_accessibility_state.h" | 65 #include "content/public/browser/browser_accessibility_state.h" |
| 66 #include "content/public/browser/browser_context.h" | 66 #include "content/public/browser/browser_context.h" |
| 67 #include "content/public/browser/browser_plugin_guest_manager.h" | 67 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 68 #include "content/public/browser/browser_thread.h" | 68 #include "content/public/browser/browser_thread.h" |
| 69 #include "content/public/browser/content_browser_client.h" | 69 #include "content/public/browser/content_browser_client.h" |
| 70 #include "content/public/browser/permission_manager.h" | 70 #include "content/public/browser/permission_manager.h" |
| 71 #include "content/public/browser/permission_type.h" | 71 #include "content/public/browser/permission_type.h" |
| 72 #include "content/public/browser/render_process_host.h" | 72 #include "content/public/browser/render_process_host.h" |
| 73 #include "content/public/browser/render_widget_host_view.h" | 73 #include "content/public/browser/render_widget_host_view.h" |
| 74 #include "content/public/browser/storage_partition.h" | |
| 74 #include "content/public/browser/stream_handle.h" | 75 #include "content/public/browser/stream_handle.h" |
| 75 #include "content/public/browser/user_metrics.h" | 76 #include "content/public/browser/user_metrics.h" |
| 76 #include "content/public/common/browser_side_navigation_policy.h" | 77 #include "content/public/common/browser_side_navigation_policy.h" |
| 77 #include "content/public/common/content_constants.h" | 78 #include "content/public/common/content_constants.h" |
| 78 #include "content/public/common/content_switches.h" | 79 #include "content/public/common/content_switches.h" |
| 79 #include "content/public/common/file_chooser_file_info.h" | 80 #include "content/public/common/file_chooser_file_info.h" |
| 80 #include "content/public/common/file_chooser_params.h" | 81 #include "content/public/common/file_chooser_params.h" |
| 81 #include "content/public/common/isolated_world_ids.h" | 82 #include "content/public/common/isolated_world_ids.h" |
| 82 #include "content/public/common/url_constants.h" | 83 #include "content/public/common/url_constants.h" |
| 83 #include "content/public/common/url_utils.h" | 84 #include "content/public/common/url_utils.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 542 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
| 542 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 543 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
| 543 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 544 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
| 544 OnJavaScriptExecuteResponse) | 545 OnJavaScriptExecuteResponse) |
| 545 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, | 546 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, |
| 546 OnVisualStateResponse) | 547 OnVisualStateResponse) |
| 547 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, | 548 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, |
| 548 OnRunJavaScriptMessage) | 549 OnRunJavaScriptMessage) |
| 549 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, | 550 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, |
| 550 OnRunBeforeUnloadConfirm) | 551 OnRunBeforeUnloadConfirm) |
| 552 IPC_MESSAGE_HANDLER(FrameHostMsg_RunFileChooser, OnRunFileChooser) | |
| 551 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, | 553 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, |
| 552 OnDidAccessInitialDocument) | 554 OnDidAccessInitialDocument) |
| 553 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) | 555 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) |
| 554 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) | 556 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) |
| 555 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAddContentSecurityPolicy, | 557 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAddContentSecurityPolicy, |
| 556 OnDidAddContentSecurityPolicy) | 558 OnDidAddContentSecurityPolicy) |
| 557 IPC_MESSAGE_HANDLER(FrameHostMsg_EnforceInsecureRequestPolicy, | 559 IPC_MESSAGE_HANDLER(FrameHostMsg_EnforceInsecureRequestPolicy, |
| 558 OnEnforceInsecureRequestPolicy) | 560 OnEnforceInsecureRequestPolicy) |
| 559 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateToUniqueOrigin, | 561 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateToUniqueOrigin, |
| 560 OnUpdateToUniqueOrigin) | 562 OnUpdateToUniqueOrigin) |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1518 const GURL& frame_url, | 1520 const GURL& frame_url, |
| 1519 bool is_reload, | 1521 bool is_reload, |
| 1520 IPC::Message* reply_msg) { | 1522 IPC::Message* reply_msg) { |
| 1521 // While a JS beforeunload dialog is showing, tabs in the same process | 1523 // While a JS beforeunload dialog is showing, tabs in the same process |
| 1522 // shouldn't process input events. | 1524 // shouldn't process input events. |
| 1523 GetProcess()->SetIgnoreInputEvents(true); | 1525 GetProcess()->SetIgnoreInputEvents(true); |
| 1524 render_view_host_->GetWidget()->StopHangMonitorTimeout(); | 1526 render_view_host_->GetWidget()->StopHangMonitorTimeout(); |
| 1525 delegate_->RunBeforeUnloadConfirm(this, is_reload, reply_msg); | 1527 delegate_->RunBeforeUnloadConfirm(this, is_reload, reply_msg); |
| 1526 } | 1528 } |
| 1527 | 1529 |
| 1530 void RenderFrameHostImpl::OnRunFileChooser(const FileChooserParams& params) { | |
| 1531 // Do not allow messages with absolute paths in them as this can permit a | |
| 1532 // renderer to coerce the browser to perform I/O on a renderer controlled | |
| 1533 // path. | |
| 1534 if (params.default_file_name != params.default_file_name.BaseName()) { | |
| 1535 bad_message::ReceivedBadMessage(GetProcess(), | |
| 1536 bad_message::RVH_FILE_CHOOSER_PATH); | |
|
Avi (use Gerrit)
2016/06/10 21:52:54
Have we renamed bad messages that we move from RVH
nasko
2016/06/10 22:07:49
I don't know, but it is a good thing to fix. Done.
| |
| 1537 return; | |
| 1538 } | |
| 1539 | |
| 1540 delegate_->RunFileChooser(this, params); | |
| 1541 } | |
| 1542 | |
| 1528 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( | 1543 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( |
| 1529 const base::string16& content, | 1544 const base::string16& content, |
| 1530 uint32_t start_offset, | 1545 uint32_t start_offset, |
| 1531 uint32_t end_offset) { | 1546 uint32_t end_offset) { |
| 1532 render_view_host_->OnTextSurroundingSelectionResponse( | 1547 render_view_host_->OnTextSurroundingSelectionResponse( |
| 1533 content, start_offset, end_offset); | 1548 content, start_offset, end_offset); |
| 1534 } | 1549 } |
| 1535 | 1550 |
| 1536 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 1551 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
| 1537 delegate_->DidAccessInitialDocument(); | 1552 delegate_->DidAccessInitialDocument(); |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2620 | 2635 |
| 2621 int RenderFrameHostImpl::GetProxyCount() { | 2636 int RenderFrameHostImpl::GetProxyCount() { |
| 2622 if (this != frame_tree_node_->current_frame_host()) | 2637 if (this != frame_tree_node_->current_frame_host()) |
| 2623 return 0; | 2638 return 0; |
| 2624 return frame_tree_node_->render_manager()->GetProxyCount(); | 2639 return frame_tree_node_->render_manager()->GetProxyCount(); |
| 2625 } | 2640 } |
| 2626 | 2641 |
| 2627 void RenderFrameHostImpl::FilesSelectedInChooser( | 2642 void RenderFrameHostImpl::FilesSelectedInChooser( |
| 2628 const std::vector<content::FileChooserFileInfo>& files, | 2643 const std::vector<content::FileChooserFileInfo>& files, |
| 2629 FileChooserParams::Mode permissions) { | 2644 FileChooserParams::Mode permissions) { |
| 2630 render_view_host_->FilesSelectedInChooser(files, permissions); | 2645 storage::FileSystemContext* const file_system_context = |
| 2646 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), | |
| 2647 GetSiteInstance()) | |
| 2648 ->GetFileSystemContext(); | |
| 2649 // Grant the security access requested to the given files. | |
| 2650 for (size_t i = 0; i < files.size(); ++i) { | |
|
Avi (use Gerrit)
2016/06/10 21:52:54
for (const auto& file : files)
nasko
2016/06/10 22:07:49
Done.
| |
| 2651 const content::FileChooserFileInfo& file = files[i]; | |
| 2652 if (permissions == FileChooserParams::Save) { | |
| 2653 ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile( | |
| 2654 GetProcess()->GetID(), file.file_path); | |
| 2655 } else { | |
| 2656 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | |
| 2657 GetProcess()->GetID(), file.file_path); | |
| 2658 } | |
| 2659 if (file.file_system_url.is_valid()) { | |
| 2660 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( | |
| 2661 GetProcess()->GetID(), | |
| 2662 file_system_context->CrackURL(file.file_system_url) | |
| 2663 .mount_filesystem_id()); | |
| 2664 } | |
| 2665 } | |
| 2666 | |
| 2667 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); | |
| 2631 } | 2668 } |
| 2632 | 2669 |
| 2633 #if defined(USE_EXTERNAL_POPUP_MENU) | 2670 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 2634 #if defined(OS_MACOSX) | 2671 #if defined(OS_MACOSX) |
| 2635 | 2672 |
| 2636 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { | 2673 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { |
| 2637 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); | 2674 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); |
| 2638 } | 2675 } |
| 2639 | 2676 |
| 2640 void RenderFrameHostImpl::DidCancelPopupMenu() { | 2677 void RenderFrameHostImpl::DidCancelPopupMenu() { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2870 // handler after it's destroyed so it can't run after the RFHI is destroyed. | 2907 // handler after it's destroyed so it can't run after the RFHI is destroyed. |
| 2871 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 2908 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
| 2872 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 2909 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
| 2873 } | 2910 } |
| 2874 | 2911 |
| 2875 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 2912 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
| 2876 web_bluetooth_service_.reset(); | 2913 web_bluetooth_service_.reset(); |
| 2877 } | 2914 } |
| 2878 | 2915 |
| 2879 } // namespace content | 2916 } // namespace content |
| OLD | NEW |