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

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

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. Created 3 years, 11 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/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.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"
14 #include "components/content_settings/core/browser/content_settings_details.h"
15 #include "components/content_settings/core/browser/host_content_settings_map.h" 15 #include "components/content_settings/core/browser/host_content_settings_map.h"
16 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/navigation_handle.h" 20 #include "content/public/browser/navigation_handle.h"
21 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_service.h"
22 #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
29 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
30 #include "chrome/browser/download/download_request_infobar_delegate_android.h" 29 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
31 #else 30 #else
32 #include "chrome/browser/download/download_permission_request.h" 31 #include "chrome/browser/download/download_permission_request.h"
33 #include "chrome/browser/permissions/permission_request_manager.h" 32 #include "chrome/browser/permissions/permission_request_manager.h"
34 #endif 33 #endif
35 34
36 using content::BrowserThread; 35 using content::BrowserThread;
37 using content::NavigationController; 36 using content::NavigationController;
38 using content::NavigationEntry; 37 using content::NavigationEntry;
39 38
39 namespace {
40
41 ContentSetting GetSettingFromStatus(
42 DownloadRequestLimiter::DownloadStatus status) {
43 switch (status) {
44 case DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD:
45 case DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD:
46 return CONTENT_SETTING_ASK;
47 case DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS:
48 return CONTENT_SETTING_ALLOW;
49 case DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED:
50 return CONTENT_SETTING_BLOCK;
51 default:
52 NOTREACHED();
53 return CONTENT_SETTING_DEFAULT;
54 }
55 }
56
57 DownloadRequestLimiter::DownloadStatus GetStatusFromSetting(
58 ContentSetting setting) {
59 switch (setting) {
60 case CONTENT_SETTING_ALLOW:
61 return DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS;
62 case CONTENT_SETTING_BLOCK:
63 return DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED;
64 case CONTENT_SETTING_ASK:
65 case CONTENT_SETTING_DEFAULT:
Bernhard Bauer 2017/01/25 19:01:14 Are these content settings actually used? DEFAULT
alshabalin 2017/02/07 16:16:29 Added NOTREACHED() for SESSION_ONLY. But left the
66 case CONTENT_SETTING_SESSION_ONLY:
67 return DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD;
68 case CONTENT_SETTING_NUM_SETTINGS:
69 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
70 NOTREACHED();
71 return DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD;
72 }
73 }
74
75 } // namespace
76
40 // TabDownloadState ------------------------------------------------------------ 77 // TabDownloadState ------------------------------------------------------------
41 78
42 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 79 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
43 DownloadRequestLimiter* host, 80 DownloadRequestLimiter* host,
44 content::WebContents* contents, 81 content::WebContents* contents,
45 content::WebContents* originating_web_contents) 82 content::WebContents* originating_web_contents)
46 : content::WebContentsObserver(contents), 83 : content::WebContentsObserver(contents),
47 web_contents_(contents), 84 web_contents_(contents),
48 host_(host), 85 host_(host),
49 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD), 86 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
50 download_count_(0), 87 download_count_(0),
88 observer_(this),
51 factory_(this) { 89 factory_(this) {
52 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, 90 observer_.Add(DownloadRequestLimiter::GetContentSettings(contents));
Bernhard Bauer 2017/01/25 19:01:14 The DownloadRequestLimiter:: prefix doesn't seem n
alshabalin 2017/02/07 16:16:29 Done.
53 content::Source<content::WebContents>(contents));
54 NavigationEntry* last_entry = 91 NavigationEntry* last_entry =
55 originating_web_contents 92 originating_web_contents
56 ? originating_web_contents->GetController().GetLastCommittedEntry() 93 ? originating_web_contents->GetController().GetLastCommittedEntry()
57 : contents->GetController().GetLastCommittedEntry(); 94 : contents->GetController().GetLastCommittedEntry();
58 if (last_entry) 95 if (last_entry)
59 initial_page_host_ = last_entry->GetURL().host(); 96 initial_page_host_ = last_entry->GetURL().host();
60 } 97 }
61 98
62 DownloadRequestLimiter::TabDownloadState::~TabDownloadState() { 99 DownloadRequestLimiter::TabDownloadState::~TabDownloadState() {
63 // We should only be destroyed after the callbacks have been notified. 100 // We should only be destroyed after the callbacks have been notified.
64 DCHECK(callbacks_.empty()); 101 DCHECK(callbacks_.empty());
65 102
66 // And we should have invalidated the back pointer. 103 // And we should have invalidated the back pointer.
67 DCHECK(!factory_.HasWeakPtrs()); 104 DCHECK(!factory_.HasWeakPtrs());
68 } 105 }
69 106
107 void DownloadRequestLimiter::TabDownloadState::SetDownloadStatusAndNotify(
108 DownloadRequestLimiter::DownloadStatus status) {
109 DownloadStatus last_status = status_;
110 status_ = status;
111 if (!web_contents())
112 return;
113 ContentSetting last_setting = GetSettingFromStatus(last_status);
114 ContentSetting current_setting = GetSettingFromStatus(status_);
115 if (current_setting == last_setting)
116 return;
117 content::NotificationService::current()->Notify(
118 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
119 content::Source<content::WebContents>(web_contents()),
120 content::NotificationService::NoDetails());
121 }
122
70 void DownloadRequestLimiter::TabDownloadState::DidStartNavigation( 123 void DownloadRequestLimiter::TabDownloadState::DidStartNavigation(
71 content::NavigationHandle* navigation_handle) { 124 content::NavigationHandle* navigation_handle) {
72 if (!navigation_handle->IsInMainFrame()) 125 if (!navigation_handle->IsInMainFrame())
73 return; 126 return;
74 127
75 // If the navigation is renderer-initiated (but not user-initiated), ensure 128 // If the navigation is renderer-initiated (but not user-initiated), ensure
76 // that a prompting or blocking limiter state is not reset, so 129 // that a prompting or blocking limiter state is not reset, so
77 // window.location.href or meta refresh can't be abused to avoid the limiter. 130 // window.location.href or meta refresh can't be abused to avoid the limiter.
78 // User-initiated navigations will trigger DidGetUserInteraction, which resets 131 // User-initiated navigations will trigger DidGetUserInteraction, which resets
79 // the limiter before the navigation starts. 132 // the limiter before the navigation starts.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 DownloadRequestLimiter::GetContentSettings(web_contents_); 240 DownloadRequestLimiter::GetContentSettings(web_contents_);
188 if (!settings) 241 if (!settings)
189 return; 242 return;
190 settings->SetContentSettingDefaultScope( 243 settings->SetContentSettingDefaultScope(
191 web_contents_->GetURL(), GURL(), 244 web_contents_->GetURL(), GURL(),
192 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), setting); 245 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), setting);
193 } 246 }
194 247
195 void DownloadRequestLimiter::TabDownloadState::Cancel() { 248 void DownloadRequestLimiter::TabDownloadState::Cancel() {
196 SetContentSetting(CONTENT_SETTING_BLOCK); 249 SetContentSetting(CONTENT_SETTING_BLOCK);
197 NotifyCallbacks(false); 250 bool throttled = NotifyCallbacks(false);
251 SetDownloadStatusAndNotify(throttled ? PROMPT_BEFORE_DOWNLOAD
252 : DOWNLOADS_NOT_ALLOWED);
198 } 253 }
199 254
200 void DownloadRequestLimiter::TabDownloadState::CancelOnce() { 255 void DownloadRequestLimiter::TabDownloadState::CancelOnce() {
201 NotifyCallbacks(false); 256 bool throttled = NotifyCallbacks(false);
257 SetDownloadStatusAndNotify(throttled ? PROMPT_BEFORE_DOWNLOAD
258 : DOWNLOADS_NOT_ALLOWED);
202 } 259 }
203 260
204 void DownloadRequestLimiter::TabDownloadState::Accept() { 261 void DownloadRequestLimiter::TabDownloadState::Accept() {
205 SetContentSetting(CONTENT_SETTING_ALLOW); 262 SetContentSetting(CONTENT_SETTING_ALLOW);
206 NotifyCallbacks(true); 263 bool throttled = NotifyCallbacks(true);
264 SetDownloadStatusAndNotify(throttled ? PROMPT_BEFORE_DOWNLOAD
265 : ALLOW_ALL_DOWNLOADS);
207 } 266 }
208 267
209 DownloadRequestLimiter::TabDownloadState::TabDownloadState() 268 DownloadRequestLimiter::TabDownloadState::TabDownloadState()
210 : web_contents_(NULL), 269 : web_contents_(NULL),
211 host_(NULL), 270 host_(NULL),
212 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD), 271 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
213 download_count_(0), 272 download_count_(0),
273 observer_(this),
214 factory_(this) {} 274 factory_(this) {}
215 275
216 bool DownloadRequestLimiter::TabDownloadState::is_showing_prompt() const { 276 bool DownloadRequestLimiter::TabDownloadState::is_showing_prompt() const {
217 return factory_.HasWeakPtrs(); 277 return factory_.HasWeakPtrs();
218 } 278 }
219 279
220 void DownloadRequestLimiter::TabDownloadState::Observe( 280 void DownloadRequestLimiter::TabDownloadState::OnContentSettingChanged(
221 int type, 281 const ContentSettingsPattern& primary_pattern,
222 const content::NotificationSource& source, 282 const ContentSettingsPattern& secondary_pattern,
223 const content::NotificationDetails& details) { 283 ContentSettingsType content_type,
224 DCHECK_EQ(chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, type); 284 std::string resource_identifier) {
285 if (content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)
286 return;
287
288 // Analogous to TabSpecificContentSettings::OnContentSettingChanged:
289 const ContentSettingsDetails details(primary_pattern, secondary_pattern,
290 content_type, resource_identifier);
291 const NavigationController& controller = web_contents()->GetController();
292 // The visible NavigationEntry is the URL in the URL field of a tab.
293 // Currently this should be matched by the |primary_pattern|.
294 NavigationEntry* entry = controller.GetVisibleEntry();
295 GURL entry_url;
296 if (entry)
297 entry_url = entry->GetURL();
298 if (!details.update_all() && !details.primary_pattern().Matches(entry_url))
299 return;
225 300
226 // Content settings have been updated for our web contents, e.g. via the OIB 301 // Content settings have been updated for our web contents, e.g. via the OIB
227 // or the settings page. Check to see if the automatic downloads setting is 302 // or the settings page. Check to see if the automatic downloads setting is
228 // different to our internal state, and update the internal state to match if 303 // different to our internal state, and update the internal state to match if
229 // necessary. If there is no content setting persisted, then retain the 304 // necessary. If there is no content setting persisted, then retain the
230 // current state and do nothing. 305 // current state and do nothing.
231 // 306 //
232 // NotifyCallbacks is not called as this notification should be triggered when 307 // NotifyCallbacks is not called as this notification should be triggered when
233 // a download is not pending. 308 // a download is not pending.
234 content::WebContents* contents = 309 //
235 content::Source<content::WebContents>(source).ptr();
236 DCHECK_EQ(contents, web_contents());
237
238 // Fetch the content settings map for this web contents, and extract the 310 // Fetch the content settings map for this web contents, and extract the
239 // automatic downloads permission value. 311 // automatic downloads permission value.
240 HostContentSettingsMap* content_settings = GetContentSettings(contents); 312 HostContentSettingsMap* content_settings = GetContentSettings(web_contents());
241 if (!content_settings) 313 if (!content_settings)
242 return; 314 return;
243 315
244 ContentSetting setting = content_settings->GetContentSetting( 316 ContentSetting setting = content_settings->GetContentSetting(
245 contents->GetURL(), contents->GetURL(), 317 web_contents()->GetURL(), web_contents()->GetURL(),
246 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string()); 318 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string());
247 319
248 // Update the internal state to match if necessary. 320 // Update the internal state to match if necessary.
249 switch (setting) { 321 SetDownloadStatusAndNotify(GetStatusFromSetting(setting));
Bernhard Bauer 2017/01/25 19:01:14 Here you convert the setting to a status, and the
alshabalin 2017/02/07 16:16:29 Added UpdateDownloadStatusAndNotify taking Content
250 case CONTENT_SETTING_ALLOW:
251 set_download_status(ALLOW_ALL_DOWNLOADS);
252 break;
253 case CONTENT_SETTING_BLOCK:
254 set_download_status(DOWNLOADS_NOT_ALLOWED);
255 break;
256 case CONTENT_SETTING_ASK:
257 case CONTENT_SETTING_DEFAULT:
258 case CONTENT_SETTING_SESSION_ONLY:
259 set_download_status(PROMPT_BEFORE_DOWNLOAD);
260 break;
261 case CONTENT_SETTING_NUM_SETTINGS:
262 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
263 NOTREACHED();
264 return;
265 }
266 } 322 }
267 323
268 void DownloadRequestLimiter::TabDownloadState::NotifyCallbacks(bool allow) { 324 bool DownloadRequestLimiter::TabDownloadState::NotifyCallbacks(bool allow) {
269 set_download_status(allow ? DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS
270 : DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED);
271 std::vector<DownloadRequestLimiter::Callback> callbacks; 325 std::vector<DownloadRequestLimiter::Callback> callbacks;
272 bool change_status = false; 326 bool throttled = false;
273 327
274 // Selectively send first few notifications only if number of downloads exceed 328 // Selectively send first few notifications only if number of downloads exceed
275 // kMaxDownloadsAtOnce. In that case, we also retain the infobar instance and 329 // kMaxDownloadsAtOnce. In that case, we also retain the infobar instance and
276 // don't close it. If allow is false, we send all the notifications to cancel 330 // don't close it. If allow is false, we send all the notifications to cancel
277 // all remaining downloads and close the infobar. 331 // all remaining downloads and close the infobar.
278 if (!allow || (callbacks_.size() < kMaxDownloadsAtOnce)) { 332 if (!allow || (callbacks_.size() < kMaxDownloadsAtOnce)) {
279 // Null the generated weak pointer so we don't get notified again. 333 // Null the generated weak pointer so we don't get notified again.
280 factory_.InvalidateWeakPtrs(); 334 factory_.InvalidateWeakPtrs();
281 callbacks.swap(callbacks_); 335 callbacks.swap(callbacks_);
282 } else { 336 } else {
283 std::vector<DownloadRequestLimiter::Callback>::iterator start, end; 337 std::vector<DownloadRequestLimiter::Callback>::iterator start, end;
284 start = callbacks_.begin(); 338 start = callbacks_.begin();
285 end = callbacks_.begin() + kMaxDownloadsAtOnce; 339 end = callbacks_.begin() + kMaxDownloadsAtOnce;
286 callbacks.assign(start, end); 340 callbacks.assign(start, end);
287 callbacks_.erase(start, end); 341 callbacks_.erase(start, end);
288 change_status = true; 342 throttled = true;
289 } 343 }
290 344
291 for (const auto& callback : callbacks) { 345 for (const auto& callback : callbacks) {
292 // When callback runs, it can cause the WebContents to be destroyed. 346 // When callback runs, it can cause the WebContents to be destroyed.
293 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 347 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
294 base::Bind(callback, allow)); 348 base::Bind(callback, allow));
295 } 349 }
296 350
297 if (change_status) 351 return throttled;
298 set_download_status(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD);
299 } 352 }
300 353
301 // DownloadRequestLimiter ------------------------------------------------------ 354 // DownloadRequestLimiter ------------------------------------------------------
302 355
303 HostContentSettingsMap* DownloadRequestLimiter::content_settings_ = NULL; 356 HostContentSettingsMap* DownloadRequestLimiter::content_settings_ = NULL;
304 357
305 void DownloadRequestLimiter::SetContentSettingsForTesting( 358 void DownloadRequestLimiter::SetContentSettingsForTesting(
306 HostContentSettingsMap* content_settings) { 359 HostContentSettingsMap* content_settings) {
307 content_settings_ = content_settings; 360 content_settings_ = content_settings;
308 } 361 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 const Callback& callback) { 452 const Callback& callback) {
400 DCHECK(originating_contents); 453 DCHECK(originating_contents);
401 454
402 TabDownloadState* state = 455 TabDownloadState* state =
403 GetDownloadState(originating_contents, originating_contents, true); 456 GetDownloadState(originating_contents, originating_contents, true);
404 switch (state->download_status()) { 457 switch (state->download_status()) {
405 case ALLOW_ALL_DOWNLOADS: 458 case ALLOW_ALL_DOWNLOADS:
406 if (state->download_count() && 459 if (state->download_count() &&
407 !(state->download_count() % 460 !(state->download_count() %
408 DownloadRequestLimiter::kMaxDownloadsAtOnce)) 461 DownloadRequestLimiter::kMaxDownloadsAtOnce))
409 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); 462 state->SetDownloadStatusAndNotify(PROMPT_BEFORE_DOWNLOAD);
410 callback.Run(true); 463 callback.Run(true);
411 state->increment_download_count(); 464 state->increment_download_count();
412 break; 465 break;
413 466
414 case ALLOW_ONE_DOWNLOAD: 467 case ALLOW_ONE_DOWNLOAD:
415 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); 468 state->SetDownloadStatusAndNotify(PROMPT_BEFORE_DOWNLOAD);
416 callback.Run(true); 469 callback.Run(true);
417 state->increment_download_count(); 470 state->increment_download_count();
418 break; 471 break;
419 472
420 case DOWNLOADS_NOT_ALLOWED: 473 case DOWNLOADS_NOT_ALLOWED:
421 callback.Run(false); 474 callback.Run(false);
422 break; 475 break;
423 476
424 case PROMPT_BEFORE_DOWNLOAD: { 477 case PROMPT_BEFORE_DOWNLOAD: {
425 HostContentSettingsMap* content_settings = 478 HostContentSettingsMap* content_settings =
426 GetContentSettings(originating_contents); 479 GetContentSettings(originating_contents);
427 ContentSetting setting = CONTENT_SETTING_ASK; 480 ContentSetting setting = CONTENT_SETTING_ASK;
428 if (content_settings) 481 if (content_settings)
429 setting = content_settings->GetContentSetting( 482 setting = content_settings->GetContentSetting(
430 originating_contents->GetURL(), originating_contents->GetURL(), 483 originating_contents->GetURL(), originating_contents->GetURL(),
431 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string()); 484 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string());
432 switch (setting) { 485 switch (setting) {
433 case CONTENT_SETTING_ALLOW: { 486 case CONTENT_SETTING_ALLOW: {
434 TabSpecificContentSettings* settings = 487 state->SetDownloadStatusAndNotify(ALLOW_ALL_DOWNLOADS);
435 TabSpecificContentSettings::FromWebContents(originating_contents);
436 if (settings)
437 settings->SetDownloadsBlocked(false);
438 callback.Run(true); 488 callback.Run(true);
439 state->increment_download_count(); 489 state->increment_download_count();
440 return; 490 return;
441 } 491 }
442 case CONTENT_SETTING_BLOCK: { 492 case CONTENT_SETTING_BLOCK: {
443 TabSpecificContentSettings* settings = 493 state->SetDownloadStatusAndNotify(DOWNLOADS_NOT_ALLOWED);
444 TabSpecificContentSettings::FromWebContents(originating_contents);
445 if (settings)
446 settings->SetDownloadsBlocked(true);
447 callback.Run(false); 494 callback.Run(false);
448 return; 495 return;
449 } 496 }
450 case CONTENT_SETTING_DEFAULT: 497 case CONTENT_SETTING_DEFAULT:
451 case CONTENT_SETTING_ASK: 498 case CONTENT_SETTING_ASK:
452 case CONTENT_SETTING_SESSION_ONLY: 499 case CONTENT_SETTING_SESSION_ONLY:
453 state->PromptUserForDownload(callback); 500 state->PromptUserForDownload(callback);
454 state->increment_download_count(); 501 state->increment_download_count();
455 break; 502 break;
456 case CONTENT_SETTING_NUM_SETTINGS: 503 case CONTENT_SETTING_NUM_SETTINGS:
457 default: 504 default:
458 NOTREACHED(); 505 NOTREACHED();
459 return; 506 return;
460 } 507 }
461 break; 508 break;
462 } 509 }
463 510
464 default: 511 default:
465 NOTREACHED(); 512 NOTREACHED();
466 } 513 }
467 } 514 }
468 515
469 void DownloadRequestLimiter::Remove(TabDownloadState* state, 516 void DownloadRequestLimiter::Remove(TabDownloadState* state,
470 content::WebContents* contents) { 517 content::WebContents* contents) {
471 DCHECK(base::ContainsKey(state_map_, contents)); 518 DCHECK(base::ContainsKey(state_map_, contents));
472 state_map_.erase(contents); 519 state_map_.erase(contents);
473 delete state; 520 delete state;
474 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698