diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 22:20:59 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 22:20:59 +0000 |
commit | 43f67a00aa82e1aa28169149c4d63169e3d3a13a (patch) | |
tree | 8353978645875986b3cf0f3cfea81e0b869bd3c6 | |
parent | 9fd1e85221106e51412f93a14a98c9e0fa35d197 (diff) | |
download | chromium_src-43f67a00aa82e1aa28169149c4d63169e3d3a13a.zip chromium_src-43f67a00aa82e1aa28169149c4d63169e3d3a13a.tar.gz chromium_src-43f67a00aa82e1aa28169149c4d63169e3d3a13a.tar.bz2 |
Make Javascript alerts do IDN and proper handling of non-standard and file
schemes.
BUG=1323921,1323917
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@834 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/jsmessage_box_handler.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc index bed59dc..a2e3174 100644 --- a/chrome/browser/jsmessage_box_handler.cc +++ b/chrome/browser/jsmessage_box_handler.cc @@ -32,9 +32,11 @@ #include "chrome/browser/app_modal_dialog_queue.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/web_contents.h" +#include "chrome/common/gfx/url_elider.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_types.h" +#include "chrome/common/pref_names.h" #include "chrome/views/message_box_view.h" #include "chrome/views/window.h" @@ -89,11 +91,20 @@ std::wstring JavascriptMessageBoxHandler::GetWindowTitle() const { if (!url.has_host()) return l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); - std::string base_address = url.scheme() + "://" + url.host(); - if (url.has_port()) - base_address += ":" + url.port(); - return l10n_util::GetStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, - ASCIIToWide(base_address)); + // We really only want the scheme, hostname, and port. + GURL::Replacements replacements; + replacements.ClearUsername(); + replacements.ClearPassword(); + replacements.ClearPath(); + replacements.ClearQuery(); + replacements.ClearRef(); + GURL clean_url = url.ReplaceComponents(replacements); + + // TODO(brettw) it should be easier than this to do the correct language + // handling without getting the accept language from the profil. + std::wstring base_address = gfx::ElideUrl(clean_url, ChromeFont(), 0, + web_contents_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); + return l10n_util::GetStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base_address); } void JavascriptMessageBoxHandler::WindowClosing() { |