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

Side by Side Diff: chrome/browser/download/download_extension_api.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
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('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 "chrome/browser/download/download_extension_api.h" 5 #include "chrome/browser/download/download_extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const int kDefaultIconSize = 32; 75 const int kDefaultIconSize = 32;
76 76
77 // Parameter keys 77 // Parameter keys
78 const char kBodyKey[] = "body"; 78 const char kBodyKey[] = "body";
79 const char kBytesReceivedKey[] = "bytesReceived"; 79 const char kBytesReceivedKey[] = "bytesReceived";
80 const char kDangerAcceptedKey[] = "dangerAccepted"; 80 const char kDangerAcceptedKey[] = "dangerAccepted";
81 const char kDangerContent[] = "content"; 81 const char kDangerContent[] = "content";
82 const char kDangerFile[] = "file"; 82 const char kDangerFile[] = "file";
83 const char kDangerKey[] = "danger"; 83 const char kDangerKey[] = "danger";
84 const char kDangerSafe[] = "safe"; 84 const char kDangerSafe[] = "safe";
85 const char kDangerUncommon[] = "uncommon";
85 const char kDangerUrl[] = "url"; 86 const char kDangerUrl[] = "url";
86 const char kEndTimeKey[] = "endTime"; 87 const char kEndTimeKey[] = "endTime";
87 const char kErrorKey[] = "error"; 88 const char kErrorKey[] = "error";
88 const char kFileSizeKey[] = "fileSize"; 89 const char kFileSizeKey[] = "fileSize";
89 const char kFilenameKey[] = "filename"; 90 const char kFilenameKey[] = "filename";
90 const char kFilenameRegexKey[] = "filenameRegex"; 91 const char kFilenameRegexKey[] = "filenameRegex";
91 const char kHeaderNameKey[] = "name"; 92 const char kHeaderNameKey[] = "name";
92 const char kHeaderValueKey[] = "value"; 93 const char kHeaderValueKey[] = "value";
93 const char kHeaderBinaryValueKey[] = "binaryValue"; 94 const char kHeaderBinaryValueKey[] = "binaryValue";
94 const char kHeadersKey[] = "headers"; 95 const char kHeadersKey[] = "headers";
(...skipping 12 matching lines...) Expand all
107 const char kStateComplete[] = "complete"; 108 const char kStateComplete[] = "complete";
108 const char kStateInProgress[] = "in_progress"; 109 const char kStateInProgress[] = "in_progress";
109 const char kStateInterrupted[] = "interrupted"; 110 const char kStateInterrupted[] = "interrupted";
110 const char kStateKey[] = "state"; 111 const char kStateKey[] = "state";
111 const char kTotalBytesKey[] = "totalBytes"; 112 const char kTotalBytesKey[] = "totalBytes";
112 const char kTotalBytesGreaterKey[] = "totalBytesGreater"; 113 const char kTotalBytesGreaterKey[] = "totalBytesGreater";
113 const char kTotalBytesLessKey[] = "totalBytesLess"; 114 const char kTotalBytesLessKey[] = "totalBytesLess";
114 const char kUrlKey[] = "url"; 115 const char kUrlKey[] = "url";
115 const char kUrlRegexKey[] = "urlRegex"; 116 const char kUrlRegexKey[] = "urlRegex";
116 117
118 // Note: Any change to the danger type strings, should be accompanied by a
119 // corresponding change to {experimental.}downloads.json.
117 const char* kDangerStrings[] = { 120 const char* kDangerStrings[] = {
118 kDangerSafe, 121 kDangerSafe,
119 kDangerFile, 122 kDangerFile,
120 kDangerUrl, 123 kDangerUrl,
121 kDangerContent, 124 kDangerContent,
122 kDangerSafe, 125 kDangerSafe,
126 kDangerUncommon,
123 }; 127 };
128 COMPILE_ASSERT(arraysize(kDangerStrings) == content::DOWNLOAD_DANGER_TYPE_MAX,
129 download_danger_type_enum_changed);
124 130
131 // Note: Any change to the state strings, should be accompanied by a
132 // corresponding change to {experimental.}downloads.json.
125 const char* kStateStrings[] = { 133 const char* kStateStrings[] = {
126 kStateInProgress, 134 kStateInProgress,
127 kStateComplete, 135 kStateComplete,
128 kStateInterrupted, 136 kStateInterrupted,
129 NULL, 137 NULL,
130 kStateInterrupted, 138 kStateInterrupted,
131 }; 139 };
140 COMPILE_ASSERT(arraysize(kStateStrings) == DownloadItem::MAX_DOWNLOAD_STATE,
141 download_item_state_enum_changed);
132 142
133 const char* DangerString(content::DownloadDangerType danger) { 143 const char* DangerString(content::DownloadDangerType danger) {
134 DCHECK(danger >= 0); 144 DCHECK(danger >= 0);
135 DCHECK(danger < static_cast<content::DownloadDangerType>( 145 DCHECK(danger < static_cast<content::DownloadDangerType>(
136 arraysize(kDangerStrings))); 146 arraysize(kDangerStrings)));
137 return kDangerStrings[danger]; 147 return kDangerStrings[danger];
138 } 148 }
139 149
140 content::DownloadDangerType DangerEnumFromString(const std::string& danger) { 150 content::DownloadDangerType DangerEnumFromString(const std::string& danger) {
141 for (size_t i = 0; i < arraysize(kDangerStrings); ++i) { 151 for (size_t i = 0; i < arraysize(kDangerStrings); ++i) {
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 ListValue args; 1076 ListValue args;
1067 args.Append(arg); 1077 args.Append(arg);
1068 std::string json_args; 1078 std::string json_args;
1069 base::JSONWriter::Write(&args, &json_args); 1079 base::JSONWriter::Write(&args, &json_args);
1070 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 1080 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
1071 event_name, 1081 event_name,
1072 json_args, 1082 json_args,
1073 profile_, 1083 profile_,
1074 GURL()); 1084 GURL());
1075 } 1085 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698