| Index: chrome/browser/download/download_request_limiter.cc
|
| ===================================================================
|
| --- chrome/browser/download/download_request_limiter.cc (revision 153800)
|
| +++ 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);
|
|
|