summaryrefslogtreecommitdiffstats
path: root/chrome/browser/message_box_handler.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-05 19:06:52 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-05 19:06:52 +0000
commitd6ad744a51007d532f49081e3ba7936f31e337a3 (patch)
treeb51da34230f19eeed4c154f51ce8c2478fbfcc2c /chrome/browser/message_box_handler.cc
parentf1b873f51bda1b262f00bc0fc98814c28cb2250c (diff)
downloadchromium_src-d6ad744a51007d532f49081e3ba7936f31e337a3.zip
chromium_src-d6ad744a51007d532f49081e3ba7936f31e337a3.tar.gz
chromium_src-d6ad744a51007d532f49081e3ba7936f31e337a3.tar.bz2
Don't show "The page at..." in the Bookmark Manager confirmation dialog.
BUG=52729 TEST=have more than 15 bookmarks in bookmark manager, try to open or delete them all at once, a confirmation dialog will be shown, notice that the "The page at..." is not more visible. Review URL: http://codereview.chromium.org/3195013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/message_box_handler.cc')
-rw-r--r--chrome/browser/message_box_handler.cc59
1 files changed, 55 insertions, 4 deletions
diff --git a/chrome/browser/message_box_handler.cc b/chrome/browser/message_box_handler.cc
index 1350c5c..be21323 100644
--- a/chrome/browser/message_box_handler.cc
+++ b/chrome/browser/message_box_handler.cc
@@ -6,26 +6,77 @@
#include "app/l10n_util.h"
#include "app/message_box_flags.h"
+#include "app/text_elider.h"
+#include "base/i18n/rtl.h"
+#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/app_modal_dialog_queue.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/cookie_modal_dialog.h"
#include "chrome/browser/cookie_prompt_modal_dialog_delegate.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/js_modal_dialog.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
+#include "gfx/font.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
+#include "grit/chromium_strings.h"
+
+static std::wstring GetTitle(Profile* profile,
+ ExtensionsService* extensions_service,
+ bool is_alert,
+ const GURL& frame_url) {
+ Extension* extension = extensions_service->GetExtensionByURL(frame_url);
+ if (!extension)
+ extension = extensions_service->GetExtensionByWebExtent(frame_url);
+
+ if (extension && (extension->location() == Extension::COMPONENT)) {
+ return l10n_util::GetString(IDS_PRODUCT_NAME);
+ } else if (extension && !extension->name().empty()) {
+ return UTF8ToWide(extension->name());
+ } else {
+ if (!frame_url.has_host())
+ return l10n_util::GetString(
+ is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE
+ : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE);
+
+ // TODO(brettw) it should be easier than this to do the correct language
+ // handling without getting the accept language from the profile.
+ string16 base_address = WideToUTF16(gfx::ElideUrl(frame_url.GetOrigin(),
+ gfx::Font(), 0,
+ UTF8ToWide(
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages))));
-void RunJavascriptMessageBox(JavaScriptMessageBoxClient* client,
+ // Force URL to have LTR directionality.
+ base_address = base::i18n::GetDisplayStringInLTRDirectionality(
+ base_address);
+
+ return UTF16ToWide(l10n_util::GetStringFUTF16(
+ is_alert ? IDS_JAVASCRIPT_ALERT_TITLE :
+ IDS_JAVASCRIPT_MESSAGEBOX_TITLE,
+ base_address));
+ }
+}
+
+void RunJavascriptMessageBox(Profile* profile,
+ JavaScriptMessageBoxClient* client,
const GURL& frame_url,
int dialog_flags,
const std::wstring& message_text,
const std::wstring& default_prompt_text,
bool display_suppress_checkbox,
IPC::Message* reply_msg) {
- std::wstring title = client->GetMessageBoxTitle(frame_url,
- (dialog_flags == MessageBoxFlags::kIsJavascriptAlert));
+ ExtensionsService* extensions_service = profile->GetExtensionsService();
+ if (!extensions_service)
+ return;
+
+ bool is_alert = dialog_flags == MessageBoxFlags::kIsJavascriptAlert;
+ std::wstring title = GetTitle(profile, extensions_service,
+ is_alert, frame_url);
Singleton<AppModalDialogQueue>()->AddDialog(new JavaScriptAppModalDialog(
client, title, dialog_flags, message_text, default_prompt_text,
display_suppress_checkbox, false, reply_msg));