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

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: fix 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
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/rand_util.h" 16 #include "base/rand_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/task_runner.h" 18 #include "base/task_runner.h"
19 #include "base/task_scheduler/post_task.h" 19 #include "base/task_scheduler/post_task.h"
20 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/common/pdf_uma.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/download/download_completion_blocker.h" 25 #include "chrome/browser/download/download_completion_blocker.h"
25 #include "chrome/browser/download/download_core_service.h" 26 #include "chrome/browser/download/download_core_service.h"
26 #include "chrome/browser/download/download_core_service_factory.h" 27 #include "chrome/browser/download/download_core_service_factory.h"
27 #include "chrome/browser/download/download_crx_util.h" 28 #include "chrome/browser/download/download_crx_util.h"
28 #include "chrome/browser/download/download_file_picker.h" 29 #include "chrome/browser/download/download_file_picker.h"
29 #include "chrome/browser/download/download_history.h" 30 #include "chrome/browser/download/download_history.h"
30 #include "chrome/browser/download/download_item_model.h" 31 #include "chrome/browser/download/download_item_model.h"
31 #include "chrome/browser/download/download_path_reservation_tracker.h" 32 #include "chrome/browser/download/download_path_reservation_tracker.h"
32 #include "chrome/browser/download/download_prefs.h" 33 #include "chrome/browser/download/download_prefs.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // On Android, Chrome wants to warn the user of file overwrites rather than 200 // On Android, Chrome wants to warn the user of file overwrites rather than
200 // uniquify. 201 // uniquify.
201 #if defined(OS_ANDROID) 202 #if defined(OS_ANDROID)
202 const DownloadPathReservationTracker::FilenameConflictAction 203 const DownloadPathReservationTracker::FilenameConflictAction
203 kDefaultPlatformConflictAction = DownloadPathReservationTracker::PROMPT; 204 kDefaultPlatformConflictAction = DownloadPathReservationTracker::PROMPT;
204 #else 205 #else
205 const DownloadPathReservationTracker::FilenameConflictAction 206 const DownloadPathReservationTracker::FilenameConflictAction
206 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY; 207 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY;
207 #endif 208 #endif
208 209
210 constexpr char kPDFMimeType[] = "application/pdf";
211
209 } // namespace 212 } // namespace
210 213
211 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) 214 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
212 : profile_(profile), 215 : profile_(profile),
213 next_download_id_(content::DownloadItem::kInvalidId), 216 next_download_id_(content::DownloadItem::kInvalidId),
214 download_prefs_(new DownloadPrefs(profile)), 217 download_prefs_(new DownloadPrefs(profile)),
215 weak_ptr_factory_(this) { 218 weak_ptr_factory_(this) {
216 } 219 }
217 220
218 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 221 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 const content::DownloadIdCallback& callback) { 279 const content::DownloadIdCallback& callback) {
277 DCHECK_CURRENTLY_ON(BrowserThread::UI); 280 DCHECK_CURRENTLY_ON(BrowserThread::UI);
278 DCHECK(!profile_->IsOffTheRecord()); 281 DCHECK(!profile_->IsOffTheRecord());
279 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_); 282 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_);
280 callback.Run(next_download_id_++); 283 callback.Run(next_download_id_++);
281 } 284 }
282 285
283 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( 286 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget(
284 DownloadItem* download, 287 DownloadItem* download,
285 const content::DownloadTargetCallback& callback) { 288 const content::DownloadTargetCallback& callback) {
289 if (download->GetTargetFilePath().empty() &&
290 download->GetMimeType() == kPDFMimeType && !download->HasUserGesture()) {
291 ReportPDFLoadStatus(PDFLoadStatus::kTriggeredNoGestureDriveByDownload);
292 }
293
286 DownloadTargetDeterminer::CompletionCallback target_determined_callback = 294 DownloadTargetDeterminer::CompletionCallback target_determined_callback =
287 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined, 295 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined,
288 weak_ptr_factory_.GetWeakPtr(), 296 weak_ptr_factory_.GetWeakPtr(),
289 download->GetId(), 297 download->GetId(),
290 callback); 298 callback);
291 DownloadTargetDeterminer::Start( 299 DownloadTargetDeterminer::Start(
292 download, 300 download,
293 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH), 301 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH),
294 kDefaultPlatformConflictAction, download_prefs_.get(), this, 302 kDefaultPlatformConflictAction, download_prefs_.get(), this,
295 target_determined_callback); 303 target_determined_callback);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || 870 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) ||
863 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || 871 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) ||
864 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || 872 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) ||
865 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || 873 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) ||
866 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { 874 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) {
867 return true; 875 return true;
868 } 876 }
869 #endif 877 #endif
870 return false; 878 return false;
871 } 879 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/BUILD.gn » ('j') | chrome/renderer/chrome_content_renderer_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698