Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: chrome/browser/ui/views/download/download_in_progress_dialog_view.cc

Issue 9969193: Change the "close Chrome with downloads in progress" dialog to resemble kenmoore's mock (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/download/download_in_progress_dialog_view.cc
diff --git a/chrome/browser/ui/views/download/download_in_progress_dialog_view.cc b/chrome/browser/ui/views/download/download_in_progress_dialog_view.cc
index 91ad0f589cb631bf617596f54fab628ea95b926b..2812bea34d5ce5de0577cd747ffcdcef714e1918 100644
--- a/chrome/browser/ui/views/download/download_in_progress_dialog_view.cc
+++ b/chrome/browser/ui/views/download/download_in_progress_dialog_view.cc
@@ -15,7 +15,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/size.h"
#include "ui/views/border.h"
-#include "ui/views/controls/label.h"
+#include "ui/views/controls/message_box_view.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
@@ -29,8 +29,7 @@ void DownloadInProgressDialogView::Show(Browser* browser,
DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser)
: browser_(browser),
- warning_(NULL),
- explanation_(NULL) {
+ message_box_view_(NULL) {
int download_count;
Browser::DownloadClosePreventionType type =
browser_->OkToCloseWithInProgressDownloads(&download_count);
@@ -40,73 +39,47 @@ DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser)
// to close.
DCHECK_NE(Browser::DOWNLOAD_CLOSE_OK, type);
- // TODO(rdsmith): This dialog should be different depending on whether we're
- // closing the last incognito window of a profile or doing browser shutdown.
- // See http://crbug.com/88421.
-
- string16 warning_text;
string16 explanation_text;
- if (download_count == 1) {
- warning_text = l10n_util::GetStringUTF16(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING);
- explanation_text = l10n_util::GetStringUTF16(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION);
+ if (type == Browser::DOWNLOAD_CLOSE_BROWSER_SHUTDOWN) {
James Cook 2012/04/17 19:03:21 Maybe a switch statement on the type with a NOTREA
benrg 2012/04/17 20:39:14 Done.
+ if (download_count == 1) {
+ title_text_ = l10n_util::GetStringUTF16(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_TITLE);
+ explanation_text = l10n_util::GetStringUTF16(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION);
+ } else {
+ title_text_ = l10n_util::GetStringUTF16(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_TITLE);
+ explanation_text = l10n_util::GetStringUTF16(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION);
+ }
ok_button_text_ = l10n_util::GetStringUTF16(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
- cancel_button_text_ = l10n_util::GetStringUTF16(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
- } else {
- warning_text = l10n_util::GetStringFUTF16(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING,
- base::IntToString16(download_count));
- explanation_text = l10n_util::GetStringUTF16(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION);
+ IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
+ } else { // DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE
+ if (download_count == 1) {
+ title_text_ = l10n_util::GetStringUTF16(
+ IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_TITLE);
+ explanation_text = l10n_util::GetStringUTF16(
+ IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION);
+ } else {
+ title_text_ = l10n_util::GetStringUTF16(
+ IDS_MULTIPLE_INCOGNITO_DOWNLOADS_REMOVE_CONFIRM_TITLE);
+ explanation_text = l10n_util::GetStringUTF16(
+ IDS_MULTIPLE_INCOGNITO_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION);
+ }
ok_button_text_ = l10n_util::GetStringUTF16(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL);
- cancel_button_text_ = l10n_util::GetStringUTF16(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
+ IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
}
+ cancel_button_text_ = l10n_util::GetStringUTF16(
+ IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
- // There are two lines of text: the bold warning label and the text
- // explanation label.
- views::GridLayout* layout = new views::GridLayout(this);
- SetLayoutManager(layout);
- const int columnset_id = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(columnset_id);
- column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::LEADING, 1,
- views::GridLayout::USE_PREF, 0, 0);
-
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::Font bold_font = rb.GetFont(
- ui::ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
- warning_ = new views::Label(warning_text, bold_font);
- warning_->SetMultiLine(true);
- warning_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- warning_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10));
- layout->StartRow(0, columnset_id);
- layout->AddView(warning_);
-
- explanation_ = new views::Label(explanation_text);
- explanation_->SetMultiLine(true);
- explanation_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- explanation_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10));
- layout->StartRow(0, columnset_id);
- layout->AddView(explanation_);
-
- dialog_dimensions_ = views::Widget::GetLocalizedContentsSize(
- IDS_DOWNLOAD_IN_PROGRESS_WIDTH_CHARS,
- IDS_DOWNLOAD_IN_PROGRESS_MINIMUM_HEIGHT_LINES);
- const int height =
- warning_->GetHeightForWidth(dialog_dimensions_.width()) +
- explanation_->GetHeightForWidth(dialog_dimensions_.width());
- dialog_dimensions_.set_height(std::max(height,
- dialog_dimensions_.height()));
+ message_box_view_ = new views::MessageBoxView(
+ views::MessageBoxView::NO_OPTIONS, explanation_text, string16());
}
DownloadInProgressDialogView::~DownloadInProgressDialogView() {}
-gfx::Size DownloadInProgressDialogView::GetPreferredSize() {
- return dialog_dimensions_;
+int DownloadInProgressDialogView::GetDefaultDialogButton() const {
+ return ui::DIALOG_BUTTON_CANCEL;
}
string16 DownloadInProgressDialogView::GetDialogButtonLabel(
@@ -115,10 +88,6 @@ string16 DownloadInProgressDialogView::GetDialogButtonLabel(
ok_button_text_ : cancel_button_text_;
}
-int DownloadInProgressDialogView::GetDefaultDialogButton() const {
- return ui::DIALOG_BUTTON_CANCEL;
-}
-
bool DownloadInProgressDialogView::Cancel() {
browser_->InProgressDownloadResponse(false);
return true;
@@ -134,9 +103,21 @@ ui::ModalType DownloadInProgressDialogView::GetModalType() const {
}
string16 DownloadInProgressDialogView::GetWindowTitle() const {
- return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
+ return title_text_;
+}
+
+void DownloadInProgressDialogView::DeleteDelegate() {
+ delete this;
+}
+
+views::Widget* DownloadInProgressDialogView::GetWidget() {
+ return message_box_view_->GetWidget();
+}
+
+const views::Widget* DownloadInProgressDialogView::GetWidget() const {
+ return message_box_view_->GetWidget();
}
views::View* DownloadInProgressDialogView::GetContentsView() {
- return this;
+ return message_box_view_;
}

Powered by Google App Engine
This is Rietveld 408576698