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

Side by Side Diff: content/browser/download/base_file_win.cc

Issue 21355004: [Downloads] Move client guid for AV scanning of downloaded files to chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove safe_util_win Created 7 years, 4 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) 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 "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include <objbase.h>
7 #include <windows.h> 8 #include <windows.h>
Lei Zhang 2013/08/07 01:03:05 nit: I think <windows.h> usually goes first?
Greg Billock 2013/08/07 17:00:56 we got some of both. I'll change it here though.
9 #include <cguid.h>
8 #include <shellapi.h> 10 #include <shellapi.h>
9 11
10 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/guid.h"
11 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
12 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
14 #include "content/browser/download/download_interrupt_reasons_impl.h" 17 #include "content/browser/download/download_interrupt_reasons_impl.h"
15 #include "content/browser/download/download_stats.h" 18 #include "content/browser/download/download_stats.h"
16 #include "content/browser/safe_util_win.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 20
19 namespace content { 21 namespace content {
20 namespace { 22 namespace {
21 23
22 const int kAllSpecialShFileOperationCodes[] = { 24 const int kAllSpecialShFileOperationCodes[] = {
23 // Should be kept in sync with the case statement below. 25 // Should be kept in sync with the case statement below.
24 ERROR_ACCESS_DENIED, 26 ERROR_ACCESS_DENIED,
25 0x71, 27 0x71,
26 0x72, 28 0x72,
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return LogInterruptReason("SHFileOperation", result, interrupt_reason); 321 return LogInterruptReason("SHFileOperation", result, interrupt_reason);
320 return interrupt_reason; 322 return interrupt_reason;
321 } 323 }
322 324
323 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation() { 325 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation() {
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
325 DCHECK(!detached_); 327 DCHECK(!detached_);
326 328
327 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 329 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED);
328 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE; 330 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE;
329 HRESULT hr = ScanAndSaveDownloadedFile(full_path_, source_url_); 331 GUID guid = GUID_NULL;
332 if (!client_guid_.empty() && base::IsValidGUID(client_guid_)) {
asanka 2013/08/07 16:42:36 Skip this validation step and just DCHECK the retu
Greg Billock 2013/08/07 17:42:56 I wasn't sure what bad thing CLSIDFromString might
333 HRESULT hr = CLSIDFromString(
asanka 2013/08/07 16:42:36 Have you looked at using UuidFromString() instead?
Greg Billock 2013/08/07 17:42:56 I saw UuidFromString(), but it isn't used elsewher
asanka 2013/08/07 19:56:12 I don't consider myself to be an expert on this, s
Greg Billock 2013/08/07 23:10:31 Tried UuidFromString. This is part of the RPC libr
334 base::UTF8ToUTF16(client_guid_).c_str(), &guid);
335 if (FAILED(hr))
336 guid = GUID_NULL;
337 }
338 HRESULT hr = base::AVScanFile(full_path_, source_url_.spec(), guid);
330 339
331 // If the download file is missing after the call, then treat this as an 340 // If the download file is missing after the call, then treat this as an
332 // interrupted download. 341 // interrupted download.
333 // 342 //
334 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is 343 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is
335 // still around, then don't interrupt the download. Attachment Execution 344 // still around, then don't interrupt the download. Attachment Execution
336 // Services deletes the submitted file if the downloaded file is blocked by 345 // Services deletes the submitted file if the downloaded file is blocked by
337 // policy or if it was found to be infected. 346 // policy or if it was found to be infected.
338 // 347 //
339 // If the file is still there, then the error could be due to AES not being 348 // If the file is still there, then the error could be due to AES not being
340 // available or some other error during the AES invocation. In either case, 349 // available or some other error during the AES invocation. In either case,
341 // we don't surface the error to the user. 350 // we don't surface the error to the user.
342 if (!base::PathExists(full_path_)) { 351 if (!base::PathExists(full_path_)) {
343 DCHECK(FAILED(hr)); 352 DCHECK(FAILED(hr));
344 result = MapScanAndSaveErrorCodeToInterruptReason(hr); 353 result = MapScanAndSaveErrorCodeToInterruptReason(hr);
345 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) { 354 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) {
346 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); 355 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT);
347 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; 356 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED;
348 } 357 }
349 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); 358 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result);
350 } 359 }
351 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 360 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED);
352 return result; 361 return result;
353 } 362 }
354 363
355 } // namespace content 364 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698