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