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

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: rebase 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
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <windows.h> 7 #include <windows.h>
8 #include <cguid.h>
9 #include <objbase.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" 19 #include "content/browser/safe_util_win.h"
17 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
18 21
19 namespace content { 22 namespace content {
20 namespace { 23 namespace {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return LogInterruptReason("SHFileOperation", result, interrupt_reason); 322 return LogInterruptReason("SHFileOperation", result, interrupt_reason);
320 return interrupt_reason; 323 return interrupt_reason;
321 } 324 }
322 325
323 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation() { 326 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation() {
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
325 DCHECK(!detached_); 328 DCHECK(!detached_);
326 329
327 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 330 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED);
328 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE; 331 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE;
329 HRESULT hr = ScanAndSaveDownloadedFile(full_path_, source_url_); 332 std::string braces_guid = "{" + client_guid_ + "}";
333 GUID guid = GUID_NULL;
334 if (base::IsValidGUID(client_guid_)) {
335 HRESULT hr = CLSIDFromString(
336 base::UTF8ToUTF16(braces_guid).c_str(), &guid);
337 if (FAILED(hr))
338 guid = GUID_NULL;
339 }
340
341 HRESULT hr = AVScanFile(full_path_, source_url_.spec(), guid);
330 342
331 // If the download file is missing after the call, then treat this as an 343 // If the download file is missing after the call, then treat this as an
332 // interrupted download. 344 // interrupted download.
333 // 345 //
334 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is 346 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is
335 // still around, then don't interrupt the download. Attachment Execution 347 // still around, then don't interrupt the download. Attachment Execution
336 // Services deletes the submitted file if the downloaded file is blocked by 348 // Services deletes the submitted file if the downloaded file is blocked by
337 // policy or if it was found to be infected. 349 // policy or if it was found to be infected.
338 // 350 //
339 // If the file is still there, then the error could be due to AES not being 351 // 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, 352 // available or some other error during the AES invocation. In either case,
341 // we don't surface the error to the user. 353 // we don't surface the error to the user.
342 if (!base::PathExists(full_path_)) { 354 if (!base::PathExists(full_path_)) {
343 DCHECK(FAILED(hr)); 355 DCHECK(FAILED(hr));
344 result = MapScanAndSaveErrorCodeToInterruptReason(hr); 356 result = MapScanAndSaveErrorCodeToInterruptReason(hr);
345 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) { 357 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) {
346 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); 358 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT);
347 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; 359 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED;
348 } 360 }
349 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); 361 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result);
350 } 362 }
351 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); 363 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED);
352 return result; 364 return result;
353 } 365 }
354 366
355 } // namespace content 367 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698