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

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

Issue 9621007: Add new danger type for uncommon or unknown downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased only Created 8 years, 9 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 // Download utility implementation 5 // Download utility implementation
6 6
7 #include "chrome/browser/download/download_util.h" 7 #include "chrome/browser/download/download_util.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <shobjidl.h> 10 #include <shobjidl.h>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // TODO(phajdan.jr): Find some standard location for this, maintaining 79 // TODO(phajdan.jr): Find some standard location for this, maintaining
80 // the same value on all platforms. 80 // the same value on all platforms.
81 static const double PI = 3.141592653589793; 81 static const double PI = 3.141592653589793;
82 82
83 using content::DownloadItem; 83 using content::DownloadItem;
84 84
85 namespace { 85 namespace {
86 86
87 // Returns a string constant to be used as the |danger_type| value in 87 // Returns a string constant to be used as the |danger_type| value in
88 // CreateDownloadItemValue(). We only return strings for DANGEROUS_FILE, 88 // CreateDownloadItemValue(). We only return strings for DANGEROUS_FILE,
89 // DANGEROUS_URL and DANGEROUS_CONTENT because the |danger_type| value is only 89 // DANGEROUS_URL, DANGEROUS_CONTENT, and UNCOMMON_CONTENT because the
90 // defined if the value of |state| is |DANGEROUS|. 90 // |danger_type| value is only defined if the value of |state| is |DANGEROUS|.
91 const char* GetDangerTypeString(content::DownloadDangerType danger_type) { 91 const char* GetDangerTypeString(content::DownloadDangerType danger_type) {
92 switch (danger_type) { 92 switch (danger_type) {
93 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: 93 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
94 return "DANGEROUS_FILE"; 94 return "DANGEROUS_FILE";
95 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: 95 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
96 return "DANGEROUS_URL"; 96 return "DANGEROUS_URL";
97 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: 97 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
98 return "DANGEROUS_CONTENT"; 98 return "DANGEROUS_CONTENT";
99 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
100 return "UNCOMMON_CONTENT";
99 default: 101 default:
100 // We shouldn't be returning a danger type string if it is 102 // We shouldn't be returning a danger type string if it is
101 // NOT_DANGEROUS or MAYBE_DANGEROUS_CONTENT. 103 // NOT_DANGEROUS or MAYBE_DANGEROUS_CONTENT.
102 NOTREACHED(); 104 NOTREACHED();
103 return ""; 105 return "";
104 } 106 }
105 } 107 }
106 108
107 } // namespace 109 } // namespace
108 110
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (download->IsInProgress()) { 453 if (download->IsInProgress()) {
452 if (download->GetSafetyState() == DownloadItem::DANGEROUS) { 454 if (download->GetSafetyState() == DownloadItem::DANGEROUS) {
453 file_value->SetString("state", "DANGEROUS"); 455 file_value->SetString("state", "DANGEROUS");
454 // These are the only danger states we expect to see (and the UI is 456 // These are the only danger states we expect to see (and the UI is
455 // equipped to handle): 457 // equipped to handle):
456 DCHECK(download->GetDangerType() == 458 DCHECK(download->GetDangerType() ==
457 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 459 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
458 download->GetDangerType() == 460 download->GetDangerType() ==
459 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 461 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
460 download->GetDangerType() == 462 download->GetDangerType() ==
461 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); 463 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
464 download->GetDangerType() ==
465 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
462 const char* danger_type_value = 466 const char* danger_type_value =
463 GetDangerTypeString(download->GetDangerType()); 467 GetDangerTypeString(download->GetDangerType());
464 file_value->SetString("danger_type", danger_type_value); 468 file_value->SetString("danger_type", danger_type_value);
465 } else if (download->IsPaused()) { 469 } else if (download->IsPaused()) {
466 file_value->SetString("state", "PAUSED"); 470 file_value->SetString("state", "PAUSED");
467 } else { 471 } else {
468 file_value->SetString("state", "IN_PROGRESS"); 472 file_value->SetString("state", "IN_PROGRESS");
469 } 473 }
470 474
471 file_value->SetString("progress_status_text", 475 file_value->SetString("progress_status_text",
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 UMA_HISTOGRAM_ENUMERATION( 634 UMA_HISTOGRAM_ENUMERATION(
631 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 635 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
632 } 636 }
633 637
634 void RecordDownloadSource(ChromeDownloadSource source) { 638 void RecordDownloadSource(ChromeDownloadSource source) {
635 UMA_HISTOGRAM_ENUMERATION( 639 UMA_HISTOGRAM_ENUMERATION(
636 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 640 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
637 } 641 }
638 642
639 } // namespace download_util 643 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698