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