Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1803)

Unified Diff: chrome/browser/prerender/prerender_contents.cc

Issue 6459005: Cancel prerender when we discover a download starting from a page we are prer... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Adding browser test Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_contents.cc
===================================================================
--- chrome/browser/prerender/prerender_contents.cc (revision 74194)
+++ 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_STARTED,
cbentzel 2011/02/09 12:19:15 Instead of registering with AllSources, you could
dominich 2011/02/09 22:33:30 Done.
+ NotificationService::AllSources());
+
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
@@ -206,6 +211,18 @@
break;
}
+ case NotificationType::DOWNLOAD_STARTED: {
+ // If the download is started from a RenderViewHost that we are
+ // delegating, kill the prerender. This will also stop the download and
+ // navigating to the page will restart it as expected.
+ RenderViewHostDelegate* rvhd =
+ Source<RenderViewHostDelegate>(source).ptr();
+ if (rvhd == this) {
+ Destroy(FINAL_STATUS_DOWNLOAD);
cbentzel 2011/02/09 12:11:14 Nit: I'd like an explicit return here, since Destr
dominich 2011/02/09 22:33:30 I'll add the same to the AUTH_* cases above.
dominich 2011/02/09 22:33:30 Done.
+ }
+ break;
+ }
+
default:
NOTREACHED() << "Unexpected notification sent.";
break;

Powered by Google App Engine
This is Rietveld 408576698