| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, | 1048 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, |
| 1049 OnAddStyleSheetByURL) | 1049 OnAddStyleSheetByURL) |
| 1050 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, | 1050 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, |
| 1051 OnSetAccessibilityMode) | 1051 OnSetAccessibilityMode) |
| 1052 IPC_MESSAGE_HANDLER(FrameMsg_DisownOpener, OnDisownOpener) | 1052 IPC_MESSAGE_HANDLER(FrameMsg_DisownOpener, OnDisownOpener) |
| 1053 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) | 1053 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) |
| 1054 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) | 1054 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) |
| 1055 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, | 1055 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, |
| 1056 OnTextTrackSettingsChanged) | 1056 OnTextTrackSettingsChanged) |
| 1057 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) | 1057 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) |
| 1058 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) |
| 1058 #if defined(OS_ANDROID) | 1059 #if defined(OS_ANDROID) |
| 1059 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1060 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
| 1060 #elif defined(OS_MACOSX) | 1061 #elif defined(OS_MACOSX) |
| 1061 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1062 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 1062 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1063 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
| 1063 #endif | 1064 #endif |
| 1064 IPC_END_MESSAGE_MAP() | 1065 IPC_END_MESSAGE_MAP() |
| 1065 | 1066 |
| 1066 return handled; | 1067 return handled; |
| 1067 } | 1068 } |
| (...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 // | 2587 // |
| 2587 // Note: It is important this notification occur before DidStopLoading so the | 2588 // Note: It is important this notification occur before DidStopLoading so the |
| 2588 // SSL manager can react to the provisional load failure before being | 2589 // SSL manager can react to the provisional load failure before being |
| 2589 // notified the load stopped. | 2590 // notified the load stopped. |
| 2590 // | 2591 // |
| 2591 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2592 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2592 DidFailProvisionalLoad(frame, error)); | 2593 DidFailProvisionalLoad(frame, error)); |
| 2593 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2594 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| 2594 DidFailProvisionalLoad(error)); | 2595 DidFailProvisionalLoad(error)); |
| 2595 | 2596 |
| 2596 bool show_repost_interstitial = | 2597 SendFailedProvisionalLoad(failed_request, error, frame); |
| 2597 (error.reason == net::ERR_CACHE_MISS && | |
| 2598 EqualsASCII(failed_request.httpMethod(), "POST")); | |
| 2599 | 2598 |
| 2600 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 2599 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) |
| 2601 params.error_code = error.reason; | |
| 2602 GetContentClient()->renderer()->GetNavigationErrorStrings( | |
| 2603 render_view_.get(), | |
| 2604 frame, | |
| 2605 failed_request, | |
| 2606 error, | |
| 2607 NULL, | |
| 2608 ¶ms.error_description); | |
| 2609 params.url = error.unreachableURL; | |
| 2610 params.showing_repost_interstitial = show_repost_interstitial; | |
| 2611 Send(new FrameHostMsg_DidFailProvisionalLoadWithError( | |
| 2612 routing_id_, params)); | |
| 2613 | |
| 2614 // Don't display an error page if this is simply a cancelled load. Aside | |
| 2615 // from being dumb, Blink doesn't expect it and it will cause a crash. | |
| 2616 if (error.reason == net::ERR_ABORTED) | |
| 2617 return; | 2600 return; |
| 2618 | 2601 |
| 2619 // Don't display "client blocked" error page if browser has asked us not to. | |
| 2620 if (error.reason == net::ERR_BLOCKED_BY_CLIENT && | |
| 2621 render_view_->renderer_preferences_.disable_client_blocked_error_page) { | |
| 2622 return; | |
| 2623 } | |
| 2624 | |
| 2625 // Allow the embedder to suppress an error page. | |
| 2626 if (GetContentClient()->renderer()->ShouldSuppressErrorPage(this, | |
| 2627 error.unreachableURL)) { | |
| 2628 return; | |
| 2629 } | |
| 2630 | |
| 2631 if (RenderThreadImpl::current() && | |
| 2632 RenderThreadImpl::current()->layout_test_mode()) { | |
| 2633 return; | |
| 2634 } | |
| 2635 | |
| 2636 // Make sure we never show errors in view source mode. | 2602 // Make sure we never show errors in view source mode. |
| 2637 frame->enableViewSourceMode(false); | 2603 frame->enableViewSourceMode(false); |
| 2638 | 2604 |
| 2639 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2605 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2640 NavigationStateImpl* navigation_state = | 2606 NavigationStateImpl* navigation_state = |
| 2641 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2607 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 2642 | 2608 |
| 2643 // If this is a failed back/forward/reload navigation, then we need to do a | 2609 // If this is a failed back/forward/reload navigation, then we need to do a |
| 2644 // 'replace' load. This is necessary to avoid messing up session history. | 2610 // 'replace' load. This is necessary to avoid messing up session history. |
| 2645 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2611 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| (...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4147 request.setCheckForBrowserSideNavigation(false); | 4113 request.setCheckForBrowserSideNavigation(false); |
| 4148 | 4114 |
| 4149 // Record this before starting the load. A lower bound of this time is needed | 4115 // Record this before starting the load. A lower bound of this time is needed |
| 4150 // to sanitize the navigationStart override set below. | 4116 // to sanitize the navigationStart override set below. |
| 4151 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 4117 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 4152 frame_->loadRequest(request); | 4118 frame_->loadRequest(request); |
| 4153 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, | 4119 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, |
| 4154 renderer_navigation_start); | 4120 renderer_navigation_start); |
| 4155 } | 4121 } |
| 4156 | 4122 |
| 4123 void RenderFrameImpl::OnFailedNavigation( |
| 4124 const CommonNavigationParams& common_params, |
| 4125 const RequestNavigationParams& request_params, |
| 4126 bool has_stale_copy_in_cache, |
| 4127 int error_code) { |
| 4128 bool is_reload = IsReload(common_params.navigation_type); |
| 4129 bool is_history_navigation = request_params.page_state.IsValid(); |
| 4130 WebURLRequest::CachePolicy cache_policy = |
| 4131 WebURLRequest::UseProtocolCachePolicy; |
| 4132 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
| 4133 common_params.url, is_history_navigation, request_params, &is_reload, |
| 4134 &cache_policy)) { |
| 4135 return; |
| 4136 } |
| 4137 |
| 4138 GetContentClient()->SetActiveURL(common_params.url); |
| 4139 |
| 4140 pending_navigation_params_.reset(new NavigationParams( |
| 4141 common_params, StartNavigationParams(), request_params)); |
| 4142 |
| 4143 // Inform the browser of the start of the provisional load. This is needed so |
| 4144 // that the load is properly tracked by the WebNavigation API. |
| 4145 // TODO(clamy): Properly set is_transition_navigation. |
| 4146 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
| 4147 routing_id_, common_params.url, false)); |
| 4148 |
| 4149 // Send the provisional load failure. |
| 4150 blink::WebURLError error = |
| 4151 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 4152 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 4153 common_params, scoped_ptr<StreamOverrideParameters>(), |
| 4154 frame_->isViewSourceModeEnabled()); |
| 4155 SendFailedProvisionalLoad(failed_request, error, frame_); |
| 4156 |
| 4157 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) |
| 4158 return; |
| 4159 |
| 4160 // Make sure errors are not shown in view source mode. |
| 4161 frame_->enableViewSourceMode(false); |
| 4162 |
| 4163 // Replace the current history entry in reloads, history navigations and loads |
| 4164 // of the same url. This corresponds to Blink's notion of a standard |
| 4165 // commit. |
| 4166 // TODO(clamy): see if initial commits in subframes should be handled |
| 4167 // separately. |
| 4168 bool replace = is_reload || is_history_navigation || |
| 4169 common_params.url == GetLoadingUrl(); |
| 4170 LoadNavigationErrorPage(failed_request, error, replace); |
| 4171 } |
| 4172 |
| 4157 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 4173 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
| 4158 RenderFrame* render_frame, | 4174 RenderFrame* render_frame, |
| 4159 const NavigationPolicyInfo& info) { | 4175 const NavigationPolicyInfo& info) { |
| 4160 #ifdef OS_ANDROID | 4176 #ifdef OS_ANDROID |
| 4161 // The handlenavigation API is deprecated and will be removed once | 4177 // The handlenavigation API is deprecated and will be removed once |
| 4162 // crbug.com/325351 is resolved. | 4178 // crbug.com/325351 is resolved. |
| 4163 if (info.urlRequest.url() != GURL(kSwappedOutURL) && | 4179 if (info.urlRequest.url() != GURL(kSwappedOutURL) && |
| 4164 GetContentClient()->renderer()->HandleNavigation( | 4180 GetContentClient()->renderer()->HandleNavigation( |
| 4165 render_frame, | 4181 render_frame, |
| 4166 static_cast<DocumentState*>(info.extraData), | 4182 static_cast<DocumentState*>(info.extraData), |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4644 WebString::fromUTF8(charset), | 4660 WebString::fromUTF8(charset), |
| 4645 base_url, | 4661 base_url, |
| 4646 params.history_url_for_data_url, | 4662 params.history_url_for_data_url, |
| 4647 false); | 4663 false); |
| 4648 } else { | 4664 } else { |
| 4649 CHECK(false) << "Invalid URL passed: " | 4665 CHECK(false) << "Invalid URL passed: " |
| 4650 << params.url.possibly_invalid_spec(); | 4666 << params.url.possibly_invalid_spec(); |
| 4651 } | 4667 } |
| 4652 } | 4668 } |
| 4653 | 4669 |
| 4670 void RenderFrameImpl::SendFailedProvisionalLoad( |
| 4671 const blink::WebURLRequest& request, |
| 4672 const blink::WebURLError& error, |
| 4673 blink::WebLocalFrame* frame) { |
| 4674 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && |
| 4675 EqualsASCII(request.httpMethod(), "POST")); |
| 4676 |
| 4677 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 4678 params.error_code = error.reason; |
| 4679 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 4680 render_view_.get(), frame, request, error, NULL, |
| 4681 ¶ms.error_description); |
| 4682 params.url = error.unreachableURL; |
| 4683 params.showing_repost_interstitial = show_repost_interstitial; |
| 4684 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); |
| 4685 } |
| 4686 |
| 4687 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( |
| 4688 int error_code, |
| 4689 const GURL& unreachable_url) { |
| 4690 // Don't display an error page if this is simply a cancelled load. Aside |
| 4691 // from being dumb, Blink doesn't expect it and it will cause a crash. |
| 4692 if (error_code == net::ERR_ABORTED) |
| 4693 return false; |
| 4694 |
| 4695 // Don't display "client blocked" error page if browser has asked us not to. |
| 4696 if (error_code == net::ERR_BLOCKED_BY_CLIENT && |
| 4697 render_view_->renderer_preferences_.disable_client_blocked_error_page) { |
| 4698 return false; |
| 4699 } |
| 4700 |
| 4701 // Allow the embedder to suppress an error page. |
| 4702 if (GetContentClient()->renderer()->ShouldSuppressErrorPage( |
| 4703 this, unreachable_url)) { |
| 4704 return false; |
| 4705 } |
| 4706 |
| 4707 if (RenderThreadImpl::current() && |
| 4708 RenderThreadImpl::current()->layout_test_mode()) { |
| 4709 return false; |
| 4710 } |
| 4711 |
| 4712 return true; |
| 4713 } |
| 4714 |
| 4654 GURL RenderFrameImpl::GetLoadingUrl() const { | 4715 GURL RenderFrameImpl::GetLoadingUrl() const { |
| 4655 WebDataSource* ds = frame_->dataSource(); | 4716 WebDataSource* ds = frame_->dataSource(); |
| 4656 if (ds->hasUnreachableURL()) | 4717 if (ds->hasUnreachableURL()) |
| 4657 return ds->unreachableURL(); | 4718 return ds->unreachableURL(); |
| 4658 | 4719 |
| 4659 const WebURLRequest& request = ds->request(); | 4720 const WebURLRequest& request = ds->request(); |
| 4660 return request.url(); | 4721 return request.url(); |
| 4661 } | 4722 } |
| 4662 | 4723 |
| 4663 void RenderFrameImpl::PopulateDocumentStateFromPending( | 4724 void RenderFrameImpl::PopulateDocumentStateFromPending( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4708 // initiated any load resulting from JS execution. | 4769 // initiated any load resulting from JS execution. |
| 4709 if (!pending_navigation_params_->common_params.url.SchemeIs( | 4770 if (!pending_navigation_params_->common_params.url.SchemeIs( |
| 4710 url::kJavaScriptScheme)) { | 4771 url::kJavaScriptScheme)) { |
| 4711 return NavigationStateImpl::CreateBrowserInitiated( | 4772 return NavigationStateImpl::CreateBrowserInitiated( |
| 4712 pending_navigation_params_->common_params, | 4773 pending_navigation_params_->common_params, |
| 4713 pending_navigation_params_->start_params, | 4774 pending_navigation_params_->start_params, |
| 4714 pending_navigation_params_->request_params); | 4775 pending_navigation_params_->request_params); |
| 4715 } | 4776 } |
| 4716 return NavigationStateImpl::CreateContentInitiated(); | 4777 return NavigationStateImpl::CreateContentInitiated(); |
| 4717 } | 4778 } |
| 4779 |
| 4718 #if defined(OS_ANDROID) | 4780 #if defined(OS_ANDROID) |
| 4719 | 4781 |
| 4720 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( | 4782 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( |
| 4721 const blink::WebURL& url, | 4783 const blink::WebURL& url, |
| 4722 WebMediaPlayerClient* client, | 4784 WebMediaPlayerClient* client, |
| 4723 media::MediaPermission* media_permission, | 4785 media::MediaPermission* media_permission, |
| 4724 blink::WebContentDecryptionModule* initial_cdm) { | 4786 blink::WebContentDecryptionModule* initial_cdm) { |
| 4725 GpuChannelHost* gpu_channel_host = | 4787 GpuChannelHost* gpu_channel_host = |
| 4726 RenderThreadImpl::current()->EstablishGpuChannelSync( | 4788 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 4727 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 4789 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4782 #elif defined(ENABLE_BROWSER_CDMS) | 4844 #elif defined(ENABLE_BROWSER_CDMS) |
| 4783 cdm_manager_, | 4845 cdm_manager_, |
| 4784 #endif | 4846 #endif |
| 4785 this); | 4847 this); |
| 4786 } | 4848 } |
| 4787 | 4849 |
| 4788 return cdm_factory_; | 4850 return cdm_factory_; |
| 4789 } | 4851 } |
| 4790 | 4852 |
| 4791 } // namespace content | 4853 } // namespace content |
| OLD | NEW |