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

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: " 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // TODO(phajdan.jr): Find some standard location for this, maintaining 78 // TODO(phajdan.jr): Find some standard location for this, maintaining
79 // the same value on all platforms. 79 // the same value on all platforms.
80 static const double PI = 3.141592653589793; 80 static const double PI = 3.141592653589793;
81 81
82 using content::DownloadItem; 82 using content::DownloadItem;
83 83
84 namespace { 84 namespace {
85 85
86 // Returns a string constant to be used as the |danger_type| value in 86 // Returns a string constant to be used as the |danger_type| value in
87 // CreateDownloadItemValue(). We only return strings for DANGEROUS_FILE, 87 // CreateDownloadItemValue(). We only return strings for DANGEROUS_FILE,
88 // DANGEROUS_URL and DANGEROUS_CONTENT because the |danger_type| value is only 88 // DANGEROUS_URL, DANGEROUS_CONTENT, and UNCOMMON_CONTENT because the
89 // defined if the value of |state| is |DANGEROUS|. 89 // |danger_type| value is only defined if the value of |state| is |DANGEROUS|.
90 const char* GetDangerTypeString(content::DownloadDangerType danger_type) { 90 const char* GetDangerTypeString(content::DownloadDangerType danger_type) {
91 switch (danger_type) { 91 switch (danger_type) {
92 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: 92 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
93 return "DANGEROUS_FILE"; 93 return "DANGEROUS_FILE";
94 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: 94 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
95 return "DANGEROUS_URL"; 95 return "DANGEROUS_URL";
96 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: 96 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
97 return "DANGEROUS_CONTENT"; 97 return "DANGEROUS_CONTENT";
98 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
99 return "UNCOMMON_CONTENT";
98 default: 100 default:
99 // We shouldn't be returning a danger type string if it is 101 // We shouldn't be returning a danger type string if it is
100 // NOT_DANGEROUS or MAYBE_DANGEROUS_CONTENT. 102 // NOT_DANGEROUS or MAYBE_DANGEROUS_CONTENT.
101 NOTREACHED(); 103 NOTREACHED();
102 return ""; 104 return "";
103 } 105 }
104 } 106 }
105 107
106 } // namespace 108 } // namespace
107 109
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (download->IsInProgress()) { 452 if (download->IsInProgress()) {
451 if (download->GetSafetyState() == DownloadItem::DANGEROUS) { 453 if (download->GetSafetyState() == DownloadItem::DANGEROUS) {
452 file_value->SetString("state", "DANGEROUS"); 454 file_value->SetString("state", "DANGEROUS");
453 // These are the only danger states we expect to see (and the UI is 455 // These are the only danger states we expect to see (and the UI is
454 // equipped to handle): 456 // equipped to handle):
455 DCHECK(download->GetDangerType() == 457 DCHECK(download->GetDangerType() ==
456 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 458 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
457 download->GetDangerType() == 459 download->GetDangerType() ==
458 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 460 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
459 download->GetDangerType() == 461 download->GetDangerType() ==
460 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); 462 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
463 download->GetDangerType() ==
464 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
461 const char* danger_type_value = 465 const char* danger_type_value =
462 GetDangerTypeString(download->GetDangerType()); 466 GetDangerTypeString(download->GetDangerType());
463 file_value->SetString("danger_type", danger_type_value); 467 file_value->SetString("danger_type", danger_type_value);
464 } else if (download->IsPaused()) { 468 } else if (download->IsPaused()) {
465 file_value->SetString("state", "PAUSED"); 469 file_value->SetString("state", "PAUSED");
466 } else { 470 } else {
467 file_value->SetString("state", "IN_PROGRESS"); 471 file_value->SetString("state", "IN_PROGRESS");
468 } 472 }
469 473
470 file_value->SetString("progress_status_text", 474 file_value->SetString("progress_status_text",
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 UMA_HISTOGRAM_ENUMERATION( 633 UMA_HISTOGRAM_ENUMERATION(
630 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 634 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
631 } 635 }
632 636
633 void RecordDownloadSource(ChromeDownloadSource source) { 637 void RecordDownloadSource(ChromeDownloadSource source) {
634 UMA_HISTOGRAM_ENUMERATION( 638 UMA_HISTOGRAM_ENUMERATION(
635 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 639 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
636 } 640 }
637 641
638 } // namespace download_util 642 } // namespace download_util
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/resources/chromeos/active_downloads.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698