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

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

Issue 1784433003: Track CTR of uncommon download warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_commands.h" 5 #include "chrome/browser/download/download_commands.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/download/download_crx_util.h" 16 #include "chrome/browser/download/download_crx_util.h"
17 #include "chrome/browser/download/download_extensions.h" 17 #include "chrome/browser/download/download_extensions.h"
18 #include "chrome/browser/download/download_item_model.h" 18 #include "chrome/browser/download/download_item_model.h"
19 #include "chrome/browser/download/download_prefs.h" 19 #include "chrome/browser/download/download_prefs.h"
20 #include "chrome/browser/image_decoder.h" 20 #include "chrome/browser/image_decoder.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/safe_browsing/download_protection_service.h" 22 #include "chrome/browser/safe_browsing/download_protection_service.h"
23 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 23 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
24 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
26 #include "chrome/common/safe_browsing/csd.pb.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "components/google/core/browser/google_util.h" 29 #include "components/google/core/browser/google_util.h"
29 #include "components/mime_util/mime_util.h" 30 #include "components/mime_util/mime_util.h"
30 #include "grit/theme_resources.h" 31 #include "grit/theme_resources.h"
31 #include "net/base/url_util.h" 32 #include "net/base/url_util.h"
32 #include "ui/base/clipboard/scoped_clipboard_writer.h" 33 #include "ui/base/clipboard/scoped_clipboard_writer.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 36
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 case PLATFORM_OPEN: 272 case PLATFORM_OPEN:
272 DownloadItemModel(download_item_).OpenUsingPlatformHandler(); 273 DownloadItemModel(download_item_).OpenUsingPlatformHandler();
273 break; 274 break;
274 case CANCEL: 275 case CANCEL:
275 download_item_->Cancel(true /* Cancelled by user */); 276 download_item_->Cancel(true /* Cancelled by user */);
276 break; 277 break;
277 case DISCARD: 278 case DISCARD:
278 download_item_->Remove(); 279 download_item_->Remove();
279 break; 280 break;
280 case KEEP: 281 case KEEP:
282 // Only sends uncommon download accept report if :
283 // 1. FULL_SAFE_BROWSING is enabled, and
284 // 2. Download verdict is uncommon, and
285 // 3. Download URL is not empty, and
286 // 4. User is not in incognito mode.
287 #if defined(FULL_SAFE_BROWSING)
288 if (download_item_->GetDangerType() ==
289 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT &&
Nathan Parker 2016/03/17 17:33:12 Remind me why this is just for uncommon downloads,
Nathan Parker 2016/03/17 17:34:39 Nevermind, just figured it out (only uncommon has
Jialiu Lin 2016/03/17 20:14:44 Yes, only uncommon has keep button.
290 !download_item_->GetURL().is_empty() &&
291 !download_item_->GetBrowserContext()->IsOffTheRecord()) {
292 safe_browsing::SafeBrowsingService* sb_service =
293 g_browser_process->safe_browsing_service();
294 // Compiles the uncommon download warning report.
295 safe_browsing::ClientSafeBrowsingReportRequest report;
296 report.set_type(safe_browsing::ClientSafeBrowsingReportRequest::
297 DANGEROUS_DOWNLOAD_WARNING);
298 report.set_download_verdict(
299 safe_browsing::ClientDownloadResponse::UNCOMMON);
300 report.set_url(download_item_->GetURL().spec());
301 report.set_did_proceed(true);
302 std::string serialized_report;
303 if (report.SerializeToString(&serialized_report))
304 sb_service->SendSerializedDownloadReport(serialized_report);
305 else
306 DLOG(ERROR)
Nathan Parker 2016/03/17 17:33:12 nit: if/else code > 1 line should have {}'s You c
Jialiu Lin 2016/03/17 20:14:44 Done
307 << "Unable to serialize the uncommon download warning report.";
308 }
309 #endif
281 download_item_->ValidateDangerousDownload(); 310 download_item_->ValidateDangerousDownload();
282 break; 311 break;
283 case LEARN_MORE_SCANNING: { 312 case LEARN_MORE_SCANNING: {
284 #if defined(FULL_SAFE_BROWSING) 313 #if defined(FULL_SAFE_BROWSING)
285 using safe_browsing::DownloadProtectionService; 314 using safe_browsing::DownloadProtectionService;
286 315
287 safe_browsing::SafeBrowsingService* sb_service = 316 safe_browsing::SafeBrowsingService* sb_service =
288 g_browser_process->safe_browsing_service(); 317 g_browser_process->safe_browsing_service();
289 DownloadProtectionService* protection_service = 318 DownloadProtectionService* protection_service =
290 (sb_service ? sb_service->download_protection_service() : nullptr); 319 (sb_service ? sb_service->download_protection_service() : nullptr);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 &mime) || 390 &mime) ||
362 !mime_util::IsSupportedImageMimeType(mime)) { 391 !mime_util::IsSupportedImageMimeType(mime)) {
363 // It seems a non-image file. 392 // It seems a non-image file.
364 return; 393 return;
365 } 394 }
366 } 395 }
367 396
368 base::FilePath file_path = download_item_->GetFullPath(); 397 base::FilePath file_path = download_item_->GetFullPath();
369 ImageClipboardCopyManager::Start(file_path); 398 ImageClipboardCopyManager::Start(file_path);
370 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698