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

Side by Side Diff: chrome/browser/download/download_file_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: '' Created 9 years, 6 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_file_manager.h" 5 #include "chrome/browser/download/download_file_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/download/download_create_info.h" 14 #include "chrome/browser/download/download_create_info.h"
15 #include "chrome/browser/download/download_manager.h" 15 #include "chrome/browser/download/download_manager.h"
16 #include "chrome/browser/download/download_request_handle.h" 16 #include "chrome/browser/download/download_request_handle.h"
17 #include "chrome/browser/download/download_util.h" 17 #include "chrome/browser/download/download_util.h"
18 #include "chrome/browser/net/chrome_url_request_context.h" 18 #include "chrome/browser/net/chrome_url_request_context.h"
19 #include "chrome/browser/platform_util.h" 19 #include "chrome/browser/platform_util.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/browser/tab_contents/tab_util.h" 22 #include "chrome/browser/tab_contents/tab_util.h"
23 #include "chrome/common/pref_names.h"
23 #include "content/browser/browser_thread.h" 24 #include "content/browser/browser_thread.h"
24 #include "content/browser/renderer_host/resource_dispatcher_host.h" 25 #include "content/browser/renderer_host/resource_dispatcher_host.h"
25 #include "content/browser/tab_contents/tab_contents.h" 26 #include "content/browser/tab_contents/tab_contents.h"
26 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
27 #include "net/base/io_buffer.h" 28 #include "net/base/io_buffer.h"
28 29
29 namespace { 30 namespace {
30 31
31 // Throttle updates to the UI thread so that a fast moving download doesn't 32 // Throttle updates to the UI thread so that a fast moving download doesn't
32 // cause it to become unresponsive (in milliseconds). 33 // cause it to become unresponsive (in milliseconds).
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 delete info; 139 delete info;
139 return; 140 return;
140 } 141 }
141 142
142 // TODO(phajdan.jr): fix the duplication of path info below. 143 // TODO(phajdan.jr): fix the duplication of path info below.
143 info->path = info->save_info.file_path; 144 info->path = info->save_info.file_path;
144 145
145 manager->CreateDownloadItem(info); 146 manager->CreateDownloadItem(info);
146 147
147 bool hash_needed = g_browser_process->safe_browsing_service()-> 148 bool hash_needed = g_browser_process->safe_browsing_service()->
148 DownloadBinHashNeeded(); 149 DownloadBinHashNeeded(manager->profile()->GetPrefs()->GetBoolean(
150 prefs::kSafeBrowsingEnabled));
149 151
150 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 152 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
151 NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile, 153 NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile,
152 info, make_scoped_refptr(manager), hash_needed)); 154 info, make_scoped_refptr(manager), hash_needed));
153 } 155 }
154 156
155 // We don't forward an update to the UI thread here, since we want to throttle 157 // We don't forward an update to the UI thread here, since we want to throttle
156 // the UI update rate via a periodic timer. If the user has cancelled the 158 // the UI update rate via a periodic timer. If the user has cancelled the
157 // download (in the UI thread), we may receive a few more updates before the IO 159 // download (in the UI thread), we may receive a few more updates before the IO
158 // thread gets the cancel message: we just delete the data since the 160 // thread gets the cancel message: we just delete the data since the
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 << " id = " << id 394 << " id = " << id
393 << " download_file = " << download_file->DebugString(); 395 << " download_file = " << download_file->DebugString();
394 396
395 downloads_.erase(id); 397 downloads_.erase(id);
396 398
397 delete download_file; 399 delete download_file;
398 400
399 if (downloads_.empty()) 401 if (downloads_.empty())
400 StopUpdateTimer(); 402 StopUpdateTimer();
401 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698