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 Browser::DownloadClosePreventionType type; |
27 in_progress_count(); | 27 int download_count; |
| 28 bool result = browser_->OkToCloseWithInProgressDownloads( |
| 29 &type, &download_count); |
| 30 |
| 31 // This dialog should have been created within the same thread invocation |
| 32 // as the original test that lead to us, so it should always not be ok |
| 33 // to close. |
| 34 DCHECK(!result); |
| 35 |
| 36 // TODO(rdsmith): This dialog should be different depending on whether we're |
| 37 // closing the last incognito window of a profile or doing browser shutdown. |
| 38 // See http://crbug.com/88421. |
28 | 39 |
29 std::wstring warning_text; | 40 std::wstring warning_text; |
30 std::wstring explanation_text; | 41 std::wstring explanation_text; |
31 if (download_count == 1) { | 42 if (download_count == 1) { |
32 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( | 43 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
33 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, | 44 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, |
34 product_name_)); | 45 product_name_)); |
35 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( | 46 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
36 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, | 47 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, |
37 product_name_)); | 48 product_name_)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return true; | 133 return true; |
123 } | 134 } |
124 | 135 |
125 std::wstring DownloadInProgressDialogView::GetWindowTitle() const { | 136 std::wstring DownloadInProgressDialogView::GetWindowTitle() const { |
126 return UTF16ToWideHack(product_name_); | 137 return UTF16ToWideHack(product_name_); |
127 } | 138 } |
128 | 139 |
129 views::View* DownloadInProgressDialogView::GetContentsView() { | 140 views::View* DownloadInProgressDialogView::GetContentsView() { |
130 return this; | 141 return this; |
131 } | 142 } |
OLD | NEW |