Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: components/app_modal/javascript_dialog_manager.cc

Issue 1676693002: Show elided hostnames in modal dialog titles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more builds Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/app_modal/javascript_dialog_manager.cc
diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc
index 2b6ec646cebf8d6edc574a13e5f4bb43a38df1c7..a0a08e6f1cddda476940c9a6b063ee98343fab27 100644
--- a/components/app_modal/javascript_dialog_manager.cc
+++ b/components/app_modal/javascript_dialog_manager.cc
@@ -22,10 +22,17 @@
#include "grit/components_strings.h"
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/font_list.h"
namespace app_modal {
namespace {
+#if !defined(OS_ANDROID)
+// Keep in sync with kDefaultMessageWidth, but allow some space for the rest of
+// the text.
+const int kUrlElideWidth = 350;
+#endif
+
class DefaultExtensionsClient : public JavaScriptDialogExtensionsClient {
public:
DefaultExtensionsClient() {}
@@ -208,9 +215,14 @@ base::string16 JavaScriptDialogManager::GetTitle(
(web_contents->GetURL().GetOrigin() == origin_url.GetOrigin());
if (origin_url.IsStandard() && !origin_url.SchemeIsFile() &&
!origin_url.SchemeIsFileSystem()) {
+#if !defined(OS_ANDROID)
+ base::string16 url_string =
+ url_formatter::ElideHost(origin_url, gfx::FontList(), kUrlElideWidth);
+#else
base::string16 url_string =
url_formatter::FormatUrlForSecurityDisplayOmitScheme(origin_url,
accept_lang);
+#endif
return l10n_util::GetStringFUTF16(
is_same_origin_as_main_frame ? IDS_JAVASCRIPT_MESSAGEBOX_TITLE
: IDS_JAVASCRIPT_MESSAGEBOX_TITLE_IFRAME,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698