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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_view_utils.cc

Issue 1181623004: [Password Manager] Replace "this site" in save password prompt with password's origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for Windows bot. Created 5 years, 5 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
Index: chrome/browser/ui/passwords/manage_passwords_view_utils.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
index 880fada39d96842d37d119df6c7378cb41e82d5d..02ea978445b1169fa485fec2e96b6f595e1dd7af 100644
--- a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
@@ -5,12 +5,18 @@
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/elide_url.h"
+#include "chrome/grit/chromium_strings.h"
+#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/affiliation_utils.h"
#include "net/base/net_util.h"
+#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/range/range.h"
#include "url/gurl.h"
const int kAvatarImageSize = 50;
@@ -28,3 +34,42 @@ gfx::ImageSkia ScaleImageForAccountAvatar(gfx::ImageSkia skia_image) {
skia::ImageOperations::RESIZE_BEST,
gfx::Size(kAvatarImageSize, kAvatarImageSize));
}
+
+void GetSavePasswordDialogTitleTextAndLinkRange(
+ const GURL& user_visible_url,
+ const GURL& form_origin_url,
+ bool is_smartlock_branding_enabled,
+ base::string16* title,
+ gfx::Range* title_link_range) {
+ std::vector<size_t> offsets;
+ std::vector<base::string16> replacements;
+ int title_id = IDS_SAVE_PASSWORD;
+
+ // Check whether the registry controlled domains for user-visible URL (i.e.
+ // the one seen in the omnibox) and the password form post-submit navigation
+ // URL differs or not.
+ bool target_domain_differs =
+ !net::registry_controlled_domains::SameDomainOrHost(
+ user_visible_url, form_origin_url,
+ net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
+ if (target_domain_differs) {
+ title_id = IDS_SAVE_PASSWORD_TITLE;
+ replacements.push_back(
+ FormatUrlForSecurityDisplay(form_origin_url, std::string()));
+ }
+
+ if (is_smartlock_branding_enabled) {
+ // "Google Smart Lock" should be a hyperlink.
+ base::string16 title_link =
+ l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
+ replacements.insert(replacements.begin(), title_link);
+ *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets);
+ *title_link_range =
+ gfx::Range(offsets[0], offsets[0] + title_link.length());
+ } else {
+ replacements.insert(
+ replacements.begin(),
+ l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TITLE_BRAND));
+ *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698