diff options
Diffstat (limited to 'chrome/browser/jsmessage_box_handler.cc')
-rw-r--r-- | chrome/browser/jsmessage_box_handler.cc | 40 |
1 files changed, 4 insertions, 36 deletions
diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc index 6ba052f..428c8a3 100644 --- a/chrome/browser/jsmessage_box_handler.cc +++ b/chrome/browser/jsmessage_box_handler.cc @@ -4,16 +4,12 @@ #include "chrome/browser/jsmessage_box_handler.h" -#include "app/gfx/text_elider.h" #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "build/build_config.h" #include "chrome/browser/app_modal_dialog_queue.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/pref_names.h" -#include "chrome/common/pref_service.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" @@ -29,47 +25,19 @@ std::wstring MakeTextSafe(const std::wstring& text) { return text; } -std::wstring GetWindowTitle(TabContents* tab_contents, const GURL& frame_url, - int dialog_flags) { - bool is_alert = (dialog_flags == MessageBoxFlags::kIsJavascriptAlert); - if (!frame_url.has_host()) - 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; - replacements.ClearUsername(); - replacements.ClearPassword(); - replacements.ClearPath(); - replacements.ClearQuery(); - replacements.ClearRef(); - GURL clean_url = frame_url.ReplaceComponents(replacements); - - // TODO(brettw) it should be easier than this to do the correct language - // handling without getting the accept language from the profile. - std::wstring base_address = gfx::ElideUrl(clean_url, gfx::Font(), 0, - tab_contents->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); - // Force URL to have LTR directionality. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - l10n_util::WrapStringWithLTRFormatting(&base_address); - return l10n_util::GetStringF( - is_alert ? IDS_JAVASCRIPT_ALERT_TITLE : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, - base_address); -} - } // namespace -void RunJavascriptMessageBox(TabContents* tab_contents, +void RunJavascriptMessageBox(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 = GetWindowTitle(tab_contents, frame_url, dialog_flags); + std::wstring title = client->GetMessageBoxTitle(frame_url, + (dialog_flags == MessageBoxFlags::kIsJavascriptAlert)); Singleton<AppModalDialogQueue>()->AddDialog( - new AppModalDialog(tab_contents, title, + new AppModalDialog(client, title, dialog_flags, MakeTextSafe(message_text), default_prompt_text, display_suppress_checkbox, false, reply_msg)); |