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/views/download/download_in_progress_dialog_view.h" | 5 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/download/download_manager.h" | 9 #include "chrome/browser/download/download_manager.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
14 #include "grit/locale_settings.h" | 14 #include "grit/locale_settings.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 #include "views/border.h" | 18 #include "views/border.h" |
19 #include "views/controls/label.h" | 19 #include "views/controls/label.h" |
20 #include "views/layout/grid_layout.h" | 20 #include "views/layout/grid_layout.h" |
21 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
22 | 22 |
23 DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser) | 23 DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser) |
24 : browser_(browser), | 24 : browser_(browser), |
25 product_name_(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)) { | 25 product_name_(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)) { |
26 int download_count = browser->profile()->GetDownloadManager()-> | 26 int download_count; |
27 in_progress_count(); | 27 Browser::DownloadClosePreventionType type = |
| 28 browser_->OkToCloseWithInProgressDownloads(&download_count); |
| 29 |
| 30 // This dialog should have been created within the same thread invocation |
| 31 // as the original test that lead to us, so it should always not be ok |
| 32 // to close. |
| 33 DCHECK(type != DOWNLOAD_CLOSE_OK); |
| 34 |
| 35 // TODO(rdsmith): This dialog should be different depending on whether we're |
| 36 // closing the last incognito window of a profile or doing browser shutdown. |
| 37 // See http://crbug.com/88421. |
28 | 38 |
29 std::wstring warning_text; | 39 std::wstring warning_text; |
30 std::wstring explanation_text; | 40 std::wstring explanation_text; |
31 if (download_count == 1) { | 41 if (download_count == 1) { |
32 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( | 42 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
33 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, | 43 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, |
34 product_name_)); | 44 product_name_)); |
35 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( | 45 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
36 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, | 46 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, |
37 product_name_)); | 47 product_name_)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return true; | 132 return true; |
123 } | 133 } |
124 | 134 |
125 std::wstring DownloadInProgressDialogView::GetWindowTitle() const { | 135 std::wstring DownloadInProgressDialogView::GetWindowTitle() const { |
126 return UTF16ToWideHack(product_name_); | 136 return UTF16ToWideHack(product_name_); |
127 } | 137 } |
128 | 138 |
129 views::View* DownloadInProgressDialogView::GetContentsView() { | 139 views::View* DownloadInProgressDialogView::GetContentsView() { |
130 return this; | 140 return this; |
131 } | 141 } |
OLD | NEW |