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