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

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

Issue 2901563003: PDF: Add UMA to track embedded PDF triggered drive-by downloads. (Closed)
Patch Set: remove stray comment Created 3 years, 7 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
« no previous file with comments | « no previous file | chrome/common/BUILD.gn » ('j') | chrome/common/BUILD.gn » ('J')
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/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #endif 71 #endif
72 72
73 #if BUILDFLAG(ENABLE_EXTENSIONS) 73 #if BUILDFLAG(ENABLE_EXTENSIONS)
74 #include "chrome/browser/extensions/api/downloads/downloads_api.h" 74 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
75 #include "chrome/browser/extensions/crx_installer.h" 75 #include "chrome/browser/extensions/crx_installer.h"
76 #include "chrome/browser/extensions/webstore_installer.h" 76 #include "chrome/browser/extensions/webstore_installer.h"
77 #include "extensions/browser/notification_types.h" 77 #include "extensions/browser/notification_types.h"
78 #include "extensions/common/constants.h" 78 #include "extensions/common/constants.h"
79 #endif 79 #endif
80 80
81 #if BUILDFLAG(ENABLE_PLUGINS)
82 #include "chrome/common/pdf_uma.h"
83 #endif
84
81 using content::BrowserThread; 85 using content::BrowserThread;
82 using content::DownloadItem; 86 using content::DownloadItem;
83 using content::DownloadManager; 87 using content::DownloadManager;
84 using safe_browsing::DownloadFileType; 88 using safe_browsing::DownloadFileType;
85 using safe_browsing::DownloadProtectionService; 89 using safe_browsing::DownloadProtectionService;
86 90
87 namespace { 91 namespace {
88 92
89 #if defined(FULL_SAFE_BROWSING) 93 #if defined(FULL_SAFE_BROWSING)
90 94
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // On Android, Chrome wants to warn the user of file overwrites rather than 203 // On Android, Chrome wants to warn the user of file overwrites rather than
200 // uniquify. 204 // uniquify.
201 #if defined(OS_ANDROID) 205 #if defined(OS_ANDROID)
202 const DownloadPathReservationTracker::FilenameConflictAction 206 const DownloadPathReservationTracker::FilenameConflictAction
203 kDefaultPlatformConflictAction = DownloadPathReservationTracker::PROMPT; 207 kDefaultPlatformConflictAction = DownloadPathReservationTracker::PROMPT;
204 #else 208 #else
205 const DownloadPathReservationTracker::FilenameConflictAction 209 const DownloadPathReservationTracker::FilenameConflictAction
206 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY; 210 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY;
207 #endif 211 #endif
208 212
213 #if BUILDFLAG(ENABLE_PLUGINS)
214 constexpr char kPDFMimeType[] = "application/pdf";
215 #endif
216
209 } // namespace 217 } // namespace
210 218
211 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) 219 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
212 : profile_(profile), 220 : profile_(profile),
213 next_download_id_(content::DownloadItem::kInvalidId), 221 next_download_id_(content::DownloadItem::kInvalidId),
214 download_prefs_(new DownloadPrefs(profile)), 222 download_prefs_(new DownloadPrefs(profile)),
215 weak_ptr_factory_(this) { 223 weak_ptr_factory_(this) {
216 } 224 }
217 225
218 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 226 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 const content::DownloadIdCallback& callback) { 284 const content::DownloadIdCallback& callback) {
277 DCHECK_CURRENTLY_ON(BrowserThread::UI); 285 DCHECK_CURRENTLY_ON(BrowserThread::UI);
278 DCHECK(!profile_->IsOffTheRecord()); 286 DCHECK(!profile_->IsOffTheRecord());
279 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_); 287 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_);
280 callback.Run(next_download_id_++); 288 callback.Run(next_download_id_++);
281 } 289 }
282 290
283 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( 291 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget(
284 DownloadItem* download, 292 DownloadItem* download,
285 const content::DownloadTargetCallback& callback) { 293 const content::DownloadTargetCallback& callback) {
294 #if BUILDFLAG(ENABLE_PLUGINS)
295 if (download->GetTargetFilePath().empty() &&
296 download->GetMimeType() == kPDFMimeType && !download->HasUserGesture()) {
297 ReportPDFLoadStatus(PDFLoadStatus::TRIGGERED_NO_GESTURE_DRIVE_BY_DOWNLOAD);
298 }
299 #endif
300
286 DownloadTargetDeterminer::CompletionCallback target_determined_callback = 301 DownloadTargetDeterminer::CompletionCallback target_determined_callback =
287 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined, 302 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined,
288 weak_ptr_factory_.GetWeakPtr(), 303 weak_ptr_factory_.GetWeakPtr(),
289 download->GetId(), 304 download->GetId(),
290 callback); 305 callback);
291 DownloadTargetDeterminer::Start( 306 DownloadTargetDeterminer::Start(
292 download, 307 download,
293 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH), 308 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH),
294 kDefaultPlatformConflictAction, download_prefs_.get(), this, 309 kDefaultPlatformConflictAction, download_prefs_.get(), this,
295 target_determined_callback); 310 target_determined_callback);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || 877 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) ||
863 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || 878 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) ||
864 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || 879 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) ||
865 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || 880 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) ||
866 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { 881 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) {
867 return true; 882 return true;
868 } 883 }
869 #endif 884 #endif
870 return false; 885 return false;
871 } 886 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/BUILD.gn » ('j') | chrome/common/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698