| 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" |
| 6 |
| 5 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 6 #include "chrome/browser/download/download_danger_prompt.h" | |
| 7 #include "chrome/browser/download/download_stats.h" | 8 #include "chrome/browser/download/download_stats.h" |
| 8 #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" |
| 9 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
| 10 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 11 #include "components/constrained_window/constrained_window_views.h" | 12 #include "components/constrained_window/constrained_window_views.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/download_danger_type.h" | 15 #include "content/public/browser/download_danger_type.h" |
| 14 #include "content/public/browser/download_item.h" | 16 #include "content/public/browser/download_item.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/views/controls/button/label_button.h" | 19 #include "ui/views/controls/button/label_button.h" |
| 18 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/grid_layout.h" | 21 #include "ui/views/layout/grid_layout.h" |
| 20 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
| 21 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/window/dialog_client_view.h" | 24 #include "ui/views/window/dialog_client_view.h" |
| 23 #include "ui/views/window/dialog_delegate.h" | 25 #include "ui/views/window/dialog_delegate.h" |
| 26 #include "url/gurl.h" |
| 24 | 27 |
| 25 using extensions::ExperienceSamplingEvent; | 28 using extensions::ExperienceSamplingEvent; |
| 26 | 29 |
| 27 namespace { | 30 namespace { |
| 28 | 31 |
| 29 const int kMessageWidth = 320; | 32 const int kMessageWidth = 320; |
| 30 const int kParagraphPadding = 15; | 33 const int kParagraphPadding = 15; |
| 31 | 34 |
| 32 // Views-specific implementation of download danger prompt dialog. We use this | 35 // Views-specific implementation of download danger prompt dialog. We use this |
| 33 // class rather than a TabModalConfirmDialog so that we can use custom | 36 // class rather than a TabModalConfirmDialog so that we can use custom |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 NOTREACHED(); | 329 NOTREACHED(); |
| 327 return base::string16(); | 330 return base::string16(); |
| 328 } | 331 } |
| 329 | 332 |
| 330 void DownloadDangerPromptViews::RunDone(Action action) { | 333 void DownloadDangerPromptViews::RunDone(Action action) { |
| 331 // Invoking the callback can cause the download item state to change or cause | 334 // Invoking the callback can cause the download item state to change or cause |
| 332 // the window to close, and |callback| refers to a member variable. | 335 // the window to close, and |callback| refers to a member variable. |
| 333 OnDone done = done_; | 336 OnDone done = done_; |
| 334 done_.Reset(); | 337 done_.Reset(); |
| 335 if (download_ != NULL) { | 338 if (download_ != NULL) { |
| 339 if (!download_->GetURL().is_empty() && |
| 340 !download_->GetBrowserContext()->IsOffTheRecord()) { |
| 341 SendSafeBrowsingDownloadRecoveryReport( |
| 342 action == DownloadDangerPrompt::ACCEPT, download_->GetURL()); |
| 343 } |
| 336 download_->RemoveObserver(this); | 344 download_->RemoveObserver(this); |
| 337 download_ = NULL; | 345 download_ = NULL; |
| 338 } | 346 } |
| 339 if (!done.is_null()) | 347 if (!done.is_null()) |
| 340 done.Run(action); | 348 done.Run(action); |
| 341 } | 349 } |
| 342 | 350 |
| 343 } // namespace | 351 } // namespace |
| 344 | 352 |
| 345 DownloadDangerPrompt* DownloadDangerPrompt::Create( | 353 DownloadDangerPrompt* DownloadDangerPrompt::Create( |
| 346 content::DownloadItem* item, | 354 content::DownloadItem* item, |
| 347 content::WebContents* web_contents, | 355 content::WebContents* web_contents, |
| 348 bool show_context, | 356 bool show_context, |
| 349 const OnDone& done) { | 357 const OnDone& done) { |
| 350 DownloadDangerPromptViews* download_danger_prompt = | 358 DownloadDangerPromptViews* download_danger_prompt = |
| 351 new DownloadDangerPromptViews(item, show_context, done); | 359 new DownloadDangerPromptViews(item, show_context, done); |
| 352 constrained_window::ShowWebModalDialogViews(download_danger_prompt, | 360 constrained_window::ShowWebModalDialogViews(download_danger_prompt, |
| 353 web_contents); | 361 web_contents); |
| 354 return download_danger_prompt; | 362 return download_danger_prompt; |
| 355 } | 363 } |
| OLD | NEW |