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 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3893 | 3893 |
3894 for (auto& observer : render_view_->observers()) | 3894 for (auto& observer : render_view_->observers()) |
3895 observer.DidFinishDocumentLoad(frame); | 3895 observer.DidFinishDocumentLoad(frame); |
3896 for (auto& observer : observers_) | 3896 for (auto& observer : observers_) |
3897 observer.DidFinishDocumentLoad(); | 3897 observer.DidFinishDocumentLoad(); |
3898 | 3898 |
3899 // Check whether we have new encoding name. | 3899 // Check whether we have new encoding name. |
3900 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3900 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
3901 } | 3901 } |
3902 | 3902 |
3903 void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame, | 3903 void RenderFrameImpl::runScriptsAtDocumentReady(bool document_is_empty) { |
3904 bool document_is_empty) { | |
3905 DCHECK_EQ(frame_, frame); | |
3906 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); | 3904 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); |
3907 | 3905 |
3908 MojoBindingsController* mojo_bindings_controller = | 3906 MojoBindingsController* mojo_bindings_controller = |
3909 MojoBindingsController::Get(this); | 3907 MojoBindingsController::Get(this); |
3910 if (mojo_bindings_controller) | 3908 if (mojo_bindings_controller) |
3911 mojo_bindings_controller->RunScriptsAtDocumentReady(); | 3909 mojo_bindings_controller->RunScriptsAtDocumentReady(); |
3912 | 3910 |
3913 if (!weak_self.get()) | 3911 if (!weak_self.get()) |
3914 return; | 3912 return; |
3915 | 3913 |
3916 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); | 3914 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); |
3917 | 3915 |
3918 // ContentClient might have deleted |frame| and |this| by now! | 3916 // ContentClient might have deleted |frame_| and |this| by now! |
3919 if (!weak_self.get()) | 3917 if (!weak_self.get()) |
3920 return; | 3918 return; |
3921 | 3919 |
3922 // If this is an empty document with an http status code indicating an error, | 3920 // If this is an empty document with an http status code indicating an error, |
3923 // we may want to display our own error page, so the user doesn't end up | 3921 // we may want to display our own error page, so the user doesn't end up |
3924 // with an unexplained blank page. | 3922 // with an unexplained blank page. |
3925 if (!document_is_empty) | 3923 if (!document_is_empty) |
3926 return; | 3924 return; |
3927 | 3925 |
3928 // Do not show error page when DevTools is attached. | 3926 // Do not show error page when DevTools is attached. |
3929 const RenderFrameImpl* localRoot = GetLocalRoot(); | 3927 const RenderFrameImpl* localRoot = GetLocalRoot(); |
3930 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) | 3928 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) |
3931 return; | 3929 return; |
3932 | 3930 |
3933 // Display error page instead of a blank page, if appropriate. | 3931 // Display error page instead of a blank page, if appropriate. |
3934 std::string error_domain = "http"; | 3932 std::string error_domain = "http"; |
3935 InternalDocumentStateData* internal_data = | 3933 InternalDocumentStateData* internal_data = |
3936 InternalDocumentStateData::FromDataSource(frame->dataSource()); | 3934 InternalDocumentStateData::FromDataSource(frame_->dataSource()); |
3937 int http_status_code = internal_data->http_status_code(); | 3935 int http_status_code = internal_data->http_status_code(); |
3938 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, | 3936 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, |
3939 &error_domain)) { | 3937 &error_domain)) { |
3940 WebURLError error; | 3938 WebURLError error; |
3941 error.unreachableURL = frame->document().url(); | 3939 error.unreachableURL = frame_->document().url(); |
3942 error.domain = WebString::fromUTF8(error_domain); | 3940 error.domain = WebString::fromUTF8(error_domain); |
3943 error.reason = http_status_code; | 3941 error.reason = http_status_code; |
3944 // This call may run scripts, e.g. via the beforeunload event. | 3942 // This call may run scripts, e.g. via the beforeunload event. |
3945 LoadNavigationErrorPage(frame->dataSource()->getRequest(), error, true, | 3943 LoadNavigationErrorPage(frame_->dataSource()->getRequest(), error, true, |
3946 nullptr); | 3944 nullptr); |
3947 } | 3945 } |
3948 // Do not use |this| or |frame| here without checking |weak_self|. | 3946 // Do not use |this| or |frame_| here without checking |weak_self|. |
3949 } | 3947 } |
3950 | 3948 |
3951 void RenderFrameImpl::runScriptsAtDocumentIdle(blink::WebLocalFrame* frame) { | 3949 void RenderFrameImpl::runScriptsAtDocumentIdle(blink::WebLocalFrame* frame) { |
3952 DCHECK_EQ(frame_, frame); | 3950 DCHECK_EQ(frame_, frame); |
3953 GetContentClient()->renderer()->RunScriptsAtDocumentIdle(this); | 3951 GetContentClient()->renderer()->RunScriptsAtDocumentIdle(this); |
3954 // ContentClient might have deleted |frame| and |this| by now! | 3952 // ContentClient might have deleted |frame| and |this| by now! |
3955 } | 3953 } |
3956 | 3954 |
3957 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 3955 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
3958 DCHECK_EQ(frame_, frame); | 3956 DCHECK_EQ(frame_, frame); |
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6969 policy(info.defaultPolicy), | 6967 policy(info.defaultPolicy), |
6970 replaces_current_history_item(info.replacesCurrentHistoryItem), | 6968 replaces_current_history_item(info.replacesCurrentHistoryItem), |
6971 history_navigation_in_new_child_frame( | 6969 history_navigation_in_new_child_frame( |
6972 info.isHistoryNavigationInNewChildFrame), | 6970 info.isHistoryNavigationInNewChildFrame), |
6973 client_redirect(info.isClientRedirect), | 6971 client_redirect(info.isClientRedirect), |
6974 cache_disabled(info.isCacheDisabled), | 6972 cache_disabled(info.isCacheDisabled), |
6975 form(info.form), | 6973 form(info.form), |
6976 source_location(info.sourceLocation) {} | 6974 source_location(info.sourceLocation) {} |
6977 | 6975 |
6978 } // namespace content | 6976 } // namespace content |
OLD | NEW |