OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 WebFrame* main_frame = webview()->GetMainFrame(); | 1069 WebFrame* main_frame = webview()->GetMainFrame(); |
1070 | 1070 |
1071 if (main_frame->GetProvisionalDataSource()) { | 1071 if (main_frame->GetProvisionalDataSource()) { |
1072 // If we have a provisional frame we are between the start | 1072 // If we have a provisional frame we are between the start |
1073 // and commit stages of loading...ignore this paint. | 1073 // and commit stages of loading...ignore this paint. |
1074 return; | 1074 return; |
1075 } | 1075 } |
1076 | 1076 |
1077 WebDataSource* ds = main_frame->GetDataSource(); | 1077 WebDataSource* ds = main_frame->GetDataSource(); |
1078 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1078 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
1079 // TODO(darin): It should not be possible for navigation_state to | 1079 DCHECK(navigation_state); |
1080 // be null here! But the UI test DownloadTest.IncognitoDownload | 1080 |
1081 // can cause it to happen. | 1081 Time now = Time::Now(); |
1082 if (navigation_state) { | 1082 if (navigation_state->first_paint_time().is_null()) { |
1083 Time now = Time::Now(); | 1083 navigation_state->set_first_paint_time(now); |
1084 if (navigation_state->first_paint_time().is_null()) { | 1084 } |
1085 navigation_state->set_first_paint_time(now); | 1085 if (navigation_state->first_paint_after_load_time().is_null() && |
1086 } | 1086 !navigation_state->finish_load_time().is_null()) { |
1087 if (navigation_state->first_paint_after_load_time().is_null() && | 1087 navigation_state->set_first_paint_after_load_time(now); |
1088 !navigation_state->finish_load_time().is_null()) { | |
1089 navigation_state->set_first_paint_after_load_time(now); | |
1090 } | |
1091 } | 1088 } |
1092 } | 1089 } |
1093 | 1090 |
1094 void RenderView::DidStartProvisionalLoadForFrame( | 1091 void RenderView::DidStartProvisionalLoadForFrame( |
1095 WebView* webview, | 1092 WebView* webview, |
1096 WebFrame* frame, | 1093 WebFrame* frame, |
1097 NavigationGesture gesture) { | 1094 NavigationGesture gesture) { |
1098 WebDataSource* ds = frame->GetProvisionalDataSource(); | 1095 WebDataSource* ds = frame->GetProvisionalDataSource(); |
1099 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1096 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
1100 | 1097 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 WebFrame* frame) { | 1308 WebFrame* frame) { |
1312 UpdateTitle(frame, title); | 1309 UpdateTitle(frame, title); |
1313 | 1310 |
1314 // Also check whether we have new encoding name. | 1311 // Also check whether we have new encoding name. |
1315 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); | 1312 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); |
1316 } | 1313 } |
1317 | 1314 |
1318 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { | 1315 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { |
1319 WebDataSource* ds = frame->GetDataSource(); | 1316 WebDataSource* ds = frame->GetDataSource(); |
1320 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1317 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
1321 // TODO(darin): It should not be possible for navigation_state to be null | 1318 DCHECK(navigation_state); |
1322 // here! | 1319 navigation_state->set_finish_load_time(Time::Now()); |
1323 if (navigation_state) | |
1324 navigation_state->set_finish_load_time(Time::Now()); | |
1325 } | 1320 } |
1326 | 1321 |
1327 void RenderView::DidFailLoadWithError(WebView* webview, | 1322 void RenderView::DidFailLoadWithError(WebView* webview, |
1328 const WebURLError& error, | 1323 const WebURLError& error, |
1329 WebFrame* frame) { | 1324 WebFrame* frame) { |
1330 // Currently this function is empty. When you implement something here and it | 1325 // Currently this function is empty. When you implement something here and it |
1331 // will display any error messages in HTML, please make sure to call | 1326 // will display any error messages in HTML, please make sure to call |
1332 // frame->SetInViewSourceMode(false) not to show them in view source mode. | 1327 // frame->SetInViewSourceMode(false) not to show them in view source mode. |
1333 } | 1328 } |
1334 | 1329 |
1335 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, | 1330 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, |
1336 WebFrame* frame) { | 1331 WebFrame* frame) { |
1337 WebDataSource* ds = frame->GetDataSource(); | 1332 WebDataSource* ds = frame->GetDataSource(); |
1338 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1333 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
1339 // TODO(darin): It should not be possible for navigation_state to be null | 1334 DCHECK(navigation_state); |
1340 // here! | 1335 navigation_state->set_finish_document_load_time(Time::Now()); |
1341 if (navigation_state) | |
1342 navigation_state->set_finish_document_load_time(Time::Now()); | |
1343 | 1336 |
1344 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); | 1337 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); |
1345 | 1338 |
1346 // The document has now been fully loaded. Scan for password forms to be | 1339 // The document has now been fully loaded. Scan for password forms to be |
1347 // sent up to the browser. | 1340 // sent up to the browser. |
1348 SendPasswordForms(frame); | 1341 SendPasswordForms(frame); |
1349 | 1342 |
1350 // Check whether we have new encoding name. | 1343 // Check whether we have new encoding name. |
1351 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); | 1344 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); |
1352 | 1345 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 void RenderView::DidAddHistoryItem() { | 2713 void RenderView::DidAddHistoryItem() { |
2721 // We don't want to update the history length for the start page | 2714 // We don't want to update the history length for the start page |
2722 // navigation. | 2715 // navigation. |
2723 WebFrame* main_frame = webview()->GetMainFrame(); | 2716 WebFrame* main_frame = webview()->GetMainFrame(); |
2724 DCHECK(main_frame != NULL); | 2717 DCHECK(main_frame != NULL); |
2725 | 2718 |
2726 WebDataSource* ds = main_frame->GetDataSource(); | 2719 WebDataSource* ds = main_frame->GetDataSource(); |
2727 DCHECK(ds != NULL); | 2720 DCHECK(ds != NULL); |
2728 | 2721 |
2729 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2722 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 2723 DCHECK(navigation_state); |
2730 if (navigation_state->transition_type() == PageTransition::START_PAGE) | 2724 if (navigation_state->transition_type() == PageTransition::START_PAGE) |
2731 return; | 2725 return; |
2732 | 2726 |
2733 history_back_list_count_++; | 2727 history_back_list_count_++; |
2734 history_forward_list_count_ = 0; | 2728 history_forward_list_count_ = 0; |
2735 } | 2729 } |
2736 | 2730 |
2737 void RenderView::OnMessageFromExternalHost(const std::string& message, | 2731 void RenderView::OnMessageFromExternalHost(const std::string& message, |
2738 const std::string& origin, | 2732 const std::string& origin, |
2739 const std::string& target) { | 2733 const std::string& target) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2970 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 2964 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); |
2971 } | 2965 } |
2972 | 2966 |
2973 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 2967 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
2974 DCHECK(frame); | 2968 DCHECK(frame); |
2975 if (print_helper_.get() == NULL) { | 2969 if (print_helper_.get() == NULL) { |
2976 print_helper_.reset(new PrintWebViewHelper(this)); | 2970 print_helper_.reset(new PrintWebViewHelper(this)); |
2977 } | 2971 } |
2978 print_helper_->Print(frame, script_initiated); | 2972 print_helper_->Print(frame, script_initiated); |
2979 } | 2973 } |
OLD | NEW |