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

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

Issue 1130213004: [Smart Lock] Make android URL prettifying util available on ios. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on top of master Created 5 years, 7 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #if defined(OS_WIN) && defined(USE_ASH) 16 #if defined(OS_WIN) && defined(USE_ASH)
17 #include "chrome/browser/ui/ash/ash_util.h" 17 #include "chrome/browser/ui/ash/ash_util.h"
18 #endif 18 #endif
19 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
20 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" 19 #include "chrome/browser/ui/passwords/password_bubble_experiment.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
23 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
24 #include "components/autofill/core/common/password_form.h" 23 #include "components/autofill/core/common/password_form.h"
24 #include "components/password_manager/core/browser/affiliation_utils.h"
25 #include "components/password_manager/core/common/experiments.h" 25 #include "components/password_manager/core/common/experiments.h"
26 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "net/base/net_util.h" 32 #include "net/base/net_util.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 34
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 void PasswordManagerHandler::SetPasswordList( 196 void PasswordManagerHandler::SetPasswordList(
197 const ScopedVector<autofill::PasswordForm>& password_list, 197 const ScopedVector<autofill::PasswordForm>& password_list,
198 bool show_passwords) { 198 bool show_passwords) {
199 base::ListValue entries; 199 base::ListValue entries;
200 languages_ = GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages); 200 languages_ = GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
201 base::string16 placeholder(base::ASCIIToUTF16(" ")); 201 base::string16 placeholder(base::ASCIIToUTF16(" "));
202 for (size_t i = 0; i < password_list.size(); ++i) { 202 for (size_t i = 0; i < password_list.size(); ++i) {
203 base::ListValue* entry = new base::ListValue(); 203 base::ListValue* entry = new base::ListValue();
204 entry->AppendString(GetHumanReadableOrigin(*password_list[i], languages_)); 204 entry->AppendString(password_manager::GetHumanReadableOrigin(
205 *password_list[i], languages_));
205 entry->AppendString(password_list[i]->username_value); 206 entry->AppendString(password_list[i]->username_value);
206 if (show_passwords) { 207 if (show_passwords) {
207 entry->AppendString(password_list[i]->password_value); 208 entry->AppendString(password_list[i]->password_value);
208 } else { 209 } else {
209 // Use a placeholder value with the same length as the password. 210 // Use a placeholder value with the same length as the password.
210 entry->AppendString( 211 entry->AppendString(
211 base::string16(password_list[i]->password_value.length(), ' ')); 212 base::string16(password_list[i]->password_value.length(), ' '));
212 } 213 }
213 const GURL& federation_url = password_list[i]->federation_url; 214 const GURL& federation_url = password_list[i]->federation_url;
214 if (!federation_url.is_empty()) { 215 if (!federation_url.is_empty()) {
215 entry->AppendString(l10n_util::GetStringFUTF16( 216 entry->AppendString(l10n_util::GetStringFUTF16(
216 IDS_PASSWORDS_VIA_FEDERATION, 217 IDS_PASSWORDS_VIA_FEDERATION,
217 base::UTF8ToUTF16(federation_url.host()))); 218 base::UTF8ToUTF16(federation_url.host())));
218 } 219 }
219 entries.Append(entry); 220 entries.Append(entry);
220 } 221 }
221 222
222 web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList", 223 web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList",
223 entries); 224 entries);
224 } 225 }
225 226
226 void PasswordManagerHandler::SetPasswordExceptionList( 227 void PasswordManagerHandler::SetPasswordExceptionList(
227 const ScopedVector<autofill::PasswordForm>& password_exception_list) { 228 const ScopedVector<autofill::PasswordForm>& password_exception_list) {
228 base::ListValue entries; 229 base::ListValue entries;
229 for (size_t i = 0; i < password_exception_list.size(); ++i) { 230 for (size_t i = 0; i < password_exception_list.size(); ++i) {
230 entries.AppendString( 231 entries.AppendString(password_manager::GetHumanReadableOrigin(
231 GetHumanReadableOrigin(*password_exception_list[i], languages_)); 232 *password_exception_list[i], languages_));
232 } 233 }
233 234
234 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 235 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
235 entries); 236 entries);
236 } 237 }
237 238
238 } // namespace options 239 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698