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

Side by Side Diff: chrome/browser/download/download_request_limiter.cc

Issue 1322033003: Stop compiling dead download infobar code on desktop Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/download_request_limiter.h" 5 #include "chrome/browser/download/download_request_limiter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/download/download_permission_request.h" 10 #include "chrome/browser/download/download_permission_request.h"
11 #include "chrome/browser/download/download_request_infobar_delegate.h"
12 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/tab_contents/tab_util.h" 13 #include "chrome/browser/tab_contents/tab_util.h"
15 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 14 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
16 #include "components/content_settings/core/browser/host_content_settings_map.h" 15 #include "components/content_settings/core/browser/host_content_settings_map.h"
17 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
23 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/resource_dispatcher_host.h" 23 #include "content/public/browser/resource_dispatcher_host.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_delegate.h" 25 #include "content/public/browser/web_contents_delegate.h"
27 #include "url/gurl.h" 26 #include "url/gurl.h"
28 27
28 #if defined(OS_ANDROID)
29 #include "chrome/browser/download/download_request_infobar_delegate.h"
30 #endif
31
29 using content::BrowserThread; 32 using content::BrowserThread;
30 using content::NavigationController; 33 using content::NavigationController;
31 using content::NavigationEntry; 34 using content::NavigationEntry;
32 35
33 // TabDownloadState ------------------------------------------------------------ 36 // TabDownloadState ------------------------------------------------------------
34 37
35 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 38 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
36 DownloadRequestLimiter* host, 39 DownloadRequestLimiter* host,
37 content::WebContents* contents, 40 content::WebContents* contents,
38 content::WebContents* originating_web_contents) 41 content::WebContents* originating_web_contents)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // WARNING: We've been deleted. 123 // WARNING: We've been deleted.
121 } 124 }
122 125
123 void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( 126 void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload(
124 const DownloadRequestLimiter::Callback& callback) { 127 const DownloadRequestLimiter::Callback& callback) {
125 callbacks_.push_back(callback); 128 callbacks_.push_back(callback);
126 DCHECK(web_contents_); 129 DCHECK(web_contents_);
127 if (is_showing_prompt()) 130 if (is_showing_prompt())
128 return; 131 return;
129 132
130 if (PermissionBubbleManager::Enabled()) { 133 #if defined(OS_ANDROID)
131 PermissionBubbleManager* bubble_manager =
132 PermissionBubbleManager::FromWebContents(web_contents_);
133 if (bubble_manager) {
134 bubble_manager->AddRequest(new DownloadPermissionRequest(
135 factory_.GetWeakPtr()));
136 } else {
137 Cancel();
138 }
139 return;
140 }
141
142 DownloadRequestInfoBarDelegate::Create( 134 DownloadRequestInfoBarDelegate::Create(
143 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr()); 135 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr());
136 #else
137 PermissionBubbleManager* bubble_manager =
138 PermissionBubbleManager::FromWebContents(web_contents_);
139 if (bubble_manager) {
140 bubble_manager->AddRequest(new DownloadPermissionRequest(
141 factory_.GetWeakPtr()));
142 } else {
143 Cancel();
144 }
145 #endif
144 } 146 }
145 147
146 void DownloadRequestLimiter::TabDownloadState::SetContentSetting( 148 void DownloadRequestLimiter::TabDownloadState::SetContentSetting(
147 ContentSetting setting) { 149 ContentSetting setting) {
148 if (!web_contents_) 150 if (!web_contents_)
149 return; 151 return;
150 HostContentSettingsMap* settings = 152 HostContentSettingsMap* settings =
151 DownloadRequestLimiter::GetContentSettings(web_contents_); 153 DownloadRequestLimiter::GetContentSettings(web_contents_);
152 ContentSettingsPattern pattern( 154 ContentSettingsPattern pattern(
153 ContentSettingsPattern::FromURL(web_contents_->GetURL())); 155 ContentSettingsPattern::FromURL(web_contents_->GetURL()));
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 NOTREACHED(); 439 NOTREACHED();
438 } 440 }
439 } 441 }
440 442
441 void DownloadRequestLimiter::Remove(TabDownloadState* state, 443 void DownloadRequestLimiter::Remove(TabDownloadState* state,
442 content::WebContents* contents) { 444 content::WebContents* contents) {
443 DCHECK(ContainsKey(state_map_, contents)); 445 DCHECK(ContainsKey(state_map_, contents));
444 state_map_.erase(contents); 446 state_map_.erase(contents);
445 delete state; 447 delete state;
446 } 448 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_request_limiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698