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 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.h" | 92 #include "content/public/common/service_names.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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 Send(new FrameMsg_Delete(routing_id_)); | 382 Send(new FrameMsg_Delete(routing_id_)); |
| 382 } | 383 } |
| 383 | 384 |
| 384 // Null out the swapout timer; in crash dumps this member will be null only if | 385 // Null out the swapout timer; in crash dumps this member will be null only if |
| 385 // the dtor has run. (It may also be null in tests.) | 386 // the dtor has run. (It may also be null in tests.) |
| 386 swapout_event_monitor_timeout_.reset(); | 387 swapout_event_monitor_timeout_.reset(); |
| 387 | 388 |
| 388 for (const auto& iter : visual_state_callbacks_) | 389 for (const auto& iter : visual_state_callbacks_) |
| 389 iter.second.Run(false); | 390 iter.second.Run(false); |
| 390 | 391 |
| 392 // Run callbacks for the outstanding text input info requests, if any. | |
| 393 for (const auto& iter : form_field_data_callbacks_) | |
| 394 iter.second.Run(FormFieldData()); | |
| 395 | |
| 391 if (render_widget_host_ && | 396 if (render_widget_host_ && |
| 392 render_widget_host_->owned_by_render_frame_host()) { | 397 render_widget_host_->owned_by_render_frame_host()) { |
| 393 // Shutdown causes the RenderWidgetHost to delete itself. | 398 // Shutdown causes the RenderWidgetHost to delete itself. |
| 394 render_widget_host_->ShutdownAndDestroyWidget(true); | 399 render_widget_host_->ShutdownAndDestroyWidget(true); |
| 395 } | 400 } |
| 396 | 401 |
| 397 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 402 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 398 // the corresponding RenderViewHost if it is no longer needed. | 403 // the corresponding RenderViewHost if it is no longer needed. |
| 399 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); | 404 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); |
| 400 } | 405 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 OnDidChangeSandboxFlags) | 692 OnDidChangeSandboxFlags) |
| 688 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, | 693 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, |
| 689 OnDidChangeFrameOwnerProperties) | 694 OnDidChangeFrameOwnerProperties) |
| 690 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) | 695 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
| 691 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) | 696 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
| 692 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, | 697 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
| 693 OnBeginNavigation) | 698 OnBeginNavigation) |
| 694 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) | 699 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) |
| 695 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 700 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
| 696 OnTextSurroundingSelectionResponse) | 701 OnTextSurroundingSelectionResponse) |
| 702 IPC_MESSAGE_HANDLER(FrameHostMsg_FocusedFormFieldDataResponse, | |
| 703 OnFocusedFormFieldDataResponse) | |
| 697 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 704 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
| 698 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 705 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
| 699 OnAccessibilityLocationChanges) | 706 OnAccessibilityLocationChanges) |
| 700 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, | 707 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
| 701 OnAccessibilityFindInPageResult) | 708 OnAccessibilityFindInPageResult) |
| 702 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult, | 709 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_ChildFrameHitTestResult, |
| 703 OnAccessibilityChildFrameHitTestResult) | 710 OnAccessibilityChildFrameHitTestResult) |
| 704 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, | 711 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, |
| 705 OnAccessibilitySnapshotResponse) | 712 OnAccessibilitySnapshotResponse) |
| 706 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 713 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1468 | 1475 |
| 1469 // Reset state for the current RenderFrameHost once the FrameTreeNode has been | 1476 // Reset state for the current RenderFrameHost once the FrameTreeNode has been |
| 1470 // reset. | 1477 // reset. |
| 1471 SetRenderFrameCreated(false); | 1478 SetRenderFrameCreated(false); |
| 1472 InvalidateMojoConnection(); | 1479 InvalidateMojoConnection(); |
| 1473 | 1480 |
| 1474 // Execute any pending AX tree snapshot callbacks with an empty response, | 1481 // Execute any pending AX tree snapshot callbacks with an empty response, |
| 1475 // since we're never going to get a response from this renderer. | 1482 // since we're never going to get a response from this renderer. |
| 1476 for (const auto& iter : ax_tree_snapshot_callbacks_) | 1483 for (const auto& iter : ax_tree_snapshot_callbacks_) |
| 1477 iter.second.Run(ui::AXTreeUpdate()); | 1484 iter.second.Run(ui::AXTreeUpdate()); |
| 1485 | |
| 1478 ax_tree_snapshot_callbacks_.clear(); | 1486 ax_tree_snapshot_callbacks_.clear(); |
| 1487 javascript_callbacks_.clear(); | |
| 1488 visual_state_callbacks_.clear(); | |
| 1489 form_field_data_callbacks_.clear(); | |
| 1479 | 1490 |
| 1480 // Ensure that future remote interface requests are associated with the new | 1491 // Ensure that future remote interface requests are associated with the new |
| 1481 // process's channel. | 1492 // process's channel. |
| 1482 remote_associated_interfaces_.reset(); | 1493 remote_associated_interfaces_.reset(); |
| 1483 | 1494 |
| 1484 if (!is_active()) { | 1495 if (!is_active()) { |
| 1485 // If the process has died, we don't need to wait for the swap out ack from | 1496 // If the process has died, we don't need to wait for the swap out ack from |
| 1486 // this RenderFrame if it is pending deletion. Complete the swap out to | 1497 // this RenderFrame if it is pending deletion. Complete the swap out to |
| 1487 // destroy it. | 1498 // destroy it. |
| 1488 OnSwappedOut(); | 1499 OnSwappedOut(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1656 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( | 1667 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( |
| 1657 const base::string16& content, | 1668 const base::string16& content, |
| 1658 uint32_t start_offset, | 1669 uint32_t start_offset, |
| 1659 uint32_t end_offset) { | 1670 uint32_t end_offset) { |
| 1660 // Just Run the callback instead of propagating further. | 1671 // Just Run the callback instead of propagating further. |
| 1661 text_surrounding_selection_callback_.Run(content, start_offset, end_offset); | 1672 text_surrounding_selection_callback_.Run(content, start_offset, end_offset); |
| 1662 // Reset the callback for enabling early exit from future request. | 1673 // Reset the callback for enabling early exit from future request. |
| 1663 text_surrounding_selection_callback_.Reset(); | 1674 text_surrounding_selection_callback_.Reset(); |
| 1664 } | 1675 } |
| 1665 | 1676 |
| 1677 void RenderFrameHostImpl::RequestFocusedFormFieldData( | |
| 1678 FormFieldDataCallback& callback) { | |
| 1679 static int next_id = 1; | |
| 1680 int request_id = ++next_id; | |
| 1681 form_field_data_callbacks_[request_id] = callback; | |
| 1682 Send(new FrameMsg_FocusedFormFieldDataRequest(GetRoutingID(), request_id)); | |
| 1683 } | |
| 1684 | |
| 1685 void RenderFrameHostImpl::OnFocusedFormFieldDataResponse( | |
| 1686 int request_id, | |
| 1687 const FormFieldData& field_data) { | |
| 1688 auto it = form_field_data_callbacks_.find(request_id); | |
| 1689 if (it != form_field_data_callbacks_.end()) { | |
| 1690 it->second.Run(field_data); | |
| 1691 form_field_data_callbacks_.erase(it); | |
| 1692 } else { | |
| 1693 NOTREACHED() << "Received form field data response for unknown request"; | |
|
Charlie Reis
2016/11/16 00:18:00
Normally we omit the NOTREACHED as well-- it's kno
shaktisahu
2016/11/16 20:26:58
Ok, I will remove the else block.
| |
| 1694 } | |
| 1695 } | |
| 1696 | |
| 1666 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 1697 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
| 1667 delegate_->DidAccessInitialDocument(); | 1698 delegate_->DidAccessInitialDocument(); |
| 1668 } | 1699 } |
| 1669 | 1700 |
| 1670 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { | 1701 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { |
| 1671 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, | 1702 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, |
| 1672 GetSiteInstance()); | 1703 GetSiteInstance()); |
| 1673 } | 1704 } |
| 1674 | 1705 |
| 1675 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, | 1706 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, |
| (...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3246 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3277 // There is no pending NavigationEntry in these cases, so pass 0 as the |
| 3247 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3278 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3248 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3279 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3249 return NavigationHandleImpl::Create( | 3280 return NavigationHandleImpl::Create( |
| 3250 params.url, frame_tree_node_, is_renderer_initiated, | 3281 params.url, frame_tree_node_, is_renderer_initiated, |
| 3251 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), | 3282 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), |
| 3252 entry_id_for_data_nav, false); // started_from_context_menu | 3283 entry_id_for_data_nav, false); // started_from_context_menu |
| 3253 } | 3284 } |
| 3254 | 3285 |
| 3255 } // namespace content | 3286 } // namespace content |
| OLD | NEW |