| 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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 is_pasting_(false), | 1073 is_pasting_(false), |
| 1074 suppress_further_dialogs_(false), | 1074 suppress_further_dialogs_(false), |
| 1075 blame_context_(nullptr), | 1075 blame_context_(nullptr), |
| 1076 #if defined(ENABLE_PLUGINS) | 1076 #if defined(ENABLE_PLUGINS) |
| 1077 focused_pepper_plugin_(nullptr), | 1077 focused_pepper_plugin_(nullptr), |
| 1078 pepper_last_mouse_event_target_(nullptr), | 1078 pepper_last_mouse_event_target_(nullptr), |
| 1079 #endif | 1079 #endif |
| 1080 frame_binding_(this), | 1080 frame_binding_(this), |
| 1081 has_accessed_initial_document_(false), | 1081 has_accessed_initial_document_(false), |
| 1082 weak_factory_(this) { | 1082 weak_factory_(this) { |
| 1083 LOG(ERROR) << "RF[" << this << "]::RF: " |
| 1084 << " routing_id:" << routing_id_; |
| 1085 |
| 1083 // We don't have a shell::Connection at this point, so use nullptr. | 1086 // We don't have a shell::Connection at this point, so use nullptr. |
| 1084 // TODO(beng): We should fix this, so we can apply policy about which | 1087 // TODO(beng): We should fix this, so we can apply policy about which |
| 1085 // interfaces get exposed. | 1088 // interfaces get exposed. |
| 1086 interface_registry_.reset(new shell::InterfaceRegistry); | 1089 interface_registry_.reset(new shell::InterfaceRegistry); |
| 1087 shell::mojom::InterfaceProviderPtr remote_interfaces; | 1090 shell::mojom::InterfaceProviderPtr remote_interfaces; |
| 1088 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); | 1091 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); |
| 1089 remote_interfaces_.reset(new shell::InterfaceProvider); | 1092 remote_interfaces_.reset(new shell::InterfaceProvider); |
| 1090 remote_interfaces_->Bind(std::move(remote_interfaces)); | 1093 remote_interfaces_->Bind(std::move(remote_interfaces)); |
| 1091 blink_interface_provider_.reset(new BlinkInterfaceProviderImpl( | 1094 blink_interface_provider_.reset(new BlinkInterfaceProviderImpl( |
| 1092 remote_interfaces_->GetWeakPtr())); | 1095 remote_interfaces_->GetWeakPtr())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 // Ensure the RenderView doesn't point to this object, once it is destroyed. | 1147 // Ensure the RenderView doesn't point to this object, once it is destroyed. |
| 1145 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_| | 1148 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_| |
| 1146 // is |this|, once the object is no longer leaked. | 1149 // is |this|, once the object is no longer leaked. |
| 1147 // See https://crbug.com/464764. | 1150 // See https://crbug.com/464764. |
| 1148 render_view_->main_render_frame_ = nullptr; | 1151 render_view_->main_render_frame_ = nullptr; |
| 1149 } | 1152 } |
| 1150 | 1153 |
| 1151 render_view_->UnregisterRenderFrame(this); | 1154 render_view_->UnregisterRenderFrame(this); |
| 1152 g_routing_id_frame_map.Get().erase(routing_id_); | 1155 g_routing_id_frame_map.Get().erase(routing_id_); |
| 1153 RenderThread::Get()->RemoveRoute(routing_id_); | 1156 RenderThread::Get()->RemoveRoute(routing_id_); |
| 1157 LOG(ERROR) << "RF[" << this << "]::~RF"; |
| 1154 } | 1158 } |
| 1155 | 1159 |
| 1156 void RenderFrameImpl::BindToWebFrame(blink::WebLocalFrame* web_frame) { | 1160 void RenderFrameImpl::BindToWebFrame(blink::WebLocalFrame* web_frame) { |
| 1157 DCHECK(!frame_); | 1161 DCHECK(!frame_); |
| 1158 | 1162 |
| 1159 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( | 1163 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( |
| 1160 std::make_pair(web_frame, this)); | 1164 std::make_pair(web_frame, this)); |
| 1161 CHECK(result.second) << "Inserting a duplicate item."; | 1165 CHECK(result.second) << "Inserting a duplicate item."; |
| 1162 | 1166 |
| 1163 frame_ = web_frame; | 1167 frame_ = web_frame; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 // the process based on the lifetime of this RenderFrameImpl object. | 1708 // the process based on the lifetime of this RenderFrameImpl object. |
| 1705 if (is_main_frame) | 1709 if (is_main_frame) |
| 1706 render_view->WasSwappedOut(); | 1710 render_view->WasSwappedOut(); |
| 1707 | 1711 |
| 1708 // Notify the browser that this frame was swapped. Use the RenderThread | 1712 // Notify the browser that this frame was swapped. Use the RenderThread |
| 1709 // directly because |this| is deleted. | 1713 // directly because |this| is deleted. |
| 1710 RenderThread::Get()->Send(new FrameHostMsg_SwapOut_ACK(routing_id)); | 1714 RenderThread::Get()->Send(new FrameHostMsg_SwapOut_ACK(routing_id)); |
| 1711 } | 1715 } |
| 1712 | 1716 |
| 1713 void RenderFrameImpl::OnDeleteFrame() { | 1717 void RenderFrameImpl::OnDeleteFrame() { |
| 1718 LOG(ERROR) << "RF[" << this << "]::OnDeleteFrame:"; |
| 1719 |
| 1714 // TODO(nasko): If this message is received right after a commit has | 1720 // TODO(nasko): If this message is received right after a commit has |
| 1715 // swapped a RenderFrameProxy with this RenderFrame, the proxy needs to be | 1721 // swapped a RenderFrameProxy with this RenderFrame, the proxy needs to be |
| 1716 // recreated in addition to the RenderFrame being deleted. | 1722 // recreated in addition to the RenderFrame being deleted. |
| 1717 // See https://crbug.com/569683 for details. | 1723 // See https://crbug.com/569683 for details. |
| 1718 in_browser_initiated_detach_ = true; | 1724 in_browser_initiated_detach_ = true; |
| 1719 | 1725 |
| 1720 // This will result in a call to RendeFrameImpl::frameDetached, which | 1726 // This will result in a call to RendeFrameImpl::frameDetached, which |
| 1721 // deletes the object. Do not access |this| after detach. | 1727 // deletes the object. Do not access |this| after detach. |
| 1722 frame_->detach(); | 1728 frame_->detach(); |
| 1723 } | 1729 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 surroundingText.textContent(), | 2222 surroundingText.textContent(), |
| 2217 surroundingText.startOffsetInTextContent(), | 2223 surroundingText.startOffsetInTextContent(), |
| 2218 surroundingText.endOffsetInTextContent())); | 2224 surroundingText.endOffsetInTextContent())); |
| 2219 } | 2225 } |
| 2220 | 2226 |
| 2221 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2227 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| 2222 const base::string16& message, | 2228 const base::string16& message, |
| 2223 const base::string16& default_value, | 2229 const base::string16& default_value, |
| 2224 const GURL& frame_url, | 2230 const GURL& frame_url, |
| 2225 base::string16* result) { | 2231 base::string16* result) { |
| 2232 LOG(ERROR) << "RF[" << this << "]::RunJavaScriptMessage: " |
| 2233 << " suppress:" << suppress_further_dialogs_; |
| 2234 |
| 2226 // Don't allow further dialogs if we are waiting to swap out, since the | 2235 // Don't allow further dialogs if we are waiting to swap out, since the |
| 2227 // ScopedPageLoadDeferrer in our stack prevents it. | 2236 // ScopedPageLoadDeferrer in our stack prevents it. |
| 2228 if (suppress_further_dialogs_) | 2237 if (suppress_further_dialogs_) |
| 2229 return false; | 2238 return false; |
| 2230 | 2239 |
| 2231 bool success = false; | 2240 bool success = false; |
| 2232 base::string16 result_temp; | 2241 base::string16 result_temp; |
| 2233 if (!result) | 2242 if (!result) |
| 2234 result = &result_temp; | 2243 result = &result_temp; |
| 2235 | 2244 |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 DCHECK(!opener || opener->isWebLocalFrame()); | 2826 DCHECK(!opener || opener->isWebLocalFrame()); |
| 2818 | 2827 |
| 2819 int opener_routing_id = opener ? | 2828 int opener_routing_id = opener ? |
| 2820 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() : | 2829 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() : |
| 2821 MSG_ROUTING_NONE; | 2830 MSG_ROUTING_NONE; |
| 2822 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); | 2831 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); |
| 2823 } | 2832 } |
| 2824 | 2833 |
| 2825 void RenderFrameImpl::frameDetached(blink::WebLocalFrame* frame, | 2834 void RenderFrameImpl::frameDetached(blink::WebLocalFrame* frame, |
| 2826 DetachType type) { | 2835 DetachType type) { |
| 2836 LOG(ERROR) << "RF[" << this << "]::frameDetached: " |
| 2837 << " type:" << static_cast<int>(type); |
| 2838 |
| 2827 // NOTE: This function is called on the frame that is being detached and not | 2839 // NOTE: This function is called on the frame that is being detached and not |
| 2828 // the parent frame. This is different from createChildFrame() which is | 2840 // the parent frame. This is different from createChildFrame() which is |
| 2829 // called on the parent frame. | 2841 // called on the parent frame. |
| 2830 DCHECK_EQ(frame_, frame); | 2842 DCHECK_EQ(frame_, frame); |
| 2831 | 2843 |
| 2832 #if defined(ENABLE_PLUGINS) | 2844 #if defined(ENABLE_PLUGINS) |
| 2833 if (focused_pepper_plugin_) | 2845 if (focused_pepper_plugin_) |
| 2834 GetRenderWidget()->set_focused_pepper_plugin(nullptr); | 2846 GetRenderWidget()->set_focused_pepper_plugin(nullptr); |
| 2835 #endif | 2847 #endif |
| 2836 | 2848 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 3206 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 3195 // callback is invoked. | 3207 // callback is invoked. |
| 3196 if (!ds) | 3208 if (!ds) |
| 3197 return; | 3209 return; |
| 3198 | 3210 |
| 3199 TRACE_EVENT2("navigation,benchmark,rail", | 3211 TRACE_EVENT2("navigation,benchmark,rail", |
| 3200 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 3212 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
| 3201 "url", ds->request().url().string().utf8()); | 3213 "url", ds->request().url().string().utf8()); |
| 3202 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3214 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3203 | 3215 |
| 3216 LOG(ERROR) << "RF[" << this << "]::didStartProvisionalLoad: " |
| 3217 << " url:" << ds->request().url().string().utf8().substr(0, 250); |
| 3218 |
| 3204 // Update the request time if WebKit has better knowledge of it. | 3219 // Update the request time if WebKit has better knowledge of it. |
| 3205 if (document_state->request_time().is_null() && | 3220 if (document_state->request_time().is_null() && |
| 3206 triggering_event_time != 0.0) { | 3221 triggering_event_time != 0.0) { |
| 3207 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); | 3222 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); |
| 3208 } | 3223 } |
| 3209 | 3224 |
| 3210 // Start time is only set after request time. | 3225 // Start time is only set after request time. |
| 3211 document_state->set_start_load_time(Time::Now()); | 3226 document_state->set_start_load_time(Time::Now()); |
| 3212 | 3227 |
| 3213 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | 3228 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3233 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); | 3248 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); |
| 3234 | 3249 |
| 3235 Send(new FrameHostMsg_DidStartProvisionalLoad( | 3250 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 3236 routing_id_, ds->request().url(), navigation_start)); | 3251 routing_id_, ds->request().url(), navigation_start)); |
| 3237 } | 3252 } |
| 3238 | 3253 |
| 3239 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 3254 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 3240 blink::WebLocalFrame* frame) { | 3255 blink::WebLocalFrame* frame) { |
| 3241 DCHECK_EQ(frame_, frame); | 3256 DCHECK_EQ(frame_, frame); |
| 3242 | 3257 |
| 3258 LOG(ERROR) << "RF[" << this << "]::didReceiveServerRedirectForProvisionalLoad:
"; |
| 3259 |
| 3243 // We don't use HistoryController in OOPIF enabled modes. | 3260 // We don't use HistoryController in OOPIF enabled modes. |
| 3244 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3261 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 3245 return; | 3262 return; |
| 3246 | 3263 |
| 3247 render_view_->history_controller()->RemoveChildrenForRedirect(this); | 3264 render_view_->history_controller()->RemoveChildrenForRedirect(this); |
| 3248 } | 3265 } |
| 3249 | 3266 |
| 3250 void RenderFrameImpl::didFailProvisionalLoad( | 3267 void RenderFrameImpl::didFailProvisionalLoad( |
| 3251 blink::WebLocalFrame* frame, | 3268 blink::WebLocalFrame* frame, |
| 3252 const blink::WebURLError& error, | 3269 const blink::WebURLError& error, |
| 3253 blink::WebHistoryCommitType commit_type) { | 3270 blink::WebHistoryCommitType commit_type) { |
| 3254 TRACE_EVENT1("navigation,benchmark,rail", | 3271 TRACE_EVENT1("navigation,benchmark,rail", |
| 3255 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); | 3272 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); |
| 3256 DCHECK_EQ(frame_, frame); | 3273 DCHECK_EQ(frame_, frame); |
| 3257 WebDataSource* ds = frame->provisionalDataSource(); | 3274 WebDataSource* ds = frame->provisionalDataSource(); |
| 3258 DCHECK(ds); | 3275 DCHECK(ds); |
| 3259 | 3276 |
| 3277 LOG(ERROR) << "RF[" << this << "]::didFailProvisionalLoad: " |
| 3278 << " url:" << ds->request().url().string().utf8().substr(0, 250); |
| 3279 |
| 3260 const WebURLRequest& failed_request = ds->request(); | 3280 const WebURLRequest& failed_request = ds->request(); |
| 3261 | 3281 |
| 3262 // Notify the browser that we failed a provisional load with an error. | 3282 // Notify the browser that we failed a provisional load with an error. |
| 3263 // | 3283 // |
| 3264 // Note: It is important this notification occur before DidStopLoading so the | 3284 // Note: It is important this notification occur before DidStopLoading so the |
| 3265 // SSL manager can react to the provisional load failure before being | 3285 // SSL manager can react to the provisional load failure before being |
| 3266 // notified the load stopped. | 3286 // notified the load stopped. |
| 3267 // | 3287 // |
| 3268 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 3288 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 3269 DidFailProvisionalLoad(frame, error)); | 3289 DidFailProvisionalLoad(frame, error)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 // change at commit time. | 3341 // change at commit time. |
| 3322 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3342 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
| 3323 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); | 3343 is_using_lofi_ = extra_data && extra_data->is_using_lofi(); |
| 3324 if (extra_data) { | 3344 if (extra_data) { |
| 3325 effective_connection_type_ = | 3345 effective_connection_type_ = |
| 3326 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3346 EffectiveConnectionTypeToWebEffectiveConnectionType( |
| 3327 extra_data->effective_connection_type()); | 3347 extra_data->effective_connection_type()); |
| 3328 } | 3348 } |
| 3329 } | 3349 } |
| 3330 | 3350 |
| 3351 LOG(ERROR) << "RF[" << this << "]::didCommitProvisionalLoad: " |
| 3352 << " url:" << GetLoadingUrl().spec().substr(0, 250); |
| 3353 |
| 3331 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3354 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
| 3332 RenderFrameProxy* proxy = | 3355 RenderFrameProxy* proxy = |
| 3333 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 3356 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
| 3334 | 3357 |
| 3335 // The proxy might have been detached while the provisional LocalFrame was | 3358 // The proxy might have been detached while the provisional LocalFrame was |
| 3336 // being navigated. In that case, don't swap the frame back in the tree | 3359 // being navigated. In that case, don't swap the frame back in the tree |
| 3337 // and return early (to avoid sending confusing IPCs to the browser | 3360 // and return early (to avoid sending confusing IPCs to the browser |
| 3338 // process). See https://crbug.com/526304 and https://crbug.com/568676. | 3361 // process). See https://crbug.com/526304 and https://crbug.com/568676. |
| 3339 // TODO(nasko, alexmos): Eventually, the browser process will send an IPC | 3362 // TODO(nasko, alexmos): Eventually, the browser process will send an IPC |
| 3340 // to clean this frame up after https://crbug.com/548275 is fixed. | 3363 // to clean this frame up after https://crbug.com/548275 is fixed. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3586 } | 3609 } |
| 3587 | 3610 |
| 3588 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { | 3611 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
| 3589 TRACE_EVENT1("navigation,benchmark,rail", | 3612 TRACE_EVENT1("navigation,benchmark,rail", |
| 3590 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_); | 3613 "RenderFrameImpl::didFinishDocumentLoad", "id", routing_id_); |
| 3591 DCHECK_EQ(frame_, frame); | 3614 DCHECK_EQ(frame_, frame); |
| 3592 WebDataSource* ds = frame->dataSource(); | 3615 WebDataSource* ds = frame->dataSource(); |
| 3593 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3616 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3594 document_state->set_finish_document_load_time(Time::Now()); | 3617 document_state->set_finish_document_load_time(Time::Now()); |
| 3595 | 3618 |
| 3619 LOG(ERROR) << "RF[" << this << "]::didFinishDocumentLoad: " |
| 3620 << " url:" << frame->document().url().string().utf8().substr(0, 250); |
| 3621 |
| 3596 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); | 3622 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); |
| 3597 | 3623 |
| 3598 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 3624 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 3599 DidFinishDocumentLoad(frame)); | 3625 DidFinishDocumentLoad(frame)); |
| 3600 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); | 3626 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); |
| 3601 | 3627 |
| 3602 // Check whether we have new encoding name. | 3628 // Check whether we have new encoding name. |
| 3603 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3629 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 3604 } | 3630 } |
| 3605 | 3631 |
| (...skipping 2745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6351 // event target. Potentially a Pepper plugin will receive the event. | 6377 // event target. Potentially a Pepper plugin will receive the event. |
| 6352 // In order to tell whether a plugin gets the last mouse event and which it | 6378 // In order to tell whether a plugin gets the last mouse event and which it |
| 6353 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6379 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6354 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6380 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6355 // |pepper_last_mouse_event_target_|. | 6381 // |pepper_last_mouse_event_target_|. |
| 6356 pepper_last_mouse_event_target_ = nullptr; | 6382 pepper_last_mouse_event_target_ = nullptr; |
| 6357 #endif | 6383 #endif |
| 6358 } | 6384 } |
| 6359 | 6385 |
| 6360 } // namespace content | 6386 } // namespace content |
| OLD | NEW |