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

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
« no previous file with comments | « no previous file | chrome/common/BUILD.gn » ('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/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 24 matching lines...) Expand all
35 #include "chrome/browser/download/save_package_file_picker.h" 35 #include "chrome/browser/download/save_package_file_picker.h"
36 #include "chrome/browser/platform_util.h" 36 #include "chrome/browser/platform_util.h"
37 #include "chrome/browser/profiles/profile.h" 37 #include "chrome/browser/profiles/profile.h"
38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_finder.h" 40 #include "chrome/browser/ui/browser_finder.h"
41 #include "chrome/browser/ui/chrome_pages.h" 41 #include "chrome/browser/ui/chrome_pages.h"
42 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 42 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
43 #include "chrome/common/chrome_constants.h" 43 #include "chrome/common/chrome_constants.h"
44 #include "chrome/common/features.h" 44 #include "chrome/common/features.h"
45 #include "chrome/common/pdf_uma.h"
45 #include "chrome/common/pref_names.h" 46 #include "chrome/common/pref_names.h"
46 #include "chrome/common/safe_browsing/file_type_policies.h" 47 #include "chrome/common/safe_browsing/file_type_policies.h"
47 #include "chrome/grit/generated_resources.h" 48 #include "chrome/grit/generated_resources.h"
48 #include "components/pref_registry/pref_registry_syncable.h" 49 #include "components/pref_registry/pref_registry_syncable.h"
49 #include "components/prefs/pref_member.h" 50 #include "components/prefs/pref_member.h"
50 #include "components/prefs/pref_service.h" 51 #include "components/prefs/pref_service.h"
51 #include "content/public/browser/download_item.h" 52 #include "content/public/browser/download_item.h"
52 #include "content/public/browser/download_manager.h" 53 #include "content/public/browser/download_manager.h"
53 #include "content/public/browser/notification_source.h" 54 #include "content/public/browser/notification_source.h"
54 #include "content/public/browser/page_navigator.h" 55 #include "content/public/browser/page_navigator.h"
(...skipping 144 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698