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 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3334 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3334 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
3335 } | 3335 } |
3336 | 3336 |
3337 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, | 3337 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, |
3338 blink::WebIconURL::Type icon_type) { | 3338 blink::WebIconURL::Type icon_type) { |
3339 DCHECK_EQ(frame_, frame); | 3339 DCHECK_EQ(frame_, frame); |
3340 // TODO(nasko): Investigate wheather implementation should move here. | 3340 // TODO(nasko): Investigate wheather implementation should move here. |
3341 render_view_->didChangeIcon(frame, icon_type); | 3341 render_view_->didChangeIcon(frame, icon_type); |
3342 } | 3342 } |
3343 | 3343 |
3344 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame, | 3344 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
3345 bool document_is_empty) { | |
3346 TRACE_EVENT1("navigation,benchmark", "RenderFrameImpl::didFinishDocumentLoad", | 3345 TRACE_EVENT1("navigation,benchmark", "RenderFrameImpl::didFinishDocumentLoad", |
3347 "id", routing_id_); | 3346 "id", routing_id_); |
3348 DCHECK_EQ(frame_, frame); | 3347 DCHECK_EQ(frame_, frame); |
3349 WebDataSource* ds = frame->dataSource(); | 3348 WebDataSource* ds = frame->dataSource(); |
3350 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3349 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3351 document_state->set_finish_document_load_time(Time::Now()); | 3350 document_state->set_finish_document_load_time(Time::Now()); |
3352 | 3351 |
3353 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); | 3352 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); |
3354 | 3353 |
3355 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 3354 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
3356 DidFinishDocumentLoad(frame)); | 3355 DidFinishDocumentLoad(frame)); |
3357 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); | 3356 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); |
3358 | 3357 |
3359 // Check whether we have new encoding name. | 3358 // Check whether we have new encoding name. |
3360 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3359 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 3360 } |
| 3361 |
| 3362 void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame, |
| 3363 bool document_is_empty) { |
| 3364 DCHECK_EQ(frame_, frame); |
| 3365 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); |
| 3366 |
| 3367 MojoBindingsController* mojo_bindings_controller = |
| 3368 MojoBindingsController::Get(this); |
| 3369 if (mojo_bindings_controller) |
| 3370 mojo_bindings_controller->RunScriptsAtDocumentReady(); |
| 3371 |
| 3372 if (!weak_self.get()) |
| 3373 return; |
| 3374 |
| 3375 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); |
| 3376 |
| 3377 // ContentClient might have deleted |frame| and |this| by now! |
| 3378 if (!weak_self.get()) |
| 3379 return; |
3361 | 3380 |
3362 // If this is an empty document with an http status code indicating an error, | 3381 // If this is an empty document with an http status code indicating an error, |
3363 // we may want to display our own error page, so the user doesn't end up | 3382 // we may want to display our own error page, so the user doesn't end up |
3364 // with an unexplained blank page. | 3383 // with an unexplained blank page. |
3365 if (!document_is_empty) | 3384 if (!document_is_empty) |
3366 return; | 3385 return; |
3367 | 3386 |
3368 // Do not show error page when DevTools is attached. | 3387 // Do not show error page when DevTools is attached. |
3369 RenderFrameImpl* localRoot = this; | 3388 RenderFrameImpl* localRoot = this; |
3370 while (localRoot->frame_ && localRoot->frame_->parent() && | 3389 while (localRoot->frame_ && localRoot->frame_->parent() && |
3371 localRoot->frame_->parent()->isWebLocalFrame()) { | 3390 localRoot->frame_->parent()->isWebLocalFrame()) { |
3372 localRoot = RenderFrameImpl::FromWebFrame(localRoot->frame_->parent()); | 3391 localRoot = RenderFrameImpl::FromWebFrame(localRoot->frame_->parent()); |
3373 DCHECK(localRoot); | 3392 DCHECK(localRoot); |
3374 } | 3393 } |
3375 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) | 3394 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) |
3376 return; | 3395 return; |
3377 | 3396 |
3378 // Display error page instead of a blank page, if appropriate. | 3397 // Display error page instead of a blank page, if appropriate. |
3379 std::string error_domain = "http"; | 3398 std::string error_domain = "http"; |
3380 InternalDocumentStateData* internal_data = | 3399 InternalDocumentStateData* internal_data = |
3381 InternalDocumentStateData::FromDataSource(frame->dataSource()); | 3400 InternalDocumentStateData::FromDataSource(frame->dataSource()); |
3382 int http_status_code = internal_data->http_status_code(); | 3401 int http_status_code = internal_data->http_status_code(); |
3383 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, | 3402 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, |
3384 &error_domain)) { | 3403 &error_domain)) { |
3385 WebURLError error; | 3404 WebURLError error; |
3386 error.unreachableURL = frame->document().url(); | 3405 error.unreachableURL = frame->document().url(); |
3387 error.domain = WebString::fromUTF8(error_domain); | 3406 error.domain = WebString::fromUTF8(error_domain); |
3388 error.reason = http_status_code; | 3407 error.reason = http_status_code; |
| 3408 // This call may run scripts, e.g. via the beforeunload event. |
3389 LoadNavigationErrorPage(frame->dataSource()->request(), error, true); | 3409 LoadNavigationErrorPage(frame->dataSource()->request(), error, true); |
3390 } | 3410 } |
3391 } | 3411 // Do not use |this| or |frame| here without checking |weak_self|. |
3392 | |
3393 void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame) { | |
3394 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); | |
3395 | |
3396 MojoBindingsController* mojo_bindings_controller = | |
3397 MojoBindingsController::Get(this); | |
3398 if (mojo_bindings_controller) | |
3399 mojo_bindings_controller->RunScriptsAtDocumentReady(); | |
3400 | |
3401 if (!weak_self.get()) | |
3402 return; | |
3403 | |
3404 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); | |
3405 // Do not use |this| or |frame|! ContentClient might have deleted them by now! | |
3406 } | 3412 } |
3407 | 3413 |
3408 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 3414 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
3409 DCHECK_EQ(frame_, frame); | 3415 DCHECK_EQ(frame_, frame); |
3410 if (!frame->parent()) { | 3416 if (!frame->parent()) { |
3411 FrameMsg_UILoadMetricsReportType::Value report_type = | 3417 FrameMsg_UILoadMetricsReportType::Value report_type = |
3412 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 3418 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
3413 frame->dataSource()->request().inputPerfMetricReportPolicy()); | 3419 frame->dataSource()->request().inputPerfMetricReportPolicy()); |
3414 base::TimeTicks ui_timestamp = base::TimeTicks() + | 3420 base::TimeTicks ui_timestamp = base::TimeTicks() + |
3415 base::TimeDelta::FromSecondsD( | 3421 base::TimeDelta::FromSecondsD( |
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6006 int match_count, | 6012 int match_count, |
6007 int ordinal, | 6013 int ordinal, |
6008 const WebRect& selection_rect, | 6014 const WebRect& selection_rect, |
6009 bool final_status_update) { | 6015 bool final_status_update) { |
6010 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6016 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6011 selection_rect, ordinal, | 6017 selection_rect, ordinal, |
6012 final_status_update)); | 6018 final_status_update)); |
6013 } | 6019 } |
6014 | 6020 |
6015 } // namespace content | 6021 } // namespace content |
OLD | NEW |