| Index: chrome/browser/prerender/prerender_contents.cc
|
| ===================================================================
|
| --- chrome/browser/prerender/prerender_contents.cc (revision 74962)
|
| +++ chrome/browser/prerender/prerender_contents.cc (working copy)
|
| @@ -84,6 +84,10 @@
|
| registrar_.Add(this, NotificationType::AUTH_CANCELLED,
|
| NotificationService::AllSources());
|
|
|
| + // Register all responses to see if we should cancel.
|
| + registrar_.Add(this, NotificationType::DOWNLOAD_INITIATED,
|
| + NotificationService::AllSources());
|
| +
|
| DCHECK(load_start_time_.is_null());
|
| load_start_time_ = base::TimeTicks::Now();
|
|
|
| @@ -97,6 +101,7 @@
|
| void PrerenderContents::set_final_status(FinalStatus final_status) {
|
| DCHECK(final_status >= FINAL_STATUS_USED && final_status < FINAL_STATUS_MAX);
|
| DCHECK_EQ(FINAL_STATUS_MAX, final_status_);
|
| +
|
| final_status_ = final_status;
|
| }
|
|
|
| @@ -186,6 +191,7 @@
|
| case NotificationType::PROFILE_DESTROYED:
|
| Destroy(FINAL_STATUS_PROFILE_DESTROYED);
|
| return;
|
| +
|
| case NotificationType::APP_TERMINATING:
|
| Destroy(FINAL_STATUS_APP_TERMINATING);
|
| return;
|
| @@ -201,11 +207,28 @@
|
| LoginHandler* handler = details_ptr->handler();
|
| DCHECK(handler != NULL);
|
| RenderViewHostDelegate* delegate = handler->GetRenderViewHostDelegate();
|
| - if (controller == NULL && delegate == this)
|
| + if (controller == NULL && delegate == this) {
|
| Destroy(FINAL_STATUS_AUTH_NEEDED);
|
| + return;
|
| + }
|
| break;
|
| }
|
|
|
| + case NotificationType::DOWNLOAD_INITIATED: {
|
| + // If the download is started from a RenderViewHost that we are
|
| + // delegating, kill the prerender. This cancels any pending requests
|
| + // though the download never actually started thanks to the
|
| + // DownloadRequestLimiter.
|
| + DCHECK(NotificationService::NoDetails() == details);
|
| + RenderViewHost* rvh = Source<RenderViewHost>(source).ptr();
|
| + CHECK(rvh != NULL);
|
| + if (rvh->delegate() == this) {
|
| + Destroy(FINAL_STATUS_DOWNLOAD);
|
| + return;
|
| + }
|
| + break;
|
| + }
|
| +
|
| default:
|
| NOTREACHED() << "Unexpected notification sent.";
|
| break;
|
|
|