diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 23:34:19 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 23:34:19 +0000 |
commit | 42f904b277f400def0fd5baf2dbd9c2080f9da99 (patch) | |
tree | ba8c1efbb8c5f3f8c17b29989f86ca111e4dce95 | |
parent | e173b790fec590fa52f4d7e0d307cb2ce4de2b87 (diff) | |
download | chromium_src-42f904b277f400def0fd5baf2dbd9c2080f9da99.zip chromium_src-42f904b277f400def0fd5baf2dbd9c2080f9da99.tar.gz chromium_src-42f904b277f400def0fd5baf2dbd9c2080f9da99.tar.bz2 |
Fix the title of a JavaScript dialog box.
Currently, the title of a JavaScript dialog box contains "Alert"
regardless of how it's made: whether by alert(), prompt(), or confirm().
"Alert" should be there only when the dialog box is created by alert().
Tested by: unittest, ui_tests, manually
BUG=2359
Original patch by yuzo@google.com at http://codereview.chromium.org/67099
Review URL: http://codereview.chromium.org/70002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13636 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 13 | ||||
-rw-r--r-- | chrome/browser/jsmessage_box_handler.cc | 14 |
2 files changed, 20 insertions, 7 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4c2cc64..b24edeb 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -1662,11 +1662,18 @@ each locale. --> </message> <!-- Javascript Dialog Box strings --> - <message name="IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE" desc="Title for Javascript alert, prompt, and confirm if there is no hostname to display"> + <message name="IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE" desc="Title for Javascript alert if there is no hostname to display"> Javascript Alert </message> - <message name="IDS_JAVASCRIPT_MESSAGEBOX_TITLE" desc="Title for Javascript alert, prompt, and confirm"> - Alert <ph name="SITE">$1<ex>http://www.google.com</ex></ph> + <message name="IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE" desc="Title for Javascript prompt and confirm if there is no hostname to display"> + Javascript + </message> + <message name="IDS_JAVASCRIPT_ALERT_TITLE" desc="Title for Javascript alert"> + Alert <ph name="SITE">$1<ex>http://www.google.com</ex> + </ph> + </message> + <message name="IDS_JAVASCRIPT_MESSAGEBOX_TITLE" desc="Title for Javascript prompt and confirm"> + <ph name="SITE">$1<ex>http://www.google.com</ex></ph> </message> <message name="IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION" desc="Optional UI shown on the message box, in the form of a checkbox, allowing the user to suppress additional message boxes from the page."> Prevent this page from creating additional dialogs. diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc index 1bf7b21..f4dc238 100644 --- a/chrome/browser/jsmessage_box_handler.cc +++ b/chrome/browser/jsmessage_box_handler.cc @@ -19,9 +19,13 @@ namespace { -std::wstring GetWindowTitle(WebContents* web_contents, const GURL& frame_url) { +std::wstring GetWindowTitle(WebContents* web_contents, const GURL& frame_url, + int dialog_flags) { + bool is_alert = (dialog_flags == MessageBox::kIsJavascriptAlert); if (!frame_url.has_host()) - return l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); + return l10n_util::GetString( + is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE + : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); // We really only want the scheme, hostname, and port. GURL::Replacements replacements; @@ -39,7 +43,9 @@ std::wstring GetWindowTitle(WebContents* web_contents, const GURL& frame_url) { // Force URL to have LTR directionality. if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) l10n_util::WrapStringWithLTRFormatting(&base_address); - return l10n_util::GetStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base_address); + return l10n_util::GetStringF( + is_alert ? IDS_JAVASCRIPT_ALERT_TITLE : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, + base_address); } } @@ -51,7 +57,7 @@ void RunJavascriptMessageBox(WebContents* web_contents, const std::wstring& default_prompt_text, bool display_suppress_checkbox, IPC::Message* reply_msg) { - std::wstring title = GetWindowTitle(web_contents, frame_url); + std::wstring title = GetWindowTitle(web_contents, frame_url, dialog_flags); #if defined(OS_WIN) || defined(OS_LINUX) AppModalDialogQueue::AddDialog(new AppModalDialog(web_contents, title, |