diff options
author | inferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 22:09:37 +0000 |
---|---|---|
committer | inferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 22:09:37 +0000 |
commit | bdb3992a2b76b27ad08293013ccfa0ca755770ba (patch) | |
tree | 50dcc844776e871f8f9e6fb98ae6540b92c2c00b | |
parent | 49b446611965a9d1c17ad1338cdfcd272d1a6d55 (diff) | |
download | chromium_src-bdb3992a2b76b27ad08293013ccfa0ca755770ba.zip chromium_src-bdb3992a2b76b27ad08293013ccfa0ca755770ba.tar.gz chromium_src-bdb3992a2b76b27ad08293013ccfa0ca755770ba.tar.bz2 |
Fix the GTK crash by eliding extra long url,command strings in external protocol launch message.
BUG=35168
TEST=None
Review URL: http://codereview.chromium.org/1518003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43002 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 37 insertions, 6 deletions
diff --git a/chrome/browser/chromeos/external_protocol_dialog.cc b/chrome/browser/chromeos/external_protocol_dialog.cc index 5a12dcf..860f62d 100644 --- a/chrome/browser/chromeos/external_protocol_dialog.cc +++ b/chrome/browser/chromeos/external_protocol_dialog.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "base/histogram.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -82,10 +83,15 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, const GURL& url) : creation_time_(base::Time::Now()), scheme_(UTF8ToWide(url.scheme())) { + const int kMaxUrlWithoutSchemeSize = 256; + std::wstring elided_url_without_scheme; + ElideString(ASCIIToWide(url.possibly_invalid_spec()), + kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); + std::wstring message_text = l10n_util::GetStringF( IDS_EXTERNAL_PROTOCOL_INFORMATION, ASCIIToWide(url.scheme() + ":"), - ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n"; + elided_url_without_scheme) + L"\n\n"; message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, message_text, diff --git a/chrome/browser/cocoa/external_protocol_dialog.mm b/chrome/browser/cocoa/external_protocol_dialog.mm index 6c346a4..c729cbf 100644 --- a/chrome/browser/cocoa/external_protocol_dialog.mm +++ b/chrome/browser/cocoa/external_protocol_dialog.mm @@ -6,6 +6,7 @@ #include "app/l10n_util_mac.h" #include "base/message_loop.h" +#include "base/string_util.h" #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/external_protocol_handler.h" @@ -57,10 +58,15 @@ void ExternalProtocolHandler::RunExternalProtocolDialog( l10n_util::GetNSStringWithFixup( IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)]; + const int kMaxUrlWithoutSchemeSize = 256; + std::wstring elided_url_without_scheme; + ElideString(ASCIIToWide(url_.possibly_invalid_spec()), + kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); + NSString* urlString = l10n_util::GetNSStringFWithFixup( IDS_EXTERNAL_PROTOCOL_INFORMATION, ASCIIToUTF16(url_.scheme() + ":"), - ASCIIToUTF16(url_.possibly_invalid_spec())); + WideToUTF16(elided_url_without_scheme)); NSString* appString = l10n_util::GetNSStringFWithFixup( IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, appName); diff --git a/chrome/browser/gtk/external_protocol_dialog_gtk.cc b/chrome/browser/gtk/external_protocol_dialog_gtk.cc index cee608f..3222f97 100644 --- a/chrome/browser/gtk/external_protocol_dialog_gtk.cc +++ b/chrome/browser/gtk/external_protocol_dialog_gtk.cc @@ -11,6 +11,7 @@ #include "app/l10n_util.h" #include "base/histogram.h" #include "base/message_loop.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/gtk/gtk_util.h" @@ -59,14 +60,23 @@ ExternalProtocolDialogGtk::ExternalProtocolDialogGtk(const GURL& url) GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); // Construct the message text. + const int kMaxUrlWithoutSchemeSize = 256; + const int kMaxCommandSize = 256; + std::wstring elided_url_without_scheme; + std::wstring elided_command; + ElideString(ASCIIToWide(url.possibly_invalid_spec()), + kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); + ElideString(ASCIIToWide(std::string("xdg-open ") + url.spec()), + kMaxCommandSize, &elided_command); + std::string message_text = l10n_util::GetStringFUTF8( IDS_EXTERNAL_PROTOCOL_INFORMATION, ASCIIToUTF16(url.scheme() + ":"), - ASCIIToUTF16(url.possibly_invalid_spec())) + "\n\n"; + WideToUTF16(elided_url_without_scheme)) + "\n\n"; message_text += l10n_util::GetStringFUTF8( IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, - ASCIIToUTF16(std::string("xdg-open ") + url.spec())) + "\n\n"; + WideToUTF16(elided_command)) + "\n\n"; message_text += l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_WARNING); diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 34f391e..32126ee 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -8,6 +8,7 @@ #include "app/message_box_flags.h" #include "base/histogram.h" #include "base/registry.h" +#include "base/string_util.h" #include "base/thread.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -117,13 +118,21 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, : tab_contents_(tab_contents), url_(url), creation_time_(base::Time::Now()) { + const int kMaxUrlWithoutSchemeSize = 256; + const int kMaxCommandSize = 256; + std::wstring elided_url_without_scheme; + std::wstring elided_command; + ElideString(ASCIIToWide(url.possibly_invalid_spec()), + kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); + ElideString(command, kMaxCommandSize, &elided_command); + std::wstring message_text = l10n_util::GetStringF( IDS_EXTERNAL_PROTOCOL_INFORMATION, ASCIIToWide(url.scheme() + ":"), - ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n"; + elided_url_without_scheme) + L"\n\n"; message_text += l10n_util::GetStringF( - IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n"; + IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, elided_command) + L"\n\n"; message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); |