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