summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 01:15:50 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 01:15:50 +0000
commit9dcb5966fd4c0e611034702fa0a6d3358ea37355 (patch)
tree1457d65d0aff4b134267b699572d4a59912ce10a /chrome
parent13cdde22f51438848b28a58de3bb22996e7c6661 (diff)
downloadchromium_src-9dcb5966fd4c0e611034702fa0a6d3358ea37355.zip
chromium_src-9dcb5966fd4c0e611034702fa0a6d3358ea37355.tar.gz
chromium_src-9dcb5966fd4c0e611034702fa0a6d3358ea37355.tar.bz2
Download in progress dialog:
- Change hardcoded "Google Chrome" to product name. - Implement for GTK. BUG=21652 Review URL: http://codereview.chromium.org/212051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/browser/app_controller_mac.mm18
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc4
-rw-r--r--chrome/browser/gtk/download_in_progress_dialog_gtk.cc98
-rw-r--r--chrome/browser/gtk/download_in_progress_dialog_gtk.h27
-rw-r--r--chrome/browser/views/frame/browser_view.cc19
-rw-r--r--chrome/chrome.gyp2
7 files changed, 156 insertions, 20 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 7f70562..2ae2568 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -1780,16 +1780,16 @@ each locale. aa1 -->
<!-- Remove in-progress downloads confirmation dialog -->
<message name="IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING" desc="Title of the dialog asking for user confirmation to close the browser when one download is in-progress.">
- Do you want to exit Google Chrome with a download in progress?
+ Do you want to exit <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> with a download in progress?
</message>
<message name="IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING" desc="Title of the dialog asking for user confirmation to close the browser when multiple downloads are in-progress.">
- Do you want to exit Google Chrome with <ph name="DOWNLOAD_COUNT">$1<ex>3</ex></ph> downloads in progress?
+ Do you want to exit <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> with <ph name="DOWNLOAD_COUNT">$2<ex>3</ex></ph> downloads in progress?
</message>
<message name="IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION" desc="Explanation of the dialog asking for user confirmation to close the browser when one download is in-progress.">
- If you close Google Chrome now, this download will be canceled.
+ If you close <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> now, this download will be canceled.
</message>
<message name="IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION" desc="Explanation of the dialog asking for user confirmation to close the browser when multiple downloads are in-progress.">
- If you close Google Chrome now, these downloads will be canceled.
+ If you close <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> now, these downloads will be canceled.
</message>
<message name="IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL" desc="Button text for OKing to close the browser when a single download is in-progress.">
Close and cancel download
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 46e1696..d8885d0 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -37,6 +37,7 @@
#include "chrome/common/pref_service.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/common/temp_scaffolding_stubs.h"
+#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@interface AppController(PRIVATE)
@@ -351,15 +352,17 @@
NSString* waitTitle = nil;
NSString* exitTitle = nil;
+ std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME);
+
// Set the dialog text based on whether or not there are multiple downloads.
if (downloadCount == 1) {
// Dialog text: warning and explanation.
warningText =
- base::SysWideToNSString(l10n_util::GetString(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING));
+ base::SysWideToNSString(l10n_util::GetStringF(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, product_name));
explanationText =
- base::SysWideToNSString(l10n_util::GetString(
- IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION));
+ base::SysWideToNSString(l10n_util::GetStringF(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, product_name));
// Cancel download and exit button text.
exitTitle =
@@ -374,10 +377,11 @@
// Dialog text: warning and explanation.
warningText =
base::SysWideToNSString(l10n_util::GetStringF(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, downloadCount));
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, product_name,
+ IntToWString(downloadCount)));
explanationText =
- base::SysWideToNSString(l10n_util::GetString(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION));
+ base::SysWideToNSString(l10n_util::GetStringF(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name));
// Cancel downloads and exit button text.
exitTitle =
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 5d9486e..56f76c0 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -43,6 +43,7 @@
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h"
+#include "chrome/browser/gtk/download_in_progress_dialog_gtk.h"
#include "chrome/browser/gtk/download_shelf_gtk.h"
#include "chrome/browser/gtk/edit_search_engine_dialog.h"
#include "chrome/browser/gtk/extension_shelf_gtk.h"
@@ -1140,8 +1141,7 @@ void BrowserWindowGtk::ShowAppMenu() {
}
void BrowserWindowGtk::ConfirmBrowserCloseWithPendingDownloads() {
- NOTIMPLEMENTED();
- browser_->InProgressDownloadResponse(false);
+ new DownloadInProgressDialogGtk(browser());
}
void BrowserWindowGtk::Observe(NotificationType type,
diff --git a/chrome/browser/gtk/download_in_progress_dialog_gtk.cc b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc
new file mode 100644
index 0000000..31f947f
--- /dev/null
+++ b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc
@@ -0,0 +1,98 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/download_in_progress_dialog_gtk.h"
+
+#include <gtk/gtk.h>
+
+#include "app/l10n_util.h"
+#include "base/string16.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/gtk_util.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+
+DownloadInProgressDialogGtk::DownloadInProgressDialogGtk(Browser* browser)
+ : browser_(browser) {
+ int download_count = browser->profile()->GetDownloadManager()->
+ in_progress_count();
+
+ std::string warning_text;
+ std::string explanation_text;
+ std::string ok_button_text;
+ std::string cancel_button_text;
+ string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
+ if (download_count == 1) {
+ warning_text =
+ l10n_util::GetStringFUTF8(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING,
+ product_name);
+ explanation_text =
+ l10n_util::GetStringFUTF8(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION,
+ product_name);
+ ok_button_text = l10n_util::GetStringUTF8(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
+ cancel_button_text = l10n_util::GetStringUTF8(
+ IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
+ } else {
+ warning_text =
+ l10n_util::GetStringFUTF8(IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING,
+ product_name, IntToString16(download_count));
+ explanation_text =
+ l10n_util::GetStringFUTF8(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name);
+ ok_button_text = l10n_util::GetStringUTF8(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL);
+ cancel_button_text = l10n_util::GetStringUTF8(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
+ }
+
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ UTF16ToUTF8(product_name).c_str(),
+ browser_->window()->GetNativeHandle(),
+ static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ NULL);
+ gtk_util::AddButtonToDialog(dialog,
+ cancel_button_text.c_str(),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+ gtk_util::AddButtonToDialog(dialog,
+ ok_button_text.c_str(),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+
+ // There are two lines of text: the bold warning label and the text
+ // explanation label. Neither one wraps.
+ GtkWidget* warning_label = gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(warning_label),
+ (std::string("<b>") + warning_text + "</b>").c_str());
+ gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5);
+ gtk_container_add(GTK_CONTAINER(content_area), warning_label);
+
+ // Spacing line.
+ gtk_container_add(GTK_CONTAINER(content_area), gtk_label_new(NULL));
+
+ GtkWidget* explanation_label = gtk_label_new(explanation_text.c_str());
+ gtk_misc_set_alignment(GTK_MISC(explanation_label), 0.0, 0.5);
+ gtk_container_add(GTK_CONTAINER(content_area), explanation_label);
+
+ // Spacing line.
+ gtk_container_add(GTK_CONTAINER(content_area), gtk_label_new(NULL));
+
+ g_signal_connect(dialog, "response", G_CALLBACK(OnResponse), this);
+
+ gtk_widget_show_all(dialog);
+}
+
+void DownloadInProgressDialogGtk::OnResponse(
+ GtkWidget* widget,
+ int response,
+ DownloadInProgressDialogGtk* dialog) {
+ gtk_widget_destroy(widget);
+ dialog->browser_->InProgressDownloadResponse(response == GTK_RESPONSE_ACCEPT);
+ delete dialog;
+}
diff --git a/chrome/browser/gtk/download_in_progress_dialog_gtk.h b/chrome/browser/gtk/download_in_progress_dialog_gtk.h
new file mode 100644
index 0000000..268a5b0
--- /dev/null
+++ b/chrome/browser/gtk/download_in_progress_dialog_gtk.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GTK_DOWNLOAD_IN_PROGRESS_DIALOG_GTK_H_
+#define CHROME_BROWSER_GTK_DOWNLOAD_IN_PROGRESS_DIALOG_GTK_H_
+
+#include "base/basictypes.h"
+
+class Browser;
+
+typedef struct _GtkWidget GtkWidget;
+
+class DownloadInProgressDialogGtk {
+ public:
+ explicit DownloadInProgressDialogGtk(Browser* browser);
+
+ private:
+ static void OnResponse(GtkWidget* widget, int response,
+ DownloadInProgressDialogGtk* dialog);
+
+ Browser* browser_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadInProgressDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_DOWNLOAD_IN_PROGRESS_DIALOG_GTK_H_
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 78a091c..0832c8d 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -252,7 +252,8 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
public views::View {
public:
explicit DownloadInProgressConfirmDialogDelegate(Browser* browser)
- : browser_(browser) {
+ : browser_(browser),
+ product_name_(l10n_util::GetString(IDS_PRODUCT_NAME)) {
int download_count = browser->profile()->GetDownloadManager()->
in_progress_count();
@@ -260,9 +261,11 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
std::wstring explanation_text;
if (download_count == 1) {
warning_text =
- l10n_util::GetString(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING);
+ l10n_util::GetStringF(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING,
+ product_name_);
explanation_text =
- l10n_util::GetString(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION);
+ l10n_util::GetStringF(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION,
+ product_name_);
ok_button_text_ = l10n_util::GetString(
IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
cancel_button_text_ = l10n_util::GetString(
@@ -270,10 +273,10 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
} else {
warning_text =
l10n_util::GetStringF(IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING,
- download_count);
+ product_name_, IntToString16(download_count));
explanation_text =
- l10n_util::GetString(
- IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION);
+ l10n_util::GetStringF(
+ IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name_);
ok_button_text_ = l10n_util::GetString(
IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL);
cancel_button_text_ = l10n_util::GetString(
@@ -350,7 +353,7 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
}
virtual std::wstring GetWindowTitle() const {
- return l10n_util::GetString(IDS_PRODUCT_NAME);
+ return product_name_;
}
private:
@@ -361,6 +364,8 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate,
std::wstring ok_button_text_;
std::wstring cancel_button_text_;
+ std::wstring product_name_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadInProgressConfirmDialogDelegate);
};
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 6927110..026f425c 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1294,6 +1294,8 @@
'browser/gtk/custom_button.cc',
'browser/gtk/custom_button.h',
'browser/gtk/dialogs_gtk.cc',
+ 'browser/gtk/download_in_progress_dialog_gtk.cc',
+ 'browser/gtk/download_in_progress_dialog_gtk.h',
'browser/gtk/download_item_gtk.cc',
'browser/gtk/download_item_gtk.h',
'browser/gtk/download_request_dialog_delegate_gtk.cc',