| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Register this with the ResourceDispatcherHost as a prerender | 342 // Register this with the ResourceDispatcherHost as a prerender |
| 343 // RenderViewHost. This must be done before the Navigate message to catch all | 343 // RenderViewHost. This must be done before the Navigate message to catch all |
| 344 // resource requests, but as it is on the same thread as the Navigate message | 344 // resource requests, but as it is on the same thread as the Navigate message |
| 345 // (IO) there is no race condition. | 345 // (IO) there is no race condition. |
| 346 prerender_tracker_->OnPrerenderingStarted( | 346 prerender_tracker_->OnPrerenderingStarted( |
| 347 child_id_, | 347 child_id_, |
| 348 route_id_, | 348 route_id_, |
| 349 prerender_manager_); | 349 prerender_manager_); |
| 350 | 350 |
| 351 // Close ourselves when the application is shutting down. | 351 // Close ourselves when the application is shutting down. |
| 352 notification_registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 352 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 353 content::NotificationService::AllSources()); | 353 content::NotificationService::AllSources()); |
| 354 | 354 |
| 355 // Register for our parent profile to shutdown, so we can shut ourselves down | 355 // Register for our parent profile to shutdown, so we can shut ourselves down |
| 356 // as well (should only be called for OTR profiles, as we should receive | 356 // as well (should only be called for OTR profiles, as we should receive |
| 357 // APP_TERMINATING before non-OTR profiles are destroyed). | 357 // APP_TERMINATING before non-OTR profiles are destroyed). |
| 358 // TODO(tburkard): figure out if this is needed. | 358 // TODO(tburkard): figure out if this is needed. |
| 359 notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 359 notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 360 content::Source<Profile>(profile_)); | 360 content::Source<Profile>(profile_)); |
| 361 | 361 |
| 362 // Register to inform new RenderViews that we're prerendering. | 362 // Register to inform new RenderViews that we're prerendering. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 434 } |
| 435 | 435 |
| 436 void PrerenderContents::Observe(int type, | 436 void PrerenderContents::Observe(int type, |
| 437 const content::NotificationSource& source, | 437 const content::NotificationSource& source, |
| 438 const content::NotificationDetails& details) { | 438 const content::NotificationDetails& details) { |
| 439 switch (type) { | 439 switch (type) { |
| 440 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 440 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
| 441 Destroy(FINAL_STATUS_PROFILE_DESTROYED); | 441 Destroy(FINAL_STATUS_PROFILE_DESTROYED); |
| 442 return; | 442 return; |
| 443 | 443 |
| 444 case content::NOTIFICATION_APP_TERMINATING: | 444 case chrome::NOTIFICATION_APP_TERMINATING: |
| 445 Destroy(FINAL_STATUS_APP_TERMINATING); | 445 Destroy(FINAL_STATUS_APP_TERMINATING); |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { | 448 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { |
| 449 // RESOURCE_RECEIVED_REDIRECT can come for any resource on a page. | 449 // RESOURCE_RECEIVED_REDIRECT can come for any resource on a page. |
| 450 // If it's a redirect on the top-level resource, the name needs | 450 // If it's a redirect on the top-level resource, the name needs |
| 451 // to be remembered for future matching, and if it redirects to | 451 // to be remembered for future matching, and if it redirects to |
| 452 // an https resource, it needs to be canceled. If a subresource | 452 // an https resource, it needs to be canceled. If a subresource |
| 453 // is redirected, nothing changes. | 453 // is redirected, nothing changes. |
| 454 DCHECK(content::Source<WebContents>(source).ptr() == GetWebContents()); | 454 DCHECK(content::Source<WebContents>(source).ptr() == GetWebContents()); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 716 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
| 717 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 717 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
| 718 return false; | 718 return false; |
| 719 const WebContents* web_contents = prerender_contents_->web_contents(); | 719 const WebContents* web_contents = prerender_contents_->web_contents(); |
| 720 return (web_contents->GetSiteInstance() != | 720 return (web_contents->GetSiteInstance() != |
| 721 web_contents->GetPendingSiteInstance()); | 721 web_contents->GetPendingSiteInstance()); |
| 722 } | 722 } |
| 723 | 723 |
| 724 | 724 |
| 725 } // namespace prerender | 725 } // namespace prerender |
| OLD | NEW |