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

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

Issue 1615653005: [Password manager] Human readable origins for Android credentials on chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests for GetShownOriginAndLinkUrl 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 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 27 matching lines...) Expand all
38 38
39 #if defined(OS_WIN) && defined(USE_ASH) 39 #if defined(OS_WIN) && defined(USE_ASH)
40 #include "chrome/browser/ui/ash/ash_util.h" 40 #include "chrome/browser/ui/ash/ash_util.h"
41 #endif 41 #endif
42 42
43 namespace options { 43 namespace options {
44 44
45 namespace { 45 namespace {
46 // The following constants should be synchronized with the constants in 46 // The following constants should be synchronized with the constants in
47 // chrome/browser/resources/options/password_manager_list.js. 47 // chrome/browser/resources/options/password_manager_list.js.
48 const char kOriginField[] = "origin"; 48 const char kUrlField[] = "url";
49 const char kShownUrlField[] = "shownUrl"; 49 const char kShownOriginField[] = "shownOrigin";
50 const char kIsAndroidUriField[] = "isAndroidUri"; 50 const char kIsAndroidUriField[] = "isAndroidUri";
51 const char kIsClickable[] = "isClickable";
51 const char kIsSecureField[] = "isSecure"; 52 const char kIsSecureField[] = "isSecure";
52 const char kUsernameField[] = "username"; 53 const char kUsernameField[] = "username";
53 const char kPasswordField[] = "password"; 54 const char kPasswordField[] = "password";
54 const char kFederationField[] = "federation"; 55 const char kFederationField[] = "federation";
55 56
56 // 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
57 // Android URI, and whether the origin is secure. 58 // Android URI, and whether the origin is secure.
58 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form, 59 void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form,
59 const std::string& languages, 60 const std::string& languages,
60 base::DictionaryValue* entry) { 61 base::DictionaryValue* entry) {
62 bool is_android_uri = false;
63 bool origin_is_clickable = false;
64 GURL link_url;
61 entry->SetString( 65 entry->SetString(
62 kOriginField, 66 kShownOriginField,
63 url_formatter::FormatUrl( 67 password_manager::GetShownOriginAndLinkUrl(
64 form.origin, languages, url_formatter::kFormatUrlOmitNothing, 68 form, languages, &is_android_uri, &link_url, &origin_is_clickable));
65 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); 69 DCHECK(link_url.is_valid());
engedy 2016/03/02 14:22:10 Hang on, how does this not fail for empty |link_ur
kolos1 2016/03/07 10:47:00 It is not always PasswordForm.affiliated_web_realm
engedy 2016/03/08 17:36:37 Please see my other comment. GetShownOriginAndLink
66 bool is_android_uri = false; 70 entry->SetString(
67 entry->SetString(kShownUrlField, password_manager::GetShownOrigin( 71 kUrlField, url_formatter::FormatUrl(
68 form, languages, &is_android_uri)); 72 link_url, languages, url_formatter::kFormatUrlOmitNothing,
73 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
69 entry->SetBoolean(kIsAndroidUriField, is_android_uri); 74 entry->SetBoolean(kIsAndroidUriField, is_android_uri);
70 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(form.origin)); 75 entry->SetBoolean(kIsClickable, origin_is_clickable);
76 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url));
engedy 2016/03/02 14:22:10 Nit: FWIW, Android credentials are always secure t
kolos1 2016/03/07 10:47:00 Thanks. Is it possible that the scheme of affili
engedy 2016/03/08 17:36:37 No, HTTP URLs are not valid facet URIs.
71 } 77 }
72 78
73 } // namespace 79 } // namespace
74 80
75 PasswordManagerHandler::PasswordManagerHandler() 81 PasswordManagerHandler::PasswordManagerHandler()
76 : password_manager_presenter_(this) {} 82 : password_manager_presenter_(this) {}
77 83
78 PasswordManagerHandler::~PasswordManagerHandler() {} 84 PasswordManagerHandler::~PasswordManagerHandler() {}
79 85
80 Profile* PasswordManagerHandler::GetProfile() { 86 Profile* PasswordManagerHandler::GetProfile() {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 268 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
263 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get()); 269 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get());
264 entries.Append(entry.release()); 270 entries.Append(entry.release());
265 } 271 }
266 272
267 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 273 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
268 entries); 274 entries);
269 } 275 }
270 276
271 } // namespace options 277 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698