OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/download/download_in_progress_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_in_progress_dialog_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "chrome/browser/download/download_manager.h" | 11 #include "chrome/browser/download/download_manager.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/gtk/gtk_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_util.h" |
16 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 | 19 |
20 DownloadInProgressDialogGtk::DownloadInProgressDialogGtk(Browser* browser) | 20 DownloadInProgressDialogGtk::DownloadInProgressDialogGtk(Browser* browser) |
21 : browser_(browser) { | 21 : browser_(browser) { |
22 int download_count = browser->profile()->GetDownloadManager()-> | 22 Browser::DownloadClosePreventionType type; |
23 in_progress_count(); | 23 int download_count; |
| 24 bool result = browser_->OkToCloseWithInProgressDownloads( |
| 25 &type, &download_count); |
| 26 |
| 27 // This dialog should have been created within the same thread invocation |
| 28 // as the original test that lead to us, so it should always not be ok |
| 29 // to close. |
| 30 DCHECK(!result); |
| 31 |
| 32 // TODO(rdsmith): This dialog should be different depending on whether we're |
| 33 // closing the last incognito window of a profile or doing browser shutdown. |
| 34 // See http://crbug.com/88421. |
24 | 35 |
25 std::string warning_text; | 36 std::string warning_text; |
26 std::string explanation_text; | 37 std::string explanation_text; |
27 std::string ok_button_text; | 38 std::string ok_button_text; |
28 std::string cancel_button_text; | 39 std::string cancel_button_text; |
29 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 40 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
30 if (download_count == 1) { | 41 if (download_count == 1) { |
31 warning_text = | 42 warning_text = |
32 l10n_util::GetStringFUTF8(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, | 43 l10n_util::GetStringFUTF8(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, |
33 product_name); | 44 product_name); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 86 |
76 gtk_widget_show_all(dialog); | 87 gtk_widget_show_all(dialog); |
77 } | 88 } |
78 | 89 |
79 void DownloadInProgressDialogGtk::OnResponse(GtkWidget* dialog, | 90 void DownloadInProgressDialogGtk::OnResponse(GtkWidget* dialog, |
80 int response_id) { | 91 int response_id) { |
81 gtk_widget_destroy(dialog); | 92 gtk_widget_destroy(dialog); |
82 browser_->InProgressDownloadResponse(response_id == GTK_RESPONSE_ACCEPT); | 93 browser_->InProgressDownloadResponse(response_id == GTK_RESPONSE_ACCEPT); |
83 delete this; | 94 delete this; |
84 } | 95 } |
OLD | NEW |