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

Side by Side Diff: chrome/browser/history/download_database.cc

Issue 19863005: Warn users about potentially unwanted downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a "Learn more" URL for unwanted downloads. Created 7 years, 5 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 "chrome/browser/history/download_database.h" 5 #include "chrome/browser/history/download_database.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 const int DownloadDatabase::kDangerTypeInvalid = -1; 105 const int DownloadDatabase::kDangerTypeInvalid = -1;
106 const int DownloadDatabase::kDangerTypeNotDangerous = 0; 106 const int DownloadDatabase::kDangerTypeNotDangerous = 0;
107 const int DownloadDatabase::kDangerTypeDangerousFile = 1; 107 const int DownloadDatabase::kDangerTypeDangerousFile = 1;
108 const int DownloadDatabase::kDangerTypeDangerousUrl = 2; 108 const int DownloadDatabase::kDangerTypeDangerousUrl = 2;
109 const int DownloadDatabase::kDangerTypeDangerousContent = 3; 109 const int DownloadDatabase::kDangerTypeDangerousContent = 3;
110 const int DownloadDatabase::kDangerTypeMaybeDangerousContent = 4; 110 const int DownloadDatabase::kDangerTypeMaybeDangerousContent = 4;
111 const int DownloadDatabase::kDangerTypeUncommonContent = 5; 111 const int DownloadDatabase::kDangerTypeUncommonContent = 5;
112 const int DownloadDatabase::kDangerTypeUserValidated = 6; 112 const int DownloadDatabase::kDangerTypeUserValidated = 6;
113 const int DownloadDatabase::kDangerTypeDangerousHost = 7; 113 const int DownloadDatabase::kDangerTypeDangerousHost = 7;
114 const int DownloadDatabase::kDangerTypePotentiallyUnwanted = 8;
114 115
115 int DownloadDatabase::StateToInt(DownloadItem::DownloadState state) { 116 int DownloadDatabase::StateToInt(DownloadItem::DownloadState state) {
116 switch (state) { 117 switch (state) {
117 case DownloadItem::IN_PROGRESS: return DownloadDatabase::kStateInProgress; 118 case DownloadItem::IN_PROGRESS: return DownloadDatabase::kStateInProgress;
118 case DownloadItem::COMPLETE: return DownloadDatabase::kStateComplete; 119 case DownloadItem::COMPLETE: return DownloadDatabase::kStateComplete;
119 case DownloadItem::CANCELLED: return DownloadDatabase::kStateCancelled; 120 case DownloadItem::CANCELLED: return DownloadDatabase::kStateCancelled;
120 case DownloadItem::INTERRUPTED: return DownloadDatabase::kStateInterrupted; 121 case DownloadItem::INTERRUPTED: return DownloadDatabase::kStateInterrupted;
121 case DownloadItem::MAX_DOWNLOAD_STATE: 122 case DownloadItem::MAX_DOWNLOAD_STATE:
122 NOTREACHED(); 123 NOTREACHED();
123 return DownloadDatabase::kStateInvalid; 124 return DownloadDatabase::kStateInvalid;
(...skipping 25 matching lines...) Expand all
149 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: 150 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
150 return DownloadDatabase::kDangerTypeDangerousContent; 151 return DownloadDatabase::kDangerTypeDangerousContent;
151 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: 152 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT:
152 return DownloadDatabase::kDangerTypeMaybeDangerousContent; 153 return DownloadDatabase::kDangerTypeMaybeDangerousContent;
153 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: 154 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
154 return DownloadDatabase::kDangerTypeUncommonContent; 155 return DownloadDatabase::kDangerTypeUncommonContent;
155 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: 156 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
156 return DownloadDatabase::kDangerTypeUserValidated; 157 return DownloadDatabase::kDangerTypeUserValidated;
157 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: 158 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
158 return DownloadDatabase::kDangerTypeDangerousHost; 159 return DownloadDatabase::kDangerTypeDangerousHost;
160 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED:
161 return DownloadDatabase::kDangerTypePotentiallyUnwanted;
159 case content::DOWNLOAD_DANGER_TYPE_MAX: 162 case content::DOWNLOAD_DANGER_TYPE_MAX:
160 NOTREACHED(); 163 NOTREACHED();
161 return DownloadDatabase::kDangerTypeInvalid; 164 return DownloadDatabase::kDangerTypeInvalid;
162 } 165 }
163 NOTREACHED(); 166 NOTREACHED();
164 return DownloadDatabase::kDangerTypeInvalid; 167 return DownloadDatabase::kDangerTypeInvalid;
165 } 168 }
166 169
167 content::DownloadDangerType DownloadDatabase::IntToDangerType(int danger_type) { 170 content::DownloadDangerType DownloadDatabase::IntToDangerType(int danger_type) {
168 switch (danger_type) { 171 switch (danger_type) {
169 case DownloadDatabase::kDangerTypeNotDangerous: 172 case DownloadDatabase::kDangerTypeNotDangerous:
170 return content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; 173 return content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS;
171 case DownloadDatabase::kDangerTypeDangerousFile: 174 case DownloadDatabase::kDangerTypeDangerousFile:
172 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; 175 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
173 case DownloadDatabase::kDangerTypeDangerousUrl: 176 case DownloadDatabase::kDangerTypeDangerousUrl:
174 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; 177 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL;
175 case DownloadDatabase::kDangerTypeDangerousContent: 178 case DownloadDatabase::kDangerTypeDangerousContent:
176 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; 179 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT;
177 case DownloadDatabase::kDangerTypeMaybeDangerousContent: 180 case DownloadDatabase::kDangerTypeMaybeDangerousContent:
178 return content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; 181 return content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT;
179 case DownloadDatabase::kDangerTypeUncommonContent: 182 case DownloadDatabase::kDangerTypeUncommonContent:
180 return content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; 183 return content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT;
181 case DownloadDatabase::kDangerTypeUserValidated: 184 case DownloadDatabase::kDangerTypeUserValidated:
182 return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED; 185 return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED;
183 case DownloadDatabase::kDangerTypeDangerousHost: 186 case DownloadDatabase::kDangerTypeDangerousHost:
184 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; 187 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST;
188 case DownloadDatabase::kDangerTypePotentiallyUnwanted:
189 return content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED;
185 default: 190 default:
186 return content::DOWNLOAD_DANGER_TYPE_MAX; 191 return content::DOWNLOAD_DANGER_TYPE_MAX;
187 } 192 }
188 } 193 }
189 194
190 DownloadDatabase::DownloadDatabase() 195 DownloadDatabase::DownloadDatabase()
191 : owning_thread_set_(false), 196 : owning_thread_set_(false),
192 owning_thread_(0), 197 owning_thread_(0),
193 in_progress_entry_cleanup_completed_(false) { 198 in_progress_entry_cleanup_completed_(false) {
194 } 199 }
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 size_t DownloadDatabase::CountDownloads() { 590 size_t DownloadDatabase::CountDownloads() {
586 EnsureInProgressEntriesCleanedUp(); 591 EnsureInProgressEntriesCleanedUp();
587 592
588 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 593 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
589 "SELECT count(*) from downloads")); 594 "SELECT count(*) from downloads"));
590 statement.Step(); 595 statement.Step();
591 return statement.ColumnInt(0); 596 return statement.ColumnInt(0);
592 } 597 }
593 598
594 } // namespace history 599 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/download_database.h ('k') | chrome/browser/resources/downloads/downloads.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698