| 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "content/child/web_url_loader_impl.h" | 45 #include "content/child/web_url_loader_impl.h" |
| 46 #include "content/child/web_url_request_util.h" | 46 #include "content/child/web_url_request_util.h" |
| 47 #include "content/child/webmessageportchannel_impl.h" | 47 #include "content/child/webmessageportchannel_impl.h" |
| 48 #include "content/child/websocket_bridge.h" | 48 #include "content/child/websocket_bridge.h" |
| 49 #include "content/child/weburlresponse_extradata_impl.h" | 49 #include "content/child/weburlresponse_extradata_impl.h" |
| 50 #include "content/common/accessibility_messages.h" | 50 #include "content/common/accessibility_messages.h" |
| 51 #include "content/common/clipboard_messages.h" | 51 #include "content/common/clipboard_messages.h" |
| 52 #include "content/common/frame_messages.h" | 52 #include "content/common/frame_messages.h" |
| 53 #include "content/common/frame_replication_state.h" | 53 #include "content/common/frame_replication_state.h" |
| 54 #include "content/common/input_messages.h" | 54 #include "content/common/input_messages.h" |
| 55 #include "content/common/navigation_params.h" | 55 #include "content/common/render_frame_setup.mojom.h" |
| 56 #include "content/common/savable_subframe.h" | 56 #include "content/common/savable_subframe.h" |
| 57 #include "content/common/service_worker/service_worker_types.h" | 57 #include "content/common/service_worker/service_worker_types.h" |
| 58 #include "content/common/site_isolation_policy.h" | 58 #include "content/common/site_isolation_policy.h" |
| 59 #include "content/common/ssl_status_serialization.h" | 59 #include "content/common/ssl_status_serialization.h" |
| 60 #include "content/common/swapped_out_messages.h" | 60 #include "content/common/swapped_out_messages.h" |
| 61 #include "content/common/view_messages.h" | 61 #include "content/common/view_messages.h" |
| 62 #include "content/public/common/bindings_policy.h" | 62 #include "content/public/common/bindings_policy.h" |
| 63 #include "content/public/common/browser_side_navigation_policy.h" | 63 #include "content/public/common/browser_side_navigation_policy.h" |
| 64 #include "content/public/common/content_constants.h" | 64 #include "content/public/common/content_constants.h" |
| 65 #include "content/public/common/content_switches.h" | 65 #include "content/public/common/content_switches.h" |
| 66 #include "content/public/common/context_menu_params.h" | 66 #include "content/public/common/context_menu_params.h" |
| 67 #include "content/public/common/isolated_world_ids.h" | 67 #include "content/public/common/isolated_world_ids.h" |
| 68 #include "content/public/common/page_state.h" | 68 #include "content/public/common/page_state.h" |
| 69 #include "content/public/common/resource_response.h" | |
| 70 #include "content/public/common/url_constants.h" | 69 #include "content/public/common/url_constants.h" |
| 71 #include "content/public/common/url_utils.h" | 70 #include "content/public/common/url_utils.h" |
| 72 #include "content/public/renderer/browser_plugin_delegate.h" | 71 #include "content/public/renderer/browser_plugin_delegate.h" |
| 73 #include "content/public/renderer/content_renderer_client.h" | 72 #include "content/public/renderer/content_renderer_client.h" |
| 74 #include "content/public/renderer/context_menu_client.h" | 73 #include "content/public/renderer/context_menu_client.h" |
| 75 #include "content/public/renderer/document_state.h" | 74 #include "content/public/renderer/document_state.h" |
| 76 #include "content/public/renderer/navigation_state.h" | 75 #include "content/public/renderer/navigation_state.h" |
| 77 #include "content/public/renderer/render_frame_observer.h" | 76 #include "content/public/renderer/render_frame_observer.h" |
| 78 #include "content/public/renderer/renderer_ppapi_host.h" | 77 #include "content/public/renderer/renderer_ppapi_host.h" |
| 79 #include "content/renderer/accessibility/renderer_accessibility.h" | 78 #include "content/renderer/accessibility/renderer_accessibility.h" |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) | 749 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) |
| 751 return true; | 750 return true; |
| 752 | 751 |
| 753 // Otherwise, WMPI can only be used if AVDA is working. | 752 // Otherwise, WMPI can only be used if AVDA is working. |
| 754 return (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 753 return (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 755 switches::kDisableAcceleratedVideoDecode) && | 754 switches::kDisableAcceleratedVideoDecode) && |
| 756 media::MediaCodecUtil::IsMediaCodecAvailable()); | 755 media::MediaCodecUtil::IsMediaCodecAvailable()); |
| 757 } | 756 } |
| 758 #endif // defined(OS_ANDROID) | 757 #endif // defined(OS_ANDROID) |
| 759 | 758 |
| 759 class DataPipeConsumerHandleReceiverImpl : public DataPipeConsumerHandleReceiver
{ |
| 760 public: |
| 761 static void CreateService(RenderFrameImpl* rfi, mojo::InterfaceRequest<DataPip
eConsumerHandleReceiver> request) { |
| 762 // No leak here because of mojo::StrongBinding usage. |
| 763 new DataPipeConsumerHandleReceiverImpl(rfi, std::move(request)); |
| 764 } |
| 765 |
| 766 void ReceiveDataPipeConsumerHandle( |
| 767 mojo::ScopedDataPipeConsumerHandle data_consumer_handle, int32_t handle_co
mmit_id) override { |
| 768 rfi_->ReceiveNavigationDataPipeConsumerHandle( |
| 769 std::move(data_consumer_handle), handle_commit_id); |
| 770 } |
| 771 |
| 772 private: |
| 773 DataPipeConsumerHandleReceiverImpl( |
| 774 RenderFrameImpl* rfi, |
| 775 mojo::InterfaceRequest<DataPipeConsumerHandleReceiver> request) |
| 776 : rfi_(rfi), binding_(this, std::move(request)) {} |
| 777 |
| 778 RenderFrameImpl* rfi_; |
| 779 mojo::StrongBinding<DataPipeConsumerHandleReceiver> binding_; |
| 780 }; |
| 781 |
| 760 } // namespace | 782 } // namespace |
| 761 | 783 |
| 762 // static | 784 // static |
| 763 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 785 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
| 764 int32_t routing_id) { | 786 int32_t routing_id) { |
| 765 DCHECK(routing_id != MSG_ROUTING_NONE); | 787 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 766 CreateParams params(render_view, routing_id); | 788 CreateParams params(render_view, routing_id); |
| 767 | 789 |
| 768 if (g_create_render_frame_impl) | 790 if (g_create_render_frame_impl) |
| 769 return g_create_render_frame_impl(params); | 791 return g_create_render_frame_impl(params); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 geolocation_dispatcher_(NULL), | 1012 geolocation_dispatcher_(NULL), |
| 991 push_messaging_dispatcher_(NULL), | 1013 push_messaging_dispatcher_(NULL), |
| 992 presentation_dispatcher_(NULL), | 1014 presentation_dispatcher_(NULL), |
| 993 screen_orientation_dispatcher_(NULL), | 1015 screen_orientation_dispatcher_(NULL), |
| 994 manifest_manager_(NULL), | 1016 manifest_manager_(NULL), |
| 995 accessibility_mode_(AccessibilityModeOff), | 1017 accessibility_mode_(AccessibilityModeOff), |
| 996 renderer_accessibility_(NULL), | 1018 renderer_accessibility_(NULL), |
| 997 media_player_delegate_(NULL), | 1019 media_player_delegate_(NULL), |
| 998 is_using_lofi_(false), | 1020 is_using_lofi_(false), |
| 999 is_pasting_(false), | 1021 is_pasting_(false), |
| 1022 latest_handle_commit_id_(-1), |
| 1023 handle_render_thread_(nullptr), |
| 1024 latest_navigation_commit_id_(-1), |
| 1025 navigation_render_thread_(nullptr), |
| 1000 weak_factory_(this) { | 1026 weak_factory_(this) { |
| 1001 std::pair<RoutingIDFrameMap::iterator, bool> result = | 1027 std::pair<RoutingIDFrameMap::iterator, bool> result = |
| 1002 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 1028 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
| 1003 CHECK(result.second) << "Inserting a duplicate item."; | 1029 CHECK(result.second) << "Inserting a duplicate item."; |
| 1004 | 1030 |
| 1005 RenderThread::Get()->AddRoute(routing_id_, this); | 1031 RenderThread::Get()->AddRoute(routing_id_, this); |
| 1006 | 1032 |
| 1007 render_view_->RegisterRenderFrame(this); | 1033 render_view_->RegisterRenderFrame(this); |
| 1008 | 1034 |
| 1009 // Everything below subclasses RenderFrameObserver and is automatically | 1035 // Everything below subclasses RenderFrameObserver and is automatically |
| (...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4670 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 4696 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
| 4671 if (renderer_accessibility()) | 4697 if (renderer_accessibility()) |
| 4672 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 4698 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
| 4673 } | 4699 } |
| 4674 | 4700 |
| 4675 // PlzNavigate | 4701 // PlzNavigate |
| 4676 void RenderFrameImpl::OnCommitNavigation( | 4702 void RenderFrameImpl::OnCommitNavigation( |
| 4677 const ResourceResponseHead& response, | 4703 const ResourceResponseHead& response, |
| 4678 const GURL& stream_url, | 4704 const GURL& stream_url, |
| 4679 const CommonNavigationParams& common_params, | 4705 const CommonNavigationParams& common_params, |
| 4680 const RequestNavigationParams& request_params) { | 4706 const RequestNavigationParams& request_params, |
| 4707 int32_t navigation_commit_id) { |
| 4681 CHECK(IsBrowserSideNavigationEnabled()); | 4708 CHECK(IsBrowserSideNavigationEnabled()); |
| 4682 // This will override the url requested by the WebURLLoader, as well as | 4709 // // This will override the url requested by the WebURLLoader, as well as |
| 4683 // provide it with the response to the request. | 4710 // // provide it with the response to the request. |
| 4684 scoped_ptr<StreamOverrideParameters> stream_override( | 4711 // scoped_ptr<StreamOverrideParameters> stream_override( |
| 4685 new StreamOverrideParameters()); | 4712 // new StreamOverrideParameters()); |
| 4686 stream_override->stream_url = stream_url; | 4713 // stream_override->stream_url = stream_url; |
| 4687 stream_override->response = response; | 4714 // stream_override->response = response; |
| 4688 | 4715 |
| 4689 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4716 // NavigateInternal(common_params, StartNavigationParams(), request_params, |
| 4690 std::move(stream_override)); | 4717 // std::move(stream_override)); |
| 4718 navigation_response = response; |
| 4719 navigation_stream_url = stream_url; |
| 4720 navigation_common_params = common_params; |
| 4721 navigation_request_params = request_params; |
| 4722 |
| 4723 latest_navigation_commit_id_ = navigation_commit_id; |
| 4724 navigation_render_thread_ = RenderThreadImpl::current(); |
| 4725 NavigateIfIPCSynched(navigation_commit_id < 0); |
| 4726 } |
| 4727 |
| 4728 // PlzNavigate |
| 4729 void RenderFrameImpl::ReceiveNavigationDataPipeConsumerHandle( |
| 4730 mojo::ScopedDataPipeConsumerHandle data_consumer_handle, int32_t handle_co
mmit_id) { |
| 4731 latest_handle_ = std::move(data_consumer_handle); |
| 4732 latest_handle_commit_id_ = handle_commit_id; |
| 4733 handle_render_thread_ = RenderThreadImpl::current(); |
| 4734 RenderFrameImpl::NavigateIfIPCSynched(false); |
| 4735 } |
| 4736 |
| 4737 void RenderFrameImpl::NavigateIfIPCSynched(bool no_sync_needed) { |
| 4738 if (no_sync_needed || latest_navigation_commit_id_ == latest_handle_commit_id_
) { |
| 4739 LOG(ERROR) << "*** NAVIGATED with commit id: " << latest_navigation_commit_i
d_ << " ***"; |
| 4740 if (navigation_render_thread_ != nullptr && handle_render_thread_ != nullptr
&& |
| 4741 navigation_render_thread_ != handle_render_thread_) { |
| 4742 LOG(ERROR) << "*** AHHHHHHHHHHHHHHH! THREADS DIFFER !!!! ***"; |
| 4743 } |
| 4744 // This will override the url requested by the WebURLLoader, as well as |
| 4745 // provide it with the response to the request. |
| 4746 scoped_ptr<StreamOverrideParameters> stream_override( |
| 4747 new StreamOverrideParameters()); |
| 4748 stream_override->stream_url = navigation_stream_url; |
| 4749 stream_override->response = navigation_response; |
| 4750 |
| 4751 NavigateInternal(navigation_common_params, |
| 4752 StartNavigationParams(), |
| 4753 navigation_request_params, |
| 4754 std::move(stream_override)); |
| 4755 // no_sync_needed ? mojo::ScopedDataPipeConsumerHandle() :
std::move(latest_handle_)); |
| 4756 } else { |
| 4757 LOG(ERROR) << "*** Still waiting on the " << (latest_navigation_commit_id_ <
latest_handle_commit_id_ ? "NAVIGATION" : "HANDLE") << " commit id to navigate"
; |
| 4758 LOG(ERROR) << "*** latest_navigation_commit_id_ : " << latest_navigation_c
ommit_id_; |
| 4759 LOG(ERROR) << "*** latest_handle_commit_id_ : " << latest_handle_commi
t_id_; |
| 4760 } |
| 4761 // TODO: throw away the extra stored data when a newer handle of the other typ
e is received. |
| 4691 } | 4762 } |
| 4692 | 4763 |
| 4693 void RenderFrameImpl::OnFailedNavigation( | 4764 void RenderFrameImpl::OnFailedNavigation( |
| 4694 const CommonNavigationParams& common_params, | 4765 const CommonNavigationParams& common_params, |
| 4695 const RequestNavigationParams& request_params, | 4766 const RequestNavigationParams& request_params, |
| 4696 bool has_stale_copy_in_cache, | 4767 bool has_stale_copy_in_cache, |
| 4697 int error_code) { | 4768 int error_code) { |
| 4698 bool is_reload = IsReload(common_params.navigation_type); | 4769 bool is_reload = IsReload(common_params.navigation_type); |
| 4699 bool is_history_navigation = request_params.page_state.IsValid(); | 4770 bool is_history_navigation = request_params.page_state.IsValid(); |
| 4700 WebURLRequest::CachePolicy cache_policy = | 4771 WebURLRequest::CachePolicy cache_policy = |
| (...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6035 return cdm_factory_.get(); | 6106 return cdm_factory_.get(); |
| 6036 } | 6107 } |
| 6037 | 6108 |
| 6038 void RenderFrameImpl::RegisterMojoServices() { | 6109 void RenderFrameImpl::RegisterMojoServices() { |
| 6039 // Only main frame have ImageDownloader service. | 6110 // Only main frame have ImageDownloader service. |
| 6040 if (!frame_->parent()) { | 6111 if (!frame_->parent()) { |
| 6041 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 6112 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
| 6042 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 6113 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
| 6043 base::Unretained(this))); | 6114 base::Unretained(this))); |
| 6044 } | 6115 } |
| 6116 |
| 6117 GetServiceRegistry()->AddService<DataPipeConsumerHandleReceiver>( |
| 6118 base::Bind(&DataPipeConsumerHandleReceiverImpl::CreateService, |
| 6119 base::Unretained(this))); |
| 6045 } | 6120 } |
| 6046 | 6121 |
| 6047 template <typename Interface> | 6122 template <typename Interface> |
| 6048 void RenderFrameImpl::ConnectToService( | 6123 void RenderFrameImpl::ConnectToService( |
| 6049 mojo::InterfaceRequest<Interface> request) { | 6124 mojo::InterfaceRequest<Interface> request) { |
| 6050 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); | 6125 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); |
| 6051 } | 6126 } |
| 6052 | 6127 |
| 6053 mojo::ServiceProviderPtr RenderFrameImpl::ConnectToApplication( | 6128 mojo::ServiceProviderPtr RenderFrameImpl::ConnectToApplication( |
| 6054 const GURL& url) { | 6129 const GURL& url) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6108 int match_count, | 6183 int match_count, |
| 6109 int ordinal, | 6184 int ordinal, |
| 6110 const WebRect& selection_rect, | 6185 const WebRect& selection_rect, |
| 6111 bool final_status_update) { | 6186 bool final_status_update) { |
| 6112 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6187 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6113 selection_rect, ordinal, | 6188 selection_rect, ordinal, |
| 6114 final_status_update)); | 6189 final_status_update)); |
| 6115 } | 6190 } |
| 6116 | 6191 |
| 6117 } // namespace content | 6192 } // namespace content |
| OLD | NEW |