Chromium Code Reviews| Index: chrome/browser/prerender/prerender_contents.cc |
| =================================================================== |
| --- chrome/browser/prerender/prerender_contents.cc (revision 74377) |
| +++ chrome/browser/prerender/prerender_contents.cc (working copy) |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/prerender/prerender_manager.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/renderer_host/render_view_host.h" |
| +#include "chrome/browser/renderer_host/resource_request_details.h" |
| #include "chrome/browser/renderer_host/site_instance.h" |
| #include "chrome/browser/renderer_preferences_util.h" |
| #include "chrome/browser/ui/login/login_prompt.h" |
| @@ -82,6 +83,10 @@ |
| registrar_.Add(this, NotificationType::AUTH_CANCELLED, |
| NotificationService::AllSources()); |
| + // Register all responses to see if we should cancel. |
| + registrar_.Add(this, NotificationType::DOWNLOAD_INITIATED, |
| + Source<RenderViewHostDelegate>(this)); |
| + |
| DCHECK(load_start_time_.is_null()); |
| load_start_time_ = base::TimeTicks::Now(); |
| @@ -95,6 +100,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 +192,7 @@ |
| case NotificationType::PROFILE_DESTROYED: |
| Destroy(FINAL_STATUS_PROFILE_DESTROYED); |
| return; |
| + |
| case NotificationType::APP_TERMINATING: |
| Destroy(FINAL_STATUS_APP_TERMINATING); |
| return; |
| @@ -201,11 +208,22 @@ |
| 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 will also stop the download and |
|
Randy Smith (Not in Mondays)
2011/02/10 16:57:10
Can you give me the context for how killing the pr
dominich
2011/02/10 18:46:22
You're right - changed the comment to reflect that
|
| + // navigating to the page will restart it as expected. |
| + DCHECK(Source<RenderViewHostDelegate>(source).ptr() == this); |
| + Destroy(FINAL_STATUS_DOWNLOAD); |
| + return; |
| + } |
| + |
| default: |
| NOTREACHED() << "Unexpected notification sent."; |
| break; |