| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "chrome/browser/download/download_stats.h" | 8 #include "chrome/browser/download/download_stats.h" |
| 9 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" | 9 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
| 10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 return base::string16(); | 324 return base::string16(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void DownloadDangerPromptViews::RunDone(Action action) { | 327 void DownloadDangerPromptViews::RunDone(Action action) { |
| 328 // Invoking the callback can cause the download item state to change or cause | 328 // Invoking the callback can cause the download item state to change or cause |
| 329 // the window to close, and |callback| refers to a member variable. | 329 // the window to close, and |callback| refers to a member variable. |
| 330 OnDone done = done_; | 330 OnDone done = done_; |
| 331 done_.Reset(); | 331 done_.Reset(); |
| 332 if (download_ != NULL) { | 332 if (download_ != NULL) { |
| 333 const bool accept = action == DownloadDangerPrompt::ACCEPT; | 333 const bool accept = action == DownloadDangerPrompt::ACCEPT; |
| 334 RecordDownloadDangerPrompt(accept, *download_); | 334 if (download_->IsDangerous() && !download_->IsDone()) { |
| 335 if (!download_->GetURL().is_empty() && | 335 RecordDownloadDangerPrompt(accept, *download_); |
| 336 !download_->GetBrowserContext()->IsOffTheRecord()) { | 336 if (!download_->GetURL().is_empty() && |
| 337 SendSafeBrowsingDownloadRecoveryReport(accept, *download_); | 337 !download_->GetBrowserContext()->IsOffTheRecord()) { |
| 338 SendSafeBrowsingDownloadRecoveryReport(accept, *download_); |
| 339 } |
| 338 } | 340 } |
| 339 download_->RemoveObserver(this); | 341 download_->RemoveObserver(this); |
| 340 download_ = NULL; | 342 download_ = NULL; |
| 341 } | 343 } |
| 342 if (!done.is_null()) | 344 if (!done.is_null()) |
| 343 done.Run(action); | 345 done.Run(action); |
| 344 } | 346 } |
| 345 | 347 |
| 346 } // namespace | 348 } // namespace |
| 347 | 349 |
| 348 DownloadDangerPrompt* DownloadDangerPrompt::Create( | 350 DownloadDangerPrompt* DownloadDangerPrompt::Create( |
| 349 content::DownloadItem* item, | 351 content::DownloadItem* item, |
| 350 content::WebContents* web_contents, | 352 content::WebContents* web_contents, |
| 351 bool show_context, | 353 bool show_context, |
| 352 const OnDone& done) { | 354 const OnDone& done) { |
| 353 DownloadDangerPromptViews* download_danger_prompt = | 355 DownloadDangerPromptViews* download_danger_prompt = |
| 354 new DownloadDangerPromptViews(item, show_context, done); | 356 new DownloadDangerPromptViews(item, show_context, done); |
| 355 constrained_window::ShowWebModalDialogViews(download_danger_prompt, | 357 constrained_window::ShowWebModalDialogViews(download_danger_prompt, |
| 356 web_contents); | 358 web_contents); |
| 357 return download_danger_prompt; | 359 return download_danger_prompt; |
| 358 } | 360 } |
| OLD | NEW |