| OLD | NEW |
| 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/host_content_settings_map_factory.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/download/download_permission_request.h" | 11 #include "chrome/browser/download/download_permission_request.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
| 14 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 15 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 15 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 16 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return; | 354 return; |
| 354 } | 355 } |
| 355 | 356 |
| 356 CanDownloadImpl(originating_contents, | 357 CanDownloadImpl(originating_contents, |
| 357 request_method, | 358 request_method, |
| 358 orig_callback); | 359 orig_callback); |
| 359 } | 360 } |
| 360 | 361 |
| 361 HostContentSettingsMap* DownloadRequestLimiter::GetContentSettings( | 362 HostContentSettingsMap* DownloadRequestLimiter::GetContentSettings( |
| 362 content::WebContents* contents) { | 363 content::WebContents* contents) { |
| 363 return content_settings_ ? content_settings_ : Profile::FromBrowserContext( | 364 return content_settings_ ? content_settings_ : |
| 364 contents->GetBrowserContext())->GetHostContentSettingsMap(); | 365 HostContentSettingsMapFactory::GetForProfile( |
| 366 Profile::FromBrowserContext(contents->GetBrowserContext())); |
| 365 } | 367 } |
| 366 | 368 |
| 367 void DownloadRequestLimiter::CanDownloadImpl( | 369 void DownloadRequestLimiter::CanDownloadImpl( |
| 368 content::WebContents* originating_contents, | 370 content::WebContents* originating_contents, |
| 369 const std::string& request_method, | 371 const std::string& request_method, |
| 370 const Callback& callback) { | 372 const Callback& callback) { |
| 371 DCHECK(originating_contents); | 373 DCHECK(originating_contents); |
| 372 | 374 |
| 373 TabDownloadState* state = GetDownloadState( | 375 TabDownloadState* state = GetDownloadState( |
| 374 originating_contents, originating_contents, true); | 376 originating_contents, originating_contents, true); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 NOTREACHED(); | 441 NOTREACHED(); |
| 440 } | 442 } |
| 441 } | 443 } |
| 442 | 444 |
| 443 void DownloadRequestLimiter::Remove(TabDownloadState* state, | 445 void DownloadRequestLimiter::Remove(TabDownloadState* state, |
| 444 content::WebContents* contents) { | 446 content::WebContents* contents) { |
| 445 DCHECK(ContainsKey(state_map_, contents)); | 447 DCHECK(ContainsKey(state_map_, contents)); |
| 446 state_map_.erase(contents); | 448 state_map_.erase(contents); |
| 447 delete state; | 449 delete state; |
| 448 } | 450 } |
| OLD | NEW |