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 3386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3397 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3397 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
3398 } | 3398 } |
3399 | 3399 |
3400 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, | 3400 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, |
3401 blink::WebIconURL::Type icon_type) { | 3401 blink::WebIconURL::Type icon_type) { |
3402 DCHECK_EQ(frame_, frame); | 3402 DCHECK_EQ(frame_, frame); |
3403 // TODO(nasko): Investigate wheather implementation should move here. | 3403 // TODO(nasko): Investigate wheather implementation should move here. |
3404 render_view_->didChangeIcon(frame, icon_type); | 3404 render_view_->didChangeIcon(frame, icon_type); |
3405 } | 3405 } |
3406 | 3406 |
3407 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame, | 3407 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
3408 bool document_is_empty) { | |
3409 TRACE_EVENT1("navigation,benchmark", "RenderFrameImpl::didFinishDocumentLoad", | 3408 TRACE_EVENT1("navigation,benchmark", "RenderFrameImpl::didFinishDocumentLoad", |
3410 "id", routing_id_); | 3409 "id", routing_id_); |
3411 DCHECK_EQ(frame_, frame); | 3410 DCHECK_EQ(frame_, frame); |
3412 WebDataSource* ds = frame->dataSource(); | 3411 WebDataSource* ds = frame->dataSource(); |
3413 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3412 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3414 document_state->set_finish_document_load_time(Time::Now()); | 3413 document_state->set_finish_document_load_time(Time::Now()); |
3415 | 3414 |
3416 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); | 3415 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); |
3417 | 3416 |
3418 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 3417 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
3419 DidFinishDocumentLoad(frame)); | 3418 DidFinishDocumentLoad(frame)); |
3420 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); | 3419 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); |
3421 | 3420 |
3422 // Check whether we have new encoding name. | 3421 // Check whether we have new encoding name. |
3423 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3422 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 3423 } |
| 3424 |
| 3425 void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame, |
| 3426 bool document_is_empty) { |
| 3427 DCHECK_EQ(frame_, frame); |
| 3428 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); |
| 3429 |
| 3430 MojoBindingsController* mojo_bindings_controller = |
| 3431 MojoBindingsController::Get(this); |
| 3432 if (mojo_bindings_controller) |
| 3433 mojo_bindings_controller->RunScriptsAtDocumentReady(); |
| 3434 |
| 3435 if (!weak_self.get()) |
| 3436 return; |
| 3437 |
| 3438 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); |
| 3439 |
| 3440 // ContentClient might have deleted |frame| and |this| by now! |
| 3441 if (!weak_self.get()) |
| 3442 return; |
3424 | 3443 |
3425 // If this is an empty document with an http status code indicating an error, | 3444 // If this is an empty document with an http status code indicating an error, |
3426 // we may want to display our own error page, so the user doesn't end up | 3445 // we may want to display our own error page, so the user doesn't end up |
3427 // with an unexplained blank page. | 3446 // with an unexplained blank page. |
3428 if (!document_is_empty) | 3447 if (!document_is_empty) |
3429 return; | 3448 return; |
3430 | 3449 |
3431 // Do not show error page when DevTools is attached. | 3450 // Do not show error page when DevTools is attached. |
3432 RenderFrameImpl* localRoot = this; | 3451 RenderFrameImpl* localRoot = this; |
3433 while (localRoot->frame_ && localRoot->frame_->parent() && | 3452 while (localRoot->frame_ && localRoot->frame_->parent() && |
3434 localRoot->frame_->parent()->isWebLocalFrame()) { | 3453 localRoot->frame_->parent()->isWebLocalFrame()) { |
3435 localRoot = RenderFrameImpl::FromWebFrame(localRoot->frame_->parent()); | 3454 localRoot = RenderFrameImpl::FromWebFrame(localRoot->frame_->parent()); |
3436 DCHECK(localRoot); | 3455 DCHECK(localRoot); |
3437 } | 3456 } |
3438 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) | 3457 if (localRoot->devtools_agent_ && localRoot->devtools_agent_->IsAttached()) |
3439 return; | 3458 return; |
3440 | 3459 |
3441 // Display error page instead of a blank page, if appropriate. | 3460 // Display error page instead of a blank page, if appropriate. |
3442 std::string error_domain = "http"; | 3461 std::string error_domain = "http"; |
3443 InternalDocumentStateData* internal_data = | 3462 InternalDocumentStateData* internal_data = |
3444 InternalDocumentStateData::FromDataSource(frame->dataSource()); | 3463 InternalDocumentStateData::FromDataSource(frame->dataSource()); |
3445 int http_status_code = internal_data->http_status_code(); | 3464 int http_status_code = internal_data->http_status_code(); |
3446 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, | 3465 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, |
3447 &error_domain)) { | 3466 &error_domain)) { |
3448 WebURLError error; | 3467 WebURLError error; |
3449 error.unreachableURL = frame->document().url(); | 3468 error.unreachableURL = frame->document().url(); |
3450 error.domain = WebString::fromUTF8(error_domain); | 3469 error.domain = WebString::fromUTF8(error_domain); |
3451 error.reason = http_status_code; | 3470 error.reason = http_status_code; |
| 3471 // This call may run scripts, e.g. via the beforeunload event. |
3452 LoadNavigationErrorPage(frame->dataSource()->request(), error, true); | 3472 LoadNavigationErrorPage(frame->dataSource()->request(), error, true); |
3453 } | 3473 } |
3454 } | 3474 // Do not use |this| or |frame| here without checking |weak_self|. |
3455 | |
3456 void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame) { | |
3457 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); | |
3458 | |
3459 MojoBindingsController* mojo_bindings_controller = | |
3460 MojoBindingsController::Get(this); | |
3461 if (mojo_bindings_controller) | |
3462 mojo_bindings_controller->RunScriptsAtDocumentReady(); | |
3463 | |
3464 if (!weak_self.get()) | |
3465 return; | |
3466 | |
3467 GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); | |
3468 // Do not use |this| or |frame|! ContentClient might have deleted them by now! | |
3469 } | 3475 } |
3470 | 3476 |
3471 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 3477 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
3472 DCHECK_EQ(frame_, frame); | 3478 DCHECK_EQ(frame_, frame); |
3473 if (!frame->parent()) { | 3479 if (!frame->parent()) { |
3474 FrameMsg_UILoadMetricsReportType::Value report_type = | 3480 FrameMsg_UILoadMetricsReportType::Value report_type = |
3475 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 3481 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
3476 frame->dataSource()->request().inputPerfMetricReportPolicy()); | 3482 frame->dataSource()->request().inputPerfMetricReportPolicy()); |
3477 base::TimeTicks ui_timestamp = base::TimeTicks() + | 3483 base::TimeTicks ui_timestamp = base::TimeTicks() + |
3478 base::TimeDelta::FromSecondsD( | 3484 base::TimeDelta::FromSecondsD( |
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6144 int match_count, | 6150 int match_count, |
6145 int ordinal, | 6151 int ordinal, |
6146 const WebRect& selection_rect, | 6152 const WebRect& selection_rect, |
6147 bool final_status_update) { | 6153 bool final_status_update) { |
6148 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6154 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6149 selection_rect, ordinal, | 6155 selection_rect, ordinal, |
6150 final_status_update)); | 6156 final_status_update)); |
6151 } | 6157 } |
6152 | 6158 |
6153 } // namespace content | 6159 } // namespace content |
OLD | NEW |