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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 OnTextSurroundingSelectionRequest) | 1042 OnTextSurroundingSelectionRequest) |
1043 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, | 1043 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, |
1044 OnAddStyleSheetByURL) | 1044 OnAddStyleSheetByURL) |
1045 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, | 1045 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, |
1046 OnSetAccessibilityMode) | 1046 OnSetAccessibilityMode) |
1047 IPC_MESSAGE_HANDLER(FrameMsg_DisownOpener, OnDisownOpener) | 1047 IPC_MESSAGE_HANDLER(FrameMsg_DisownOpener, OnDisownOpener) |
1048 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) | 1048 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) |
1049 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) | 1049 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) |
1050 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, | 1050 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, |
1051 OnTextTrackSettingsChanged) | 1051 OnTextTrackSettingsChanged) |
| 1052 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) |
1052 #if defined(OS_ANDROID) | 1053 #if defined(OS_ANDROID) |
1053 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1054 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
1054 #elif defined(OS_MACOSX) | 1055 #elif defined(OS_MACOSX) |
1055 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1056 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
1056 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1057 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
1057 #endif | 1058 #endif |
1058 IPC_END_MESSAGE_MAP() | 1059 IPC_END_MESSAGE_MAP() |
1059 | 1060 |
1060 return handled; | 1061 return handled; |
1061 } | 1062 } |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 // | 2504 // |
2504 // Note: It is important this notification occur before DidStopLoading so the | 2505 // Note: It is important this notification occur before DidStopLoading so the |
2505 // SSL manager can react to the provisional load failure before being | 2506 // SSL manager can react to the provisional load failure before being |
2506 // notified the load stopped. | 2507 // notified the load stopped. |
2507 // | 2508 // |
2508 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2509 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
2509 DidFailProvisionalLoad(frame, error)); | 2510 DidFailProvisionalLoad(frame, error)); |
2510 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2511 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
2511 DidFailProvisionalLoad(error)); | 2512 DidFailProvisionalLoad(error)); |
2512 | 2513 |
2513 bool show_repost_interstitial = | 2514 SendFailedProvisionalLoad(failed_request, error, frame); |
2514 (error.reason == net::ERR_CACHE_MISS && | |
2515 EqualsASCII(failed_request.httpMethod(), "POST")); | |
2516 | 2515 |
2517 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 2516 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) |
2518 params.error_code = error.reason; | |
2519 GetContentClient()->renderer()->GetNavigationErrorStrings( | |
2520 render_view_.get(), | |
2521 frame, | |
2522 failed_request, | |
2523 error, | |
2524 NULL, | |
2525 ¶ms.error_description); | |
2526 params.url = error.unreachableURL; | |
2527 params.showing_repost_interstitial = show_repost_interstitial; | |
2528 Send(new FrameHostMsg_DidFailProvisionalLoadWithError( | |
2529 routing_id_, params)); | |
2530 | |
2531 // Don't display an error page if this is simply a cancelled load. Aside | |
2532 // from being dumb, Blink doesn't expect it and it will cause a crash. | |
2533 if (error.reason == net::ERR_ABORTED) | |
2534 return; | 2517 return; |
2535 | 2518 |
2536 // Don't display "client blocked" error page if browser has asked us not to. | |
2537 if (error.reason == net::ERR_BLOCKED_BY_CLIENT && | |
2538 render_view_->renderer_preferences_.disable_client_blocked_error_page) { | |
2539 return; | |
2540 } | |
2541 | |
2542 // Allow the embedder to suppress an error page. | |
2543 if (GetContentClient()->renderer()->ShouldSuppressErrorPage(this, | |
2544 error.unreachableURL)) { | |
2545 return; | |
2546 } | |
2547 | |
2548 if (RenderThreadImpl::current() && | |
2549 RenderThreadImpl::current()->layout_test_mode()) { | |
2550 return; | |
2551 } | |
2552 | |
2553 // Make sure we never show errors in view source mode. | 2519 // Make sure we never show errors in view source mode. |
2554 frame->enableViewSourceMode(false); | 2520 frame->enableViewSourceMode(false); |
2555 | 2521 |
2556 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2522 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2557 NavigationStateImpl* navigation_state = | 2523 NavigationStateImpl* navigation_state = |
2558 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2524 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2559 | 2525 |
2560 // If this is a failed back/forward/reload navigation, then we need to do a | 2526 // If this is a failed back/forward/reload navigation, then we need to do a |
2561 // 'replace' load. This is necessary to avoid messing up session history. | 2527 // 'replace' load. This is necessary to avoid messing up session history. |
2562 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2528 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 request.setCheckForBrowserSideNavigation(false); | 4027 request.setCheckForBrowserSideNavigation(false); |
4062 | 4028 |
4063 // Record this before starting the load. A lower bound of this time is needed | 4029 // Record this before starting the load. A lower bound of this time is needed |
4064 // to sanitize the navigationStart override set below. | 4030 // to sanitize the navigationStart override set below. |
4065 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 4031 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
4066 frame_->loadRequest(request); | 4032 frame_->loadRequest(request); |
4067 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, | 4033 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, |
4068 renderer_navigation_start); | 4034 renderer_navigation_start); |
4069 } | 4035 } |
4070 | 4036 |
| 4037 void RenderFrameImpl::OnFailedNavigation( |
| 4038 const CommonNavigationParams& common_params, |
| 4039 const RequestNavigationParams& request_params, |
| 4040 bool has_stale_copy_in_cache, |
| 4041 int error_code) { |
| 4042 bool is_reload = IsReload(common_params.navigation_type); |
| 4043 bool is_history_navigation = request_params.page_state.IsValid(); |
| 4044 WebURLRequest::CachePolicy cache_policy = |
| 4045 WebURLRequest::UseProtocolCachePolicy; |
| 4046 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
| 4047 common_params.url, is_history_navigation, request_params, &is_reload, |
| 4048 &cache_policy)) { |
| 4049 return; |
| 4050 } |
| 4051 |
| 4052 GetContentClient()->SetActiveURL(common_params.url); |
| 4053 |
| 4054 pending_navigation_params_.reset(new NavigationParams( |
| 4055 common_params, StartNavigationParams(), request_params)); |
| 4056 |
| 4057 // Inform the browser of the start of the provisional load. This is needed so |
| 4058 // that the load is properly tracked by the WebNavigation API. |
| 4059 // TODO(clamy): Properly set is_transition_navigation. |
| 4060 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
| 4061 routing_id_, common_params.url, false)); |
| 4062 |
| 4063 // Send the provisional load failure. |
| 4064 blink::WebURLError error = |
| 4065 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 4066 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 4067 common_params, scoped_ptr<StreamOverrideParameters>(), |
| 4068 frame_->isViewSourceModeEnabled()); |
| 4069 SendFailedProvisionalLoad(failed_request, error, frame_); |
| 4070 |
| 4071 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) |
| 4072 return; |
| 4073 |
| 4074 // Make sure errors are not shown in view source mode. |
| 4075 frame_->enableViewSourceMode(false); |
| 4076 |
| 4077 // Replace the current history entry in reloads, history navigations and loads |
| 4078 // of the same url. This corresponds to Blink's notion of a standard |
| 4079 // commit. |
| 4080 // TODO(clamy): see if initial commits in subframes should be handled |
| 4081 // separately. |
| 4082 bool replace = is_reload || is_history_navigation || |
| 4083 common_params.url == GetLoadingUrl(); |
| 4084 LoadNavigationErrorPage(failed_request, error, replace); |
| 4085 } |
| 4086 |
4071 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 4087 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
4072 RenderFrame* render_frame, | 4088 RenderFrame* render_frame, |
4073 const NavigationPolicyInfo& info) { | 4089 const NavigationPolicyInfo& info) { |
4074 #ifdef OS_ANDROID | 4090 #ifdef OS_ANDROID |
4075 // The handlenavigation API is deprecated and will be removed once | 4091 // The handlenavigation API is deprecated and will be removed once |
4076 // crbug.com/325351 is resolved. | 4092 // crbug.com/325351 is resolved. |
4077 if (info.urlRequest.url() != GURL(kSwappedOutURL) && | 4093 if (info.urlRequest.url() != GURL(kSwappedOutURL) && |
4078 GetContentClient()->renderer()->HandleNavigation( | 4094 GetContentClient()->renderer()->HandleNavigation( |
4079 render_frame, | 4095 render_frame, |
4080 static_cast<DocumentState*>(info.extraData), | 4096 static_cast<DocumentState*>(info.extraData), |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4558 WebString::fromUTF8(charset), | 4574 WebString::fromUTF8(charset), |
4559 base_url, | 4575 base_url, |
4560 params.history_url_for_data_url, | 4576 params.history_url_for_data_url, |
4561 false); | 4577 false); |
4562 } else { | 4578 } else { |
4563 CHECK(false) << "Invalid URL passed: " | 4579 CHECK(false) << "Invalid URL passed: " |
4564 << params.url.possibly_invalid_spec(); | 4580 << params.url.possibly_invalid_spec(); |
4565 } | 4581 } |
4566 } | 4582 } |
4567 | 4583 |
| 4584 void RenderFrameImpl::SendFailedProvisionalLoad( |
| 4585 const blink::WebURLRequest& request, |
| 4586 const blink::WebURLError& error, |
| 4587 blink::WebLocalFrame* frame) { |
| 4588 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && |
| 4589 EqualsASCII(request.httpMethod(), "POST")); |
| 4590 |
| 4591 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 4592 params.error_code = error.reason; |
| 4593 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 4594 render_view_.get(), frame, request, error, NULL, |
| 4595 ¶ms.error_description); |
| 4596 params.url = error.unreachableURL; |
| 4597 params.showing_repost_interstitial = show_repost_interstitial; |
| 4598 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); |
| 4599 } |
| 4600 |
| 4601 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( |
| 4602 int error_code, |
| 4603 const GURL& unreachable_url) { |
| 4604 // Don't display an error page if this is simply a cancelled load. Aside |
| 4605 // from being dumb, Blink doesn't expect it and it will cause a crash. |
| 4606 if (error_code == net::ERR_ABORTED) |
| 4607 return false; |
| 4608 |
| 4609 // Don't display "client blocked" error page if browser has asked us not to. |
| 4610 if (error_code == net::ERR_BLOCKED_BY_CLIENT && |
| 4611 render_view_->renderer_preferences_.disable_client_blocked_error_page) { |
| 4612 return false; |
| 4613 } |
| 4614 |
| 4615 // Allow the embedder to suppress an error page. |
| 4616 if (GetContentClient()->renderer()->ShouldSuppressErrorPage( |
| 4617 this, unreachable_url)) { |
| 4618 return false; |
| 4619 } |
| 4620 |
| 4621 if (RenderThreadImpl::current() && |
| 4622 RenderThreadImpl::current()->layout_test_mode()) { |
| 4623 return false; |
| 4624 } |
| 4625 |
| 4626 return true; |
| 4627 } |
| 4628 |
4568 GURL RenderFrameImpl::GetLoadingUrl() const { | 4629 GURL RenderFrameImpl::GetLoadingUrl() const { |
4569 WebDataSource* ds = frame_->dataSource(); | 4630 WebDataSource* ds = frame_->dataSource(); |
4570 if (ds->hasUnreachableURL()) | 4631 if (ds->hasUnreachableURL()) |
4571 return ds->unreachableURL(); | 4632 return ds->unreachableURL(); |
4572 | 4633 |
4573 const WebURLRequest& request = ds->request(); | 4634 const WebURLRequest& request = ds->request(); |
4574 return request.url(); | 4635 return request.url(); |
4575 } | 4636 } |
4576 | 4637 |
4577 void RenderFrameImpl::PopulateDocumentStateFromPending( | 4638 void RenderFrameImpl::PopulateDocumentStateFromPending( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4622 // initiated any load resulting from JS execution. | 4683 // initiated any load resulting from JS execution. |
4623 if (!pending_navigation_params_->common_params.url.SchemeIs( | 4684 if (!pending_navigation_params_->common_params.url.SchemeIs( |
4624 url::kJavaScriptScheme)) { | 4685 url::kJavaScriptScheme)) { |
4625 return NavigationStateImpl::CreateBrowserInitiated( | 4686 return NavigationStateImpl::CreateBrowserInitiated( |
4626 pending_navigation_params_->common_params, | 4687 pending_navigation_params_->common_params, |
4627 pending_navigation_params_->start_params, | 4688 pending_navigation_params_->start_params, |
4628 pending_navigation_params_->request_params); | 4689 pending_navigation_params_->request_params); |
4629 } | 4690 } |
4630 return NavigationStateImpl::CreateContentInitiated(); | 4691 return NavigationStateImpl::CreateContentInitiated(); |
4631 } | 4692 } |
| 4693 |
4632 #if defined(OS_ANDROID) | 4694 #if defined(OS_ANDROID) |
4633 | 4695 |
4634 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( | 4696 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( |
4635 const blink::WebURL& url, | 4697 const blink::WebURL& url, |
4636 WebMediaPlayerClient* client, | 4698 WebMediaPlayerClient* client, |
4637 media::MediaPermission* media_permission, | 4699 media::MediaPermission* media_permission, |
4638 blink::WebContentDecryptionModule* initial_cdm) { | 4700 blink::WebContentDecryptionModule* initial_cdm) { |
4639 GpuChannelHost* gpu_channel_host = | 4701 GpuChannelHost* gpu_channel_host = |
4640 RenderThreadImpl::current()->EstablishGpuChannelSync( | 4702 RenderThreadImpl::current()->EstablishGpuChannelSync( |
4641 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 4703 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4696 #elif defined(ENABLE_BROWSER_CDMS) | 4758 #elif defined(ENABLE_BROWSER_CDMS) |
4697 cdm_manager_, | 4759 cdm_manager_, |
4698 #endif | 4760 #endif |
4699 this); | 4761 this); |
4700 } | 4762 } |
4701 | 4763 |
4702 return cdm_factory_; | 4764 return cdm_factory_; |
4703 } | 4765 } |
4704 | 4766 |
4705 } // namespace content | 4767 } // namespace content |
OLD | NEW |