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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_danger_prompt_impl.cc

Issue 2029903002: Add token field to ClientSafeBrowsingReportReqeust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak comments Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_danger_prompt.h" 5 #include "chrome/browser/download/download_danger_prompt.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/download/download_stats.h" 9 #include "chrome/browser/download/download_stats.h"
10 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 10 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
11 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 11 #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
12 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 12 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
13 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/download_danger_type.h" 16 #include "content/public/browser/download_danger_type.h"
17 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
18 #include "grit/components_strings.h" 18 #include "grit/components_strings.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 using extensions::ExperienceSamplingEvent; 22 using extensions::ExperienceSamplingEvent;
23 using safe_browsing::ClientSafeBrowsingReportRequest;
23 24
24 namespace { 25 namespace {
25 26
26 // TODO(wittman): Create a native web contents modal dialog implementation of 27 // TODO(wittman): Create a native web contents modal dialog implementation of
27 // this dialog for non-Views platforms, to support bold formatting of the 28 // this dialog for non-Views platforms, to support bold formatting of the
28 // message lead. 29 // message lead.
29 30
30 // Implements DownloadDangerPrompt using a TabModalConfirmDialog. 31 // Implements DownloadDangerPrompt using a TabModalConfirmDialog.
31 class DownloadDangerPromptImpl : public DownloadDangerPrompt, 32 class DownloadDangerPromptImpl : public DownloadDangerPrompt,
32 public content::DownloadItem::Observer, 33 public content::DownloadItem::Observer,
(...skipping 17 matching lines...) Expand all
50 base::string16 GetDialogMessage() override; 51 base::string16 GetDialogMessage() override;
51 base::string16 GetAcceptButtonTitle() override; 52 base::string16 GetAcceptButtonTitle() override;
52 base::string16 GetCancelButtonTitle() override; 53 base::string16 GetCancelButtonTitle() override;
53 void OnAccepted() override; 54 void OnAccepted() override;
54 void OnCanceled() override; 55 void OnCanceled() override;
55 void OnClosed() override; 56 void OnClosed() override;
56 57
57 void RunDone(Action action); 58 void RunDone(Action action);
58 59
59 content::DownloadItem* download_; 60 content::DownloadItem* download_;
61 // show_context_ is true, this is a comfirming download dialog (through
62 // download API), otherwise it is download recovery dialog from a regular
63 // download.
60 bool show_context_; 64 bool show_context_;
61 OnDone done_; 65 OnDone done_;
62 66
63 std::unique_ptr<ExperienceSamplingEvent> sampling_event_; 67 std::unique_ptr<ExperienceSamplingEvent> sampling_event_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl); 69 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl);
66 }; 70 };
67 71
68 DownloadDangerPromptImpl::DownloadDangerPromptImpl( 72 DownloadDangerPromptImpl::DownloadDangerPromptImpl(
69 content::DownloadItem* download, 73 content::DownloadItem* download,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 OnDone done = done_; 247 OnDone done = done_;
244 done_.Reset(); 248 done_.Reset();
245 if (download_ != NULL) { 249 if (download_ != NULL) {
246 // If this download is no longer dangerous, or is already canceled or 250 // If this download is no longer dangerous, or is already canceled or
247 // completed, don't send any report. 251 // completed, don't send any report.
248 if (download_->IsDangerous() && !download_->IsDone()) { 252 if (download_->IsDangerous() && !download_->IsDone()) {
249 const bool accept = action == DownloadDangerPrompt::ACCEPT; 253 const bool accept = action == DownloadDangerPrompt::ACCEPT;
250 RecordDownloadDangerPrompt(accept, *download_); 254 RecordDownloadDangerPrompt(accept, *download_);
251 if (!download_->GetURL().is_empty() && 255 if (!download_->GetURL().is_empty() &&
252 !download_->GetBrowserContext()->IsOffTheRecord()) { 256 !download_->GetBrowserContext()->IsOffTheRecord()) {
253 SendSafeBrowsingDownloadRecoveryReport(accept, *download_); 257 ClientSafeBrowsingReportRequest::ReportType report_type
258 = show_context_ ?
259 ClientSafeBrowsingReportRequest::DANGEROUS_DOWNLOAD_BY_API :
260 ClientSafeBrowsingReportRequest::DANGEROUS_DOWNLOAD_RECOVERY;
261 SendSafeBrowsingDownloadReport(report_type, accept, *download_);
254 } 262 }
255 } 263 }
256 download_->RemoveObserver(this); 264 download_->RemoveObserver(this);
257 download_ = NULL; 265 download_ = NULL;
258 } 266 }
259 if (!done.is_null()) 267 if (!done.is_null())
260 done.Run(action); 268 done.Run(action);
261 } 269 }
262 270
263 } // namespace 271 } // namespace
264 272
265 // static 273 // static
266 DownloadDangerPrompt* DownloadDangerPrompt::Create( 274 DownloadDangerPrompt* DownloadDangerPrompt::Create(
267 content::DownloadItem* item, 275 content::DownloadItem* item,
268 content::WebContents* web_contents, 276 content::WebContents* web_contents,
269 bool show_context, 277 bool show_context,
270 const OnDone& done) { 278 const OnDone& done) {
271 DownloadDangerPromptImpl* prompt = 279 DownloadDangerPromptImpl* prompt =
272 new DownloadDangerPromptImpl(item, web_contents, show_context, done); 280 new DownloadDangerPromptImpl(item, web_contents, show_context, done);
273 // |prompt| will be deleted when the dialog is done. 281 // |prompt| will be deleted when the dialog is done.
274 TabModalConfirmDialog::Create(prompt, web_contents); 282 TabModalConfirmDialog::Create(prompt, web_contents);
275 return prompt; 283 return prompt;
276 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698