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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_view_utils.cc

Issue 1776673003: Fix the password bubble titles for android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return std::make_pair(upper_string, lower_string); 71 return std::make_pair(upper_string, lower_string);
72 } 72 }
73 73
74 void GetSavePasswordDialogTitleTextAndLinkRange( 74 void GetSavePasswordDialogTitleTextAndLinkRange(
75 const GURL& user_visible_url, 75 const GURL& user_visible_url,
76 const GURL& form_origin_url, 76 const GURL& form_origin_url,
77 bool is_smartlock_branding_enabled, 77 bool is_smartlock_branding_enabled,
78 PasswordTittleType dialog_type, 78 PasswordTittleType dialog_type,
79 base::string16* title, 79 base::string16* title,
80 gfx::Range* title_link_range) { 80 gfx::Range* title_link_range) {
81 DCHECK(!password_manager::FacetURI::FromPotentiallyInvalidSpec(
engedy 2016/03/09 15:33:16 nit: DCHECK(!password_manager::IsValidAndroidFace
vasilii 2016/03/10 11:11:36 Done.
82 form_origin_url.spec()).IsValidAndroidFacetURI());
81 std::vector<size_t> offsets; 83 std::vector<size_t> offsets;
82 std::vector<base::string16> replacements; 84 std::vector<base::string16> replacements;
83 int title_id = 0; 85 int title_id = 0;
84 switch (dialog_type) { 86 switch (dialog_type) {
85 case PasswordTittleType::SAVE_PASSWORD: 87 case PasswordTittleType::SAVE_PASSWORD:
86 title_id = IDS_SAVE_PASSWORD; 88 title_id = IDS_SAVE_PASSWORD;
87 break; 89 break;
88 case PasswordTittleType::SAVE_ACCOUNT: 90 case PasswordTittleType::SAVE_ACCOUNT:
89 title_id = IDS_SAVE_ACCOUNT; 91 title_id = IDS_SAVE_ACCOUNT;
90 break; 92 break;
91 case PasswordTittleType::UPDATE_PASSWORD: 93 case PasswordTittleType::UPDATE_PASSWORD:
92 title_id = IDS_UPDATE_PASSWORD; 94 title_id = IDS_UPDATE_PASSWORD;
93 break; 95 break;
94 } 96 }
95 97
96 // Check whether the registry controlled domains for user-visible URL (i.e. 98 // Check whether the registry controlled domains for user-visible URL (i.e.
97 // the one seen in the omnibox) and the password form post-submit navigation 99 // the one seen in the omnibox) and the password form post-submit navigation
98 // URL differs or not. 100 // URL differs or not.
99 password_manager::FacetURI facet_uri = 101 if (!SameDomainOrHost(user_visible_url, form_origin_url)) {
100 password_manager::FacetURI::FromPotentiallyInvalidSpec(
101 form_origin_url.spec());
102 if (facet_uri.IsValidAndroidFacetURI()) {
103 title_id = IDS_SAVE_PASSWORD_TITLE;
104 replacements.push_back(
105 base::ASCIIToUTF16(GetHumanReadableOriginForAndroidUri(facet_uri)));
106 } else if (!SameDomainOrHost(user_visible_url, form_origin_url)) {
107 title_id = IDS_SAVE_PASSWORD_TITLE; 102 title_id = IDS_SAVE_PASSWORD_TITLE;
108 // TODO(palmer): Look into passing real language prefs here, not "". 103 // TODO(palmer): Look into passing real language prefs here, not "".
109 // crbug.com/498069. 104 // crbug.com/498069.
110 replacements.push_back(url_formatter::FormatUrlForSecurityDisplay( 105 replacements.push_back(url_formatter::FormatUrlForSecurityDisplay(
111 form_origin_url, std::string())); 106 form_origin_url, std::string()));
112 } 107 }
113 108
114 if (is_smartlock_branding_enabled) { 109 if (is_smartlock_branding_enabled) {
115 // "Google Smart Lock" should be a hyperlink. 110 // "Google Smart Lock" should be a hyperlink.
116 base::string16 title_link = 111 base::string16 title_link =
117 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); 112 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
118 replacements.insert(replacements.begin(), title_link); 113 replacements.insert(replacements.begin(), title_link);
119 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); 114 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets);
120 *title_link_range = 115 *title_link_range =
121 gfx::Range(offsets[0], offsets[0] + title_link.length()); 116 gfx::Range(offsets[0], offsets[0] + title_link.length());
122 } else { 117 } else {
123 replacements.insert( 118 replacements.insert(
124 replacements.begin(), 119 replacements.begin(),
125 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_TITLE_BRAND)); 120 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_TITLE_BRAND));
126 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); 121 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets);
127 } 122 }
128 } 123 }
129 124
130 void GetManagePasswordsDialogTitleText(const GURL& user_visible_url, 125 void GetManagePasswordsDialogTitleText(const GURL& user_visible_url,
131 const GURL& password_origin_url, 126 const GURL& password_origin_url,
132 base::string16* title) { 127 base::string16* title) {
128 DCHECK(!password_manager::FacetURI::FromPotentiallyInvalidSpec(
129 password_origin_url.spec()).IsValidAndroidFacetURI());
133 // Check whether the registry controlled domains for user-visible URL 130 // Check whether the registry controlled domains for user-visible URL
134 // (i.e. the one seen in the omnibox) and the managed password origin URL 131 // (i.e. the one seen in the omnibox) and the managed password origin URL
135 // differ or not. 132 // differ or not.
136 password_manager::FacetURI facet_uri = 133 if (!SameDomainOrHost(user_visible_url, password_origin_url)) {
137 password_manager::FacetURI::FromPotentiallyInvalidSpec(
138 password_origin_url.spec());
139 if (facet_uri.IsValidAndroidFacetURI()) {
140 *title = l10n_util::GetStringFUTF16(
141 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN,
142 base::ASCIIToUTF16(GetHumanReadableOriginForAndroidUri(facet_uri)));
143 } else if (!SameDomainOrHost(user_visible_url, password_origin_url)) {
144 // TODO(palmer): Look into passing real language prefs here, not "". 134 // TODO(palmer): Look into passing real language prefs here, not "".
145 base::string16 formatted_url = url_formatter::FormatUrlForSecurityDisplay( 135 base::string16 formatted_url = url_formatter::FormatUrlForSecurityDisplay(
146 password_origin_url, std::string()); 136 password_origin_url, std::string());
147 *title = l10n_util::GetStringFUTF16( 137 *title = l10n_util::GetStringFUTF16(
148 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN, formatted_url); 138 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN, formatted_url);
149 } else { 139 } else {
150 *title = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); 140 *title = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE);
151 } 141 }
152 } 142 }
153 143
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 : form.username_value; 177 : form.username_value;
188 } 178 }
189 179
190 bool IsSyncingAutosignSetting(Profile* profile) { 180 bool IsSyncingAutosignSetting(Profile* profile) {
191 const ProfileSyncService* sync_service = 181 const ProfileSyncService* sync_service =
192 ProfileSyncServiceFactory::GetForProfile(profile); 182 ProfileSyncServiceFactory::GetForProfile(profile);
193 return (sync_service && sync_service->IsFirstSetupComplete() && 183 return (sync_service && sync_service->IsFirstSetupComplete() &&
194 sync_service->IsSyncActive() && 184 sync_service->IsSyncActive() &&
195 sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)); 185 sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES));
196 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698