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

Unified Diff: chrome/browser/download/download_request_limiter.cc

Issue 10890023: Miscellaneous cleanups from several months ago I never got around to landing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/download/download_request_limiter.cc
===================================================================
--- chrome/browser/download/download_request_limiter.cc (revision 154486)
+++ chrome/browser/download/download_request_limiter.cc (working copy)
@@ -128,61 +128,39 @@
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type != content::NOTIFICATION_NAV_ENTRY_PENDING &&
- type != content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
- NOTREACHED();
- return;
- }
content::NavigationController* controller = &web_contents()->GetController();
- if (type == content::NOTIFICATION_NAV_ENTRY_PENDING &&
- content::Source<NavigationController>(source).ptr() != controller) {
- NOTREACHED();
- return;
- }
- if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED &&
- &content::Source<content::WebContents>(source).ptr()->
- GetController() != controller) {
- NOTREACHED();
- return;
- }
+ if (type == content::NOTIFICATION_NAV_ENTRY_PENDING) {
+ DCHECK_EQ(controller, content::Source<NavigationController>(source).ptr());
- switch (type) {
- case content::NOTIFICATION_NAV_ENTRY_PENDING: {
- // NOTE: resetting state on a pending navigate isn't ideal. In particular
- // it is possible that queued up downloads for the page before the
- // pending navigate will be delivered to us after we process this
- // request. If this happens we may let a download through that we
- // shouldn't have. But this is rather rare, and it is difficult to get
- // 100% right, so we don't deal with it.
- NavigationEntry* entry = controller->GetPendingEntry();
- if (!entry)
- return;
+ // NOTE: Resetting state on a pending navigate isn't ideal. In particular it
+ // is possible that queued up downloads for the page before the pending
+ // navigation will be delivered to us after we process this request. If this
+ // happens we may let a download through that we shouldn't have. But this is
+ // rather rare, and it is difficult to get 100% right, so we don't deal with
+ // it.
+ NavigationEntry* entry = controller->GetPendingEntry();
+ if (!entry)
+ return;
- if (content::PageTransitionIsRedirect(entry->GetTransitionType())) {
- // Redirects don't count.
+ // Redirects don't count.
+ if (content::PageTransitionIsRedirect(entry->GetTransitionType()))
+ return;
+
+ if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS ||
+ status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) {
+ // User has either allowed all downloads or canceled all downloads. Only
+ // reset the download state if the user is navigating to a different host
+ // (or host is empty).
+ if (!initial_page_host_.empty() && !entry->GetURL().host().empty() &&
+ entry->GetURL().host() == initial_page_host_)
return;
- }
-
- if (status_ == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS ||
- status_ == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) {
- // User has either allowed all downloads or canceled all downloads. Only
- // reset the download state if the user is navigating to a different
- // host (or host is empty).
- if (!initial_page_host_.empty() && !entry->GetURL().host().empty() &&
- entry->GetURL().host() == initial_page_host_) {
- return;
- }
- }
- break;
}
-
- case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
- // Tab closed, no need to handle closing the dialog as it's owned by the
- // WebContents, break so that we get deleted after switch.
- break;
-
- default:
- NOTREACHED();
+ } else {
+ DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, type);
+ DCHECK_EQ(controller,
+ &content::Source<content::WebContents>(source)->GetController());
+ // Tab closed, no need to handle closing the dialog as it's owned by the
+ // WebContents.
}
NotifyCallbacks(false);
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/browser/printing/background_printing_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698