| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "content/public/browser/resource_context.h" | 79 #include "content/public/browser/resource_context.h" |
| 80 #include "content/public/browser/storage_partition.h" | 80 #include "content/public/browser/storage_partition.h" |
| 81 #include "content/public/browser/stream_handle.h" | 81 #include "content/public/browser/stream_handle.h" |
| 82 #include "content/public/browser/user_metrics.h" | 82 #include "content/public/browser/user_metrics.h" |
| 83 #include "content/public/common/browser_side_navigation_policy.h" | 83 #include "content/public/common/browser_side_navigation_policy.h" |
| 84 #include "content/public/common/content_constants.h" | 84 #include "content/public/common/content_constants.h" |
| 85 #include "content/public/common/content_features.h" | 85 #include "content/public/common/content_features.h" |
| 86 #include "content/public/common/content_switches.h" | 86 #include "content/public/common/content_switches.h" |
| 87 #include "content/public/common/file_chooser_file_info.h" | 87 #include "content/public/common/file_chooser_file_info.h" |
| 88 #include "content/public/common/file_chooser_params.h" | 88 #include "content/public/common/file_chooser_params.h" |
| 89 #include "content/public/common/form_field_data.h" | |
| 90 #include "content/public/common/isolated_world_ids.h" | 89 #include "content/public/common/isolated_world_ids.h" |
| 91 #include "content/public/common/service_manager_connection.h" | 90 #include "content/public/common/service_manager_connection.h" |
| 92 #include "content/public/common/service_names.mojom.h" | 91 #include "content/public/common/service_names.mojom.h" |
| 93 #include "content/public/common/url_constants.h" | 92 #include "content/public/common/url_constants.h" |
| 94 #include "content/public/common/url_utils.h" | 93 #include "content/public/common/url_utils.h" |
| 95 #include "device/generic_sensor/sensor_provider_impl.h" | 94 #include "device/generic_sensor/sensor_provider_impl.h" |
| 96 #include "device/geolocation/geolocation_service_context.h" | 95 #include "device/geolocation/geolocation_service_context.h" |
| 97 #include "device/vibration/vibration_manager_impl.h" | 96 #include "device/vibration/vibration_manager_impl.h" |
| 98 #include "device/wake_lock/wake_lock_service_context.h" | 97 #include "device/wake_lock/wake_lock_service_context.h" |
| 99 #include "media/base/media_switches.h" | 98 #include "media/base/media_switches.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 Send(new FrameMsg_Delete(routing_id_)); | 418 Send(new FrameMsg_Delete(routing_id_)); |
| 420 } | 419 } |
| 421 | 420 |
| 422 // Null out the swapout timer; in crash dumps this member will be null only if | 421 // Null out the swapout timer; in crash dumps this member will be null only if |
| 423 // the dtor has run. (It may also be null in tests.) | 422 // the dtor has run. (It may also be null in tests.) |
| 424 swapout_event_monitor_timeout_.reset(); | 423 swapout_event_monitor_timeout_.reset(); |
| 425 | 424 |
| 426 for (const auto& iter : visual_state_callbacks_) | 425 for (const auto& iter : visual_state_callbacks_) |
| 427 iter.second.Run(false); | 426 iter.second.Run(false); |
| 428 | 427 |
| 429 form_field_data_callbacks_.clear(); | |
| 430 | |
| 431 if (render_widget_host_ && | 428 if (render_widget_host_ && |
| 432 render_widget_host_->owned_by_render_frame_host()) { | 429 render_widget_host_->owned_by_render_frame_host()) { |
| 433 // Shutdown causes the RenderWidgetHost to delete itself. | 430 // Shutdown causes the RenderWidgetHost to delete itself. |
| 434 render_widget_host_->ShutdownAndDestroyWidget(true); | 431 render_widget_host_->ShutdownAndDestroyWidget(true); |
| 435 } | 432 } |
| 436 | 433 |
| 437 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 434 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 438 // the corresponding RenderViewHost if it is no longer needed. | 435 // the corresponding RenderViewHost if it is no longer needed. |
| 439 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); | 436 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); |
| 440 } | 437 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 OnDidChangeSandboxFlags) | 724 OnDidChangeSandboxFlags) |
| 728 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, | 725 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, |
| 729 OnDidChangeFrameOwnerProperties) | 726 OnDidChangeFrameOwnerProperties) |
| 730 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) | 727 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
| 731 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) | 728 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
| 732 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, | 729 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
| 733 OnBeginNavigation) | 730 OnBeginNavigation) |
| 734 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) | 731 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) |
| 735 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 732 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
| 736 OnTextSurroundingSelectionResponse) | 733 OnTextSurroundingSelectionResponse) |
| 737 IPC_MESSAGE_HANDLER(FrameHostMsg_FocusedFormFieldDataResponse, | |
| 738 OnFocusedFormFieldDataResponse) | |
| 739 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 734 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
| 740 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 735 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
| 741 OnAccessibilityLocationChanges) | 736 OnAccessibilityLocationChanges) |
| 742 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, | 737 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
| 743 OnAccessibilityFindInPageResult) | 738 OnAccessibilityFindInPageResult) |
| 744 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult, | 739 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult, |
| 745 OnAccessibilityChildFrameHitTestResult) | 740 OnAccessibilityChildFrameHitTestResult) |
| 746 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, | 741 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, |
| 747 OnAccessibilitySnapshotResponse) | 742 OnAccessibilitySnapshotResponse) |
| 748 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 743 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 | 1521 |
| 1527 // Reset state for the current RenderFrameHost once the FrameTreeNode has been | 1522 // Reset state for the current RenderFrameHost once the FrameTreeNode has been |
| 1528 // reset. | 1523 // reset. |
| 1529 SetRenderFrameCreated(false); | 1524 SetRenderFrameCreated(false); |
| 1530 InvalidateMojoConnection(); | 1525 InvalidateMojoConnection(); |
| 1531 | 1526 |
| 1532 // Execute any pending AX tree snapshot callbacks with an empty response, | 1527 // Execute any pending AX tree snapshot callbacks with an empty response, |
| 1533 // since we're never going to get a response from this renderer. | 1528 // since we're never going to get a response from this renderer. |
| 1534 for (const auto& iter : ax_tree_snapshot_callbacks_) | 1529 for (const auto& iter : ax_tree_snapshot_callbacks_) |
| 1535 iter.second.Run(ui::AXTreeUpdate()); | 1530 iter.second.Run(ui::AXTreeUpdate()); |
| 1536 | |
| 1537 ax_tree_snapshot_callbacks_.clear(); | 1531 ax_tree_snapshot_callbacks_.clear(); |
| 1538 javascript_callbacks_.clear(); | |
| 1539 visual_state_callbacks_.clear(); | |
| 1540 form_field_data_callbacks_.clear(); | |
| 1541 | 1532 |
| 1542 // Ensure that future remote interface requests are associated with the new | 1533 // Ensure that future remote interface requests are associated with the new |
| 1543 // process's channel. | 1534 // process's channel. |
| 1544 remote_associated_interfaces_.reset(); | 1535 remote_associated_interfaces_.reset(); |
| 1545 | 1536 |
| 1546 if (!is_active()) { | 1537 if (!is_active()) { |
| 1547 // If the process has died, we don't need to wait for the swap out ack from | 1538 // If the process has died, we don't need to wait for the swap out ack from |
| 1548 // this RenderFrame if it is pending deletion. Complete the swap out to | 1539 // this RenderFrame if it is pending deletion. Complete the swap out to |
| 1549 // destroy it. | 1540 // destroy it. |
| 1550 OnSwappedOut(); | 1541 OnSwappedOut(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( | 1709 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( |
| 1719 const base::string16& content, | 1710 const base::string16& content, |
| 1720 uint32_t start_offset, | 1711 uint32_t start_offset, |
| 1721 uint32_t end_offset) { | 1712 uint32_t end_offset) { |
| 1722 // Just Run the callback instead of propagating further. | 1713 // Just Run the callback instead of propagating further. |
| 1723 text_surrounding_selection_callback_.Run(content, start_offset, end_offset); | 1714 text_surrounding_selection_callback_.Run(content, start_offset, end_offset); |
| 1724 // Reset the callback for enabling early exit from future request. | 1715 // Reset the callback for enabling early exit from future request. |
| 1725 text_surrounding_selection_callback_.Reset(); | 1716 text_surrounding_selection_callback_.Reset(); |
| 1726 } | 1717 } |
| 1727 | 1718 |
| 1728 void RenderFrameHostImpl::RequestFocusedFormFieldData( | |
| 1729 FormFieldDataCallback& callback) { | |
| 1730 static int next_id = 1; | |
| 1731 int request_id = ++next_id; | |
| 1732 form_field_data_callbacks_[request_id] = callback; | |
| 1733 Send(new FrameMsg_FocusedFormFieldDataRequest(GetRoutingID(), request_id)); | |
| 1734 } | |
| 1735 | |
| 1736 void RenderFrameHostImpl::OnFocusedFormFieldDataResponse( | |
| 1737 int request_id, | |
| 1738 const FormFieldData& field_data) { | |
| 1739 auto it = form_field_data_callbacks_.find(request_id); | |
| 1740 if (it != form_field_data_callbacks_.end()) { | |
| 1741 it->second.Run(field_data); | |
| 1742 form_field_data_callbacks_.erase(it); | |
| 1743 } | |
| 1744 } | |
| 1745 | |
| 1746 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 1719 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
| 1747 delegate_->DidAccessInitialDocument(); | 1720 delegate_->DidAccessInitialDocument(); |
| 1748 } | 1721 } |
| 1749 | 1722 |
| 1750 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { | 1723 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { |
| 1751 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, | 1724 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, |
| 1752 GetSiteInstance()); | 1725 GetSiteInstance()); |
| 1753 } | 1726 } |
| 1754 | 1727 |
| 1755 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, | 1728 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3331 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3304 // There is no pending NavigationEntry in these cases, so pass 0 as the |
| 3332 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3305 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3333 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3306 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3334 return NavigationHandleImpl::Create( | 3307 return NavigationHandleImpl::Create( |
| 3335 params.url, frame_tree_node_, is_renderer_initiated, | 3308 params.url, frame_tree_node_, is_renderer_initiated, |
| 3336 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), | 3309 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), |
| 3337 entry_id_for_data_nav, false); // started_from_context_menu | 3310 entry_id_for_data_nav, false); // started_from_context_menu |
| 3338 } | 3311 } |
| 3339 | 3312 |
| 3340 } // namespace content | 3313 } // namespace content |
| OLD | NEW |