| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 #if defined(OS_ANDROID) | 110 #if defined(OS_ANDROID) |
| 111 #include "content/browser/android/app_web_message_port_message_filter.h" | 111 #include "content/browser/android/app_web_message_port_message_filter.h" |
| 112 #include "content/public/browser/android/java_interfaces.h" | 112 #include "content/public/browser/android/java_interfaces.h" |
| 113 #if defined(ENABLE_MOJO_CDM) | 113 #if defined(ENABLE_MOJO_CDM) |
| 114 #include "content/browser/media/android/provision_fetcher_impl.h" | 114 #include "content/browser/media/android/provision_fetcher_impl.h" |
| 115 #endif | 115 #endif |
| 116 #include "content/browser/media/android/media_player_renderer.h" | 116 #include "content/browser/media/android/media_player_renderer.h" |
| 117 #include "media/base/audio_renderer_sink.h" | 117 #include "media/base/audio_renderer_sink.h" |
| 118 #include "media/base/video_renderer_sink.h" | 118 #include "media/base/video_renderer_sink.h" |
| 119 #include "media/mojo/services/mojo_renderer_service.h" //nogncheck | 119 #include "media/mojo/services/mojo_renderer_service.h" // nogncheck |
| 120 #endif | 120 #endif |
| 121 | 121 |
| 122 #if defined(OS_MACOSX) | 122 #if defined(OS_MACOSX) |
| 123 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 123 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 #if defined(ENABLE_WEBVR) | 126 #if defined(ENABLE_WEBVR) |
| 127 #include "base/command_line.h" | 127 #include "device/vr/vr_service_impl.h" // nogncheck |
| 128 #include "content/public/common/content_switches.h" | |
| 129 #include "device/vr/vr_service_impl.h" // nogncheck | |
| 130 #endif | 128 #endif |
| 131 | 129 |
| 132 using base::TimeDelta; | 130 using base::TimeDelta; |
| 133 | 131 |
| 134 namespace content { | 132 namespace content { |
| 135 | 133 |
| 136 namespace { | 134 namespace { |
| 137 | 135 |
| 138 // The next value to use for the accessibility reset token. | 136 // The next value to use for the accessibility reset token. |
| 139 int g_next_accessibility_reset_token = 1; | 137 int g_next_accessibility_reset_token = 1; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 is_loading_(false), | 290 is_loading_(false), |
| 293 pending_commit_(false), | 291 pending_commit_(false), |
| 294 nav_entry_id_(0), | 292 nav_entry_id_(0), |
| 295 accessibility_reset_token_(0), | 293 accessibility_reset_token_(0), |
| 296 accessibility_reset_count_(0), | 294 accessibility_reset_count_(0), |
| 297 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), | 295 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), |
| 298 no_create_browser_accessibility_manager_for_testing_(false), | 296 no_create_browser_accessibility_manager_for_testing_(false), |
| 299 web_ui_type_(WebUI::kNoWebUI), | 297 web_ui_type_(WebUI::kNoWebUI), |
| 300 pending_web_ui_type_(WebUI::kNoWebUI), | 298 pending_web_ui_type_(WebUI::kNoWebUI), |
| 301 should_reuse_web_ui_(false), | 299 should_reuse_web_ui_(false), |
| 300 has_selection_(false), |
| 302 last_navigation_lofi_state_(LOFI_UNSPECIFIED), | 301 last_navigation_lofi_state_(LOFI_UNSPECIFIED), |
| 303 frame_host_binding_(this), | 302 frame_host_binding_(this), |
| 304 weak_ptr_factory_(this) { | 303 weak_ptr_factory_(this) { |
| 305 frame_tree_->AddRenderViewHostRef(render_view_host_); | 304 frame_tree_->AddRenderViewHostRef(render_view_host_); |
| 306 GetProcess()->AddRoute(routing_id_, this); | 305 GetProcess()->AddRoute(routing_id_, this); |
| 307 g_routing_id_frame_map.Get().insert(std::make_pair( | 306 g_routing_id_frame_map.Get().insert(std::make_pair( |
| 308 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 307 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
| 309 this)); | 308 this)); |
| 310 site_instance_->AddObserver(this); | 309 site_instance_->AddObserver(this); |
| 311 GetSiteInstance()->IncrementActiveFrameCount(); | 310 GetSiteInstance()->IncrementActiveFrameCount(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 frame_tree_node_->IsMainFrame() && render_view_host_->ref_count() == 1; | 376 frame_tree_node_->IsMainFrame() && render_view_host_->ref_count() == 1; |
| 378 if (is_active() && render_frame_created_ && | 377 if (is_active() && render_frame_created_ && |
| 379 !will_render_view_clean_up_render_frame) { | 378 !will_render_view_clean_up_render_frame) { |
| 380 Send(new FrameMsg_Delete(routing_id_)); | 379 Send(new FrameMsg_Delete(routing_id_)); |
| 381 } | 380 } |
| 382 | 381 |
| 383 // Null out the swapout timer; in crash dumps this member will be null only if | 382 // Null out the swapout timer; in crash dumps this member will be null only if |
| 384 // the dtor has run. (It may also be null in tests.) | 383 // the dtor has run. (It may also be null in tests.) |
| 385 swapout_event_monitor_timeout_.reset(); | 384 swapout_event_monitor_timeout_.reset(); |
| 386 | 385 |
| 387 for (const auto& iter: visual_state_callbacks_) { | 386 for (const auto& iter : visual_state_callbacks_) |
| 388 iter.second.Run(false); | 387 iter.second.Run(false); |
| 389 } | |
| 390 | 388 |
| 391 if (render_widget_host_ && | 389 if (render_widget_host_ && |
| 392 render_widget_host_->owned_by_render_frame_host()) { | 390 render_widget_host_->owned_by_render_frame_host()) { |
| 393 // Shutdown causes the RenderWidgetHost to delete itself. | 391 // Shutdown causes the RenderWidgetHost to delete itself. |
| 394 render_widget_host_->ShutdownAndDestroyWidget(true); | 392 render_widget_host_->ShutdownAndDestroyWidget(true); |
| 395 } | 393 } |
| 396 | 394 |
| 397 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 395 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 398 // the corresponding RenderViewHost if it is no longer needed. | 396 // the corresponding RenderViewHost if it is no longer needed. |
| 399 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); | 397 frame_tree_->ReleaseRenderViewHostRef(render_view_host_); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 OnAccessibilityChildFrameHitTestResult) | 699 OnAccessibilityChildFrameHitTestResult) |
| 702 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, | 700 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, |
| 703 OnAccessibilitySnapshotResponse) | 701 OnAccessibilitySnapshotResponse) |
| 704 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 702 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
| 705 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) | 703 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) |
| 706 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) | 704 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) |
| 707 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, | 705 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, |
| 708 OnDidChangeLoadProgress) | 706 OnDidChangeLoadProgress) |
| 709 IPC_MESSAGE_HANDLER(FrameHostMsg_SerializeAsMHTMLResponse, | 707 IPC_MESSAGE_HANDLER(FrameHostMsg_SerializeAsMHTMLResponse, |
| 710 OnSerializeAsMHTMLResponse) | 708 OnSerializeAsMHTMLResponse) |
| 709 IPC_MESSAGE_HANDLER(FrameHostMsg_SelectionChanged, OnSelectionChanged) |
| 711 #if defined(USE_EXTERNAL_POPUP_MENU) | 710 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 712 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) | 711 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
| 713 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) | 712 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
| 714 #endif | 713 #endif |
| 715 IPC_END_MESSAGE_MAP() | 714 IPC_END_MESSAGE_MAP() |
| 716 | 715 |
| 717 // No further actions here, since we may have been deleted. | 716 // No further actions here, since we may have been deleted. |
| 718 return handled; | 717 return handled; |
| 719 } | 718 } |
| 720 | 719 |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 void RenderFrameHostImpl::OnSerializeAsMHTMLResponse( | 2122 void RenderFrameHostImpl::OnSerializeAsMHTMLResponse( |
| 2124 int job_id, | 2123 int job_id, |
| 2125 bool success, | 2124 bool success, |
| 2126 const std::set<std::string>& digests_of_uris_of_serialized_resources, | 2125 const std::set<std::string>& digests_of_uris_of_serialized_resources, |
| 2127 base::TimeDelta renderer_main_thread_time) { | 2126 base::TimeDelta renderer_main_thread_time) { |
| 2128 MHTMLGenerationManager::GetInstance()->OnSerializeAsMHTMLResponse( | 2127 MHTMLGenerationManager::GetInstance()->OnSerializeAsMHTMLResponse( |
| 2129 this, job_id, success, digests_of_uris_of_serialized_resources, | 2128 this, job_id, success, digests_of_uris_of_serialized_resources, |
| 2130 renderer_main_thread_time); | 2129 renderer_main_thread_time); |
| 2131 } | 2130 } |
| 2132 | 2131 |
| 2132 void RenderFrameHostImpl::OnSelectionChanged(const base::string16& text, |
| 2133 uint32_t offset, |
| 2134 const gfx::Range& range) { |
| 2135 has_selection_ = !text.empty(); |
| 2136 GetRenderWidgetHost()->OnSelectionChanged(text, offset, range); |
| 2137 } |
| 2138 |
| 2133 #if defined(USE_EXTERNAL_POPUP_MENU) | 2139 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 2134 void RenderFrameHostImpl::OnShowPopup( | 2140 void RenderFrameHostImpl::OnShowPopup( |
| 2135 const FrameHostMsg_ShowPopup_Params& params) { | 2141 const FrameHostMsg_ShowPopup_Params& params) { |
| 2136 RenderViewHostDelegateView* view = | 2142 RenderViewHostDelegateView* view = |
| 2137 render_view_host_->delegate_->GetDelegateView(); | 2143 render_view_host_->delegate_->GetDelegateView(); |
| 2138 if (view) { | 2144 if (view) { |
| 2139 gfx::Point original_point(params.bounds.x(), params.bounds.y()); | 2145 gfx::Point original_point(params.bounds.x(), params.bounds.y()); |
| 2140 gfx::Point transformed_point = | 2146 gfx::Point transformed_point = |
| 2141 static_cast<RenderWidgetHostViewBase*>(GetView()) | 2147 static_cast<RenderWidgetHostViewBase*>(GetView()) |
| 2142 ->TransformPointToRootCoordSpace(original_point); | 2148 ->TransformPointToRootCoordSpace(original_point); |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( | 2906 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( |
| 2901 GetProcess()->GetID(), | 2907 GetProcess()->GetID(), |
| 2902 file_system_context->CrackURL(file.file_system_url) | 2908 file_system_context->CrackURL(file.file_system_url) |
| 2903 .mount_filesystem_id()); | 2909 .mount_filesystem_id()); |
| 2904 } | 2910 } |
| 2905 } | 2911 } |
| 2906 | 2912 |
| 2907 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); | 2913 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); |
| 2908 } | 2914 } |
| 2909 | 2915 |
| 2916 bool RenderFrameHostImpl::HasSelection() { |
| 2917 return has_selection_; |
| 2918 } |
| 2919 |
| 2910 void RenderFrameHostImpl::GetInterfaceProvider( | 2920 void RenderFrameHostImpl::GetInterfaceProvider( |
| 2911 shell::mojom::InterfaceProviderRequest interfaces) { | 2921 shell::mojom::InterfaceProviderRequest interfaces) { |
| 2912 interface_registry_->Bind(std::move(interfaces)); | 2922 interface_registry_->Bind(std::move(interfaces)); |
| 2913 } | 2923 } |
| 2914 | 2924 |
| 2915 #if defined(USE_EXTERNAL_POPUP_MENU) | 2925 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 2916 #if defined(OS_MACOSX) | 2926 #if defined(OS_MACOSX) |
| 2917 | 2927 |
| 2918 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { | 2928 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { |
| 2919 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); | 2929 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3183 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 3193 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
| 3184 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 3194 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
| 3185 return web_bluetooth_service_.get(); | 3195 return web_bluetooth_service_.get(); |
| 3186 } | 3196 } |
| 3187 | 3197 |
| 3188 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 3198 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
| 3189 web_bluetooth_service_.reset(); | 3199 web_bluetooth_service_.reset(); |
| 3190 } | 3200 } |
| 3191 | 3201 |
| 3192 } // namespace content | 3202 } // namespace content |
| OLD | NEW |