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

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

Issue 7134017: Make safe browsing work in a multi-profile environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: addressed sky's nit Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
31 #include "chrome/browser/history/download_history_info.h" 31 #include "chrome/browser/history/download_history_info.h"
32 #include "chrome/browser/platform_util.h" 32 #include "chrome/browser/platform_util.h"
33 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/tab_contents/tab_util.h" 34 #include "chrome/browser/tab_contents/tab_util.h"
35 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/browser/ui/download/download_tab_helper.h" 37 #include "chrome/browser/ui/download/download_tab_helper.h"
38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
39 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
40 #include "chrome/common/pref_names.h"
40 #include "content/browser/browser_thread.h" 41 #include "content/browser/browser_thread.h"
41 #include "content/browser/renderer_host/render_process_host.h" 42 #include "content/browser/renderer_host/render_process_host.h"
42 #include "content/browser/renderer_host/render_view_host.h" 43 #include "content/browser/renderer_host/render_view_host.h"
43 #include "content/browser/renderer_host/resource_dispatcher_host.h" 44 #include "content/browser/renderer_host/resource_dispatcher_host.h"
44 #include "content/browser/tab_contents/tab_contents.h" 45 #include "content/browser/tab_contents/tab_contents.h"
45 #include "content/common/content_notification_types.h" 46 #include "content/common/content_notification_types.h"
46 #include "googleurl/src/gurl.h" 47 #include "googleurl/src/gurl.h"
47 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
48 #include "grit/theme_resources.h" 49 #include "grit/theme_resources.h"
49 #include "net/base/mime_util.h" 50 #include "net/base/mime_util.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
264 265
265 DownloadItem* download = GetActiveDownloadItem(download_id); 266 DownloadItem* download = GetActiveDownloadItem(download_id);
266 if (!download) 267 if (!download)
267 return; 268 return;
268 269
269 #if defined(ENABLE_SAFE_BROWSING) 270 #if defined(ENABLE_SAFE_BROWSING)
270 // Create a client to verify download URL with safebrowsing. 271 // Create a client to verify download URL with safebrowsing.
271 // It deletes itself after the callback. 272 // It deletes itself after the callback.
272 scoped_refptr<DownloadSBClient> sb_client = new DownloadSBClient( 273 scoped_refptr<DownloadSBClient> sb_client = new DownloadSBClient(
273 download_id, download->url_chain(), download->referrer_url()); 274 download_id, download->url_chain(), download->referrer_url(),
275 profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled));
274 sb_client->CheckDownloadUrl( 276 sb_client->CheckDownloadUrl(
275 NewCallback(this, &DownloadManager::CheckDownloadUrlDone)); 277 NewCallback(this, &DownloadManager::CheckDownloadUrlDone));
276 #else 278 #else
277 CheckDownloadUrlDone(download_id, false); 279 CheckDownloadUrlDone(download_id, false);
278 #endif 280 #endif
279 } 281 }
280 282
281 void DownloadManager::CheckForHistoryFilesRemoval() { 283 void DownloadManager::CheckForHistoryFilesRemoval() {
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
283 for (DownloadMap::iterator it = history_downloads_.begin(); 285 for (DownloadMap::iterator it = history_downloads_.begin();
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 download->OnAllDataSaved(size); 668 download->OnAllDataSaved(size);
667 669
668 // When hash is not available, it means either it is not calculated 670 // When hash is not available, it means either it is not calculated
669 // or there is error while it is calculated. We will skip the download hash 671 // or there is error while it is calculated. We will skip the download hash
670 // check in that case. 672 // check in that case.
671 if (!hash.empty()) { 673 if (!hash.empty()) {
672 #if defined(ENABLE_SAFE_BROWSING) 674 #if defined(ENABLE_SAFE_BROWSING)
673 scoped_refptr<DownloadSBClient> sb_client = 675 scoped_refptr<DownloadSBClient> sb_client =
674 new DownloadSBClient(download_id, 676 new DownloadSBClient(download_id,
675 download->url_chain(), 677 download->url_chain(),
676 download->referrer_url()); 678 download->referrer_url(),
679 profile_->GetPrefs()->GetBoolean(
680 prefs::kSafeBrowsingEnabled));
677 sb_client->CheckDownloadHash( 681 sb_client->CheckDownloadHash(
678 hash, NewCallback(this, &DownloadManager::CheckDownloadHashDone)); 682 hash, NewCallback(this, &DownloadManager::CheckDownloadHashDone));
679 #else 683 #else
680 CheckDownloadHashDone(download_id, false); 684 CheckDownloadHashDone(download_id, false);
681 #endif 685 #endif
682 } 686 }
683 MaybeCompleteDownload(download); 687 MaybeCompleteDownload(download);
684 } 688 }
685 689
686 // TODO(lzheng): This function currently works as a callback place holder. 690 // TODO(lzheng): This function currently works as a callback place holder.
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 observed_download_manager_->RemoveObserver(this); 1364 observed_download_manager_->RemoveObserver(this);
1361 } 1365 }
1362 1366
1363 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { 1367 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() {
1364 observing_download_manager_->NotifyModelChanged(); 1368 observing_download_manager_->NotifyModelChanged();
1365 } 1369 }
1366 1370
1367 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1371 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1368 observed_download_manager_ = NULL; 1372 observed_download_manager_ = NULL;
1369 } 1373 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file_manager.cc ('k') | chrome/browser/download/download_safe_browsing_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698