OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 | 177 |
178 private: | 178 private: |
179 PrerenderContents* prerender_contents_; | 179 PrerenderContents* prerender_contents_; |
180 }; | 180 }; |
181 | 181 |
182 void PrerenderContents::Observer::OnPrerenderStopLoading( | 182 void PrerenderContents::Observer::OnPrerenderStopLoading( |
183 PrerenderContents* contents) { | 183 PrerenderContents* contents) { |
184 } | 184 } |
185 | 185 |
| 186 void PrerenderContents::Observer::OnPrerenderDomContentLoaded( |
| 187 PrerenderContents* contents) { |
| 188 } |
| 189 |
186 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( | 190 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( |
187 PrerenderContents* contents, PrerenderContents* replacement) { | 191 PrerenderContents* contents, PrerenderContents* replacement) { |
188 } | 192 } |
189 | 193 |
190 PrerenderContents::Observer::Observer() { | 194 PrerenderContents::Observer::Observer() { |
191 } | 195 } |
192 | 196 |
193 PrerenderContents::Observer::~Observer() { | 197 PrerenderContents::Observer::~Observer() { |
194 } | 198 } |
195 | 199 |
(...skipping 14 matching lines...) Expand all Loading... |
210 has_stopped_loading_(false), | 214 has_stopped_loading_(false), |
211 has_finished_loading_(false), | 215 has_finished_loading_(false), |
212 final_status_(FINAL_STATUS_MAX), | 216 final_status_(FINAL_STATUS_MAX), |
213 match_complete_status_(MATCH_COMPLETE_DEFAULT), | 217 match_complete_status_(MATCH_COMPLETE_DEFAULT), |
214 prerendering_has_been_cancelled_(false), | 218 prerendering_has_been_cancelled_(false), |
215 child_id_(-1), | 219 child_id_(-1), |
216 route_id_(-1), | 220 route_id_(-1), |
217 origin_(origin), | 221 origin_(origin), |
218 experiment_id_(experiment_id), | 222 experiment_id_(experiment_id), |
219 creator_child_id_(-1), | 223 creator_child_id_(-1), |
| 224 main_frame_id_(0), |
220 cookie_status_(0) { | 225 cookie_status_(0) { |
221 DCHECK(prerender_manager != NULL); | 226 DCHECK(prerender_manager != NULL); |
222 } | 227 } |
223 | 228 |
224 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { | 229 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { |
225 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( | 230 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( |
226 prerender_url(), referrer(), origin(), experiment_id()); | 231 prerender_url(), referrer(), origin(), experiment_id()); |
227 | 232 |
228 new_contents->load_start_time_ = load_start_time_; | 233 new_contents->load_start_time_ = load_start_time_; |
229 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; | 234 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 475 |
471 void PrerenderContents::NotifyPrerenderStart() { | 476 void PrerenderContents::NotifyPrerenderStart() { |
472 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); | 477 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); |
473 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStart(this)); | 478 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStart(this)); |
474 } | 479 } |
475 | 480 |
476 void PrerenderContents::NotifyPrerenderStopLoading() { | 481 void PrerenderContents::NotifyPrerenderStopLoading() { |
477 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStopLoading(this)); | 482 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStopLoading(this)); |
478 } | 483 } |
479 | 484 |
| 485 void PrerenderContents::NotifyPrerenderDomContentLoaded() { |
| 486 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 487 OnPrerenderDomContentLoaded(this)); |
| 488 } |
| 489 |
480 void PrerenderContents::NotifyPrerenderStop() { | 490 void PrerenderContents::NotifyPrerenderStop() { |
481 DCHECK_NE(FINAL_STATUS_MAX, final_status_); | 491 DCHECK_NE(FINAL_STATUS_MAX, final_status_); |
482 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStop(this)); | 492 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStop(this)); |
483 observer_list_.Clear(); | 493 observer_list_.Clear(); |
484 } | 494 } |
485 | 495 |
486 void PrerenderContents::NotifyPrerenderCreatedMatchCompleteReplacement( | 496 void PrerenderContents::NotifyPrerenderCreatedMatchCompleteReplacement( |
487 PrerenderContents* replacement) { | 497 PrerenderContents* replacement) { |
488 FOR_EACH_OBSERVER(Observer, observer_list_, | 498 FOR_EACH_OBSERVER(Observer, observer_list_, |
489 OnPrerenderCreatedMatchCompleteReplacement(this, | 499 OnPrerenderCreatedMatchCompleteReplacement(this, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 render_frame_host->Send(new PrerenderMsg_SetIsPrerendering( | 567 render_frame_host->Send(new PrerenderMsg_SetIsPrerendering( |
558 render_frame_host->GetRoutingID(), true)); | 568 render_frame_host->GetRoutingID(), true)); |
559 } | 569 } |
560 | 570 |
561 void PrerenderContents::DidStopLoading( | 571 void PrerenderContents::DidStopLoading( |
562 content::RenderViewHost* render_view_host) { | 572 content::RenderViewHost* render_view_host) { |
563 has_stopped_loading_ = true; | 573 has_stopped_loading_ = true; |
564 NotifyPrerenderStopLoading(); | 574 NotifyPrerenderStopLoading(); |
565 } | 575 } |
566 | 576 |
| 577 void PrerenderContents::DocumentLoadedInFrame( |
| 578 int64 frame_id, |
| 579 RenderViewHost* render_view_host) { |
| 580 if (frame_id == main_frame_id_) |
| 581 NotifyPrerenderDomContentLoaded(); |
| 582 } |
| 583 |
567 void PrerenderContents::DidStartProvisionalLoadForFrame( | 584 void PrerenderContents::DidStartProvisionalLoadForFrame( |
568 int64 frame_id, | 585 int64 frame_id, |
569 int64 parent_frame_id, | 586 int64 parent_frame_id, |
570 bool is_main_frame, | 587 bool is_main_frame, |
571 const GURL& validated_url, | 588 const GURL& validated_url, |
572 bool is_error_page, | 589 bool is_error_page, |
573 bool is_iframe_srcdoc, | 590 bool is_iframe_srcdoc, |
574 RenderViewHost* render_view_host) { | 591 RenderViewHost* render_view_host) { |
575 if (is_main_frame) { | 592 if (is_main_frame) { |
576 if (!CheckURL(validated_url)) | 593 if (!CheckURL(validated_url)) |
577 return; | 594 return; |
578 | 595 |
579 // Usually, this event fires if the user clicks or enters a new URL. | 596 // Usually, this event fires if the user clicks or enters a new URL. |
580 // Neither of these can happen in the case of an invisible prerender. | 597 // Neither of these can happen in the case of an invisible prerender. |
581 // So the cause is: Some JavaScript caused a new URL to be loaded. In that | 598 // So the cause is: Some JavaScript caused a new URL to be loaded. In that |
582 // case, the spinner would start again in the browser, so we must reset | 599 // case, the spinner would start again in the browser, so we must reset |
583 // has_stopped_loading_ so that the spinner won't be stopped. | 600 // has_stopped_loading_ so that the spinner won't be stopped. |
584 has_stopped_loading_ = false; | 601 has_stopped_loading_ = false; |
585 has_finished_loading_ = false; | 602 has_finished_loading_ = false; |
586 } | 603 } |
587 } | 604 } |
588 | 605 |
| 606 void PrerenderContents::DidCommitProvisionalLoadForFrame( |
| 607 int64 frame_id, |
| 608 const base::string16& frame_unique_name, |
| 609 bool is_main_frame, |
| 610 const GURL& url, |
| 611 content::PageTransition transition_type, |
| 612 RenderViewHost* render_view_host) { |
| 613 if (is_main_frame) { |
| 614 main_frame_id_ = frame_id; |
| 615 } |
| 616 } |
| 617 |
589 void PrerenderContents::DidFinishLoad(int64 frame_id, | 618 void PrerenderContents::DidFinishLoad(int64 frame_id, |
590 const GURL& validated_url, | 619 const GURL& validated_url, |
591 bool is_main_frame, | 620 bool is_main_frame, |
592 RenderViewHost* render_view_host) { | 621 RenderViewHost* render_view_host) { |
593 if (is_main_frame) | 622 if (is_main_frame) |
594 has_finished_loading_ = true; | 623 has_finished_loading_ = true; |
595 } | 624 } |
596 | 625 |
597 void PrerenderContents::DidNavigateMainFrame( | 626 void PrerenderContents::DidNavigateMainFrame( |
598 const content::LoadCommittedDetails& details, | 627 const content::LoadCommittedDetails& details, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 DCHECK_GE(cookie_status_, 0); | 835 DCHECK_GE(cookie_status_, 0); |
807 DCHECK_LT(cookie_status_, kNumCookieStatuses); | 836 DCHECK_LT(cookie_status_, kNumCookieStatuses); |
808 } | 837 } |
809 | 838 |
810 void PrerenderContents::AddResourceThrottle( | 839 void PrerenderContents::AddResourceThrottle( |
811 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 840 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
812 resource_throttles_.push_back(throttle); | 841 resource_throttles_.push_back(throttle); |
813 } | 842 } |
814 | 843 |
815 } // namespace prerender | 844 } // namespace prerender |
OLD | NEW |