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

Side by Side Diff: chrome/browser/ui/webui/options/password_manager_handler.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/webui/options/password_manager_handler.h" 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const char kIsAndroidUriField[] = "isAndroidUri"; 50 const char kIsAndroidUriField[] = "isAndroidUri";
51 const char kIsClickable[] = "isClickable"; 51 const char kIsClickable[] = "isClickable";
52 const char kIsSecureField[] = "isSecure"; 52 const char kIsSecureField[] = "isSecure";
53 const char kUsernameField[] = "username"; 53 const char kUsernameField[] = "username";
54 const char kPasswordField[] = "password"; 54 const char kPasswordField[] = "password";
55 const char kFederationField[] = "federation"; 55 const char kFederationField[] = "federation";
56 56
57 // Copies from |form| to |entry| the origin, shown origin, whether the origin is 57 // Copies from |form| to |entry| the origin, shown origin, whether the origin is
58 // Android URI, and whether the origin is secure. 58 // Android URI, and whether the origin is secure.
59 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form, 59 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form,
60 const std::string& languages,
61 base::DictionaryValue* entry) { 60 base::DictionaryValue* entry) {
62 bool is_android_uri = false; 61 bool is_android_uri = false;
63 bool origin_is_clickable = false; 62 bool origin_is_clickable = false;
64 GURL link_url; 63 GURL link_url;
65 entry->SetString( 64 entry->SetString(
66 kShownOriginField, 65 kShownOriginField,
67 password_manager::GetShownOriginAndLinkUrl( 66 password_manager::GetShownOriginAndLinkUrl(
68 form, languages, &is_android_uri, &link_url, &origin_is_clickable)); 67 form, &is_android_uri, &link_url, &origin_is_clickable));
69 DCHECK(link_url.is_valid()); 68 DCHECK(link_url.is_valid());
70 entry->SetString( 69 entry->SetString(
71 kUrlField, url_formatter::FormatUrl( 70 kUrlField, url_formatter::FormatUrl(
72 link_url, languages, url_formatter::kFormatUrlOmitNothing, 71 link_url, url_formatter::kFormatUrlOmitNothing,
73 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); 72 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
74 entry->SetBoolean(kIsAndroidUriField, is_android_uri); 73 entry->SetBoolean(kIsAndroidUriField, is_android_uri);
75 entry->SetBoolean(kIsClickable, origin_is_clickable); 74 entry->SetBoolean(kIsClickable, origin_is_clickable);
76 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url)); 75 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url));
77 } 76 }
78 77
79 } // namespace 78 } // namespace
80 79
81 PasswordManagerHandler::PasswordManagerHandler() 80 PasswordManagerHandler::PasswordManagerHandler()
82 : password_manager_presenter_(this) {} 81 : password_manager_presenter_(this) {}
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 222 }
224 223
225 void PasswordManagerHandler::HandleUpdatePasswordLists( 224 void PasswordManagerHandler::HandleUpdatePasswordLists(
226 const base::ListValue* args) { 225 const base::ListValue* args) {
227 password_manager_presenter_.UpdatePasswordLists(); 226 password_manager_presenter_.UpdatePasswordLists();
228 } 227 }
229 228
230 void PasswordManagerHandler::SetPasswordList( 229 void PasswordManagerHandler::SetPasswordList(
231 const std::vector<scoped_ptr<autofill::PasswordForm>>& password_list) { 230 const std::vector<scoped_ptr<autofill::PasswordForm>>& password_list) {
232 base::ListValue entries; 231 base::ListValue entries;
233 languages_ = GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
234 base::string16 placeholder(base::ASCIIToUTF16(" ")); 232 base::string16 placeholder(base::ASCIIToUTF16(" "));
235 for (const auto& saved_password : password_list) { 233 for (const auto& saved_password : password_list) {
236 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 234 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
237 CopyOriginInfoOfPasswordForm(*saved_password, languages_, entry.get()); 235 CopyOriginInfoOfPasswordForm(*saved_password, entry.get());
238 236
239 entry->SetString(kUsernameField, saved_password->username_value); 237 entry->SetString(kUsernameField, saved_password->username_value);
240 // Use a placeholder value with the same length as the password. 238 // Use a placeholder value with the same length as the password.
241 entry->SetString( 239 entry->SetString(
242 kPasswordField, 240 kPasswordField,
243 base::string16(saved_password->password_value.length(), ' ')); 241 base::string16(saved_password->password_value.length(), ' '));
244 if (!saved_password->federation_origin.unique()) { 242 if (!saved_password->federation_origin.unique()) {
245 entry->SetString( 243 entry->SetString(
246 kFederationField, 244 kFederationField,
247 l10n_util::GetStringFUTF16( 245 l10n_util::GetStringFUTF16(
248 IDS_PASSWORDS_VIA_FEDERATION, 246 IDS_PASSWORDS_VIA_FEDERATION,
249 base::UTF8ToUTF16(saved_password->federation_origin.host()))); 247 base::UTF8ToUTF16(saved_password->federation_origin.host())));
250 } 248 }
251 249
252 entries.Append(entry.release()); 250 entries.Append(entry.release());
253 } 251 }
254 252
255 web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList", 253 web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList",
256 entries); 254 entries);
257 } 255 }
258 256
259 void PasswordManagerHandler::SetPasswordExceptionList( 257 void PasswordManagerHandler::SetPasswordExceptionList(
260 const std::vector<scoped_ptr<autofill::PasswordForm>>& 258 const std::vector<scoped_ptr<autofill::PasswordForm>>&
261 password_exception_list) { 259 password_exception_list) {
262 base::ListValue entries; 260 base::ListValue entries;
263 for (const auto& exception : password_exception_list) { 261 for (const auto& exception : password_exception_list) {
264 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 262 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
265 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get()); 263 CopyOriginInfoOfPasswordForm(*exception, entry.get());
266 entries.Append(entry.release()); 264 entries.Append(entry.release());
267 } 265 }
268 266
269 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 267 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
270 entries); 268 entries);
271 } 269 }
272 270
273 } // namespace options 271 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/password_manager_handler.h ('k') | chrome/common/net/x509_certificate_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698