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