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

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: Inlined the variable androidUriSuffix 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 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());
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));
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() {
81 return Profile::FromWebUI(web_ui()); 87 return Profile::FromWebUI(web_ui());
82 } 88 }
83 89
84 #if !defined(OS_ANDROID) 90 #if !defined(OS_ANDROID)
85 gfx::NativeWindow PasswordManagerHandler::GetNativeWindow() const { 91 gfx::NativeWindow PasswordManagerHandler::GetNativeWindow() const {
86 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 92 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
87 } 93 }
88 #endif 94 #endif
89 95
90 void PasswordManagerHandler::GetLocalizedValues( 96 void PasswordManagerHandler::GetLocalizedValues(
91 base::DictionaryValue* localized_strings) { 97 base::DictionaryValue* localized_strings) {
92 DCHECK(localized_strings); 98 DCHECK(localized_strings);
93 99
94 static const OptionsStringResource resources[] = { 100 static const OptionsStringResource resources[] = {
101 {"androidUriSuffix", IDS_PASSWORDS_ANDROID_URI_SUFFIX},
95 {"autoSigninTitle", IDS_PASSWORDS_AUTO_SIGNIN_TITLE}, 102 {"autoSigninTitle", IDS_PASSWORDS_AUTO_SIGNIN_TITLE},
96 {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION}, 103 {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION},
97 {"savedPasswordsTitle", IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE}, 104 {"savedPasswordsTitle", IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE},
98 {"passwordExceptionsTitle", IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE}, 105 {"passwordExceptionsTitle", IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE},
99 {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS}, 106 {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS},
100 {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON}, 107 {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON},
101 {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON}, 108 {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON},
102 {"passwordsNoPasswordsDescription", 109 {"passwordsNoPasswordsDescription",
103 IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION}, 110 IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION},
104 {"passwordsNoExceptionsDescription", 111 {"passwordsNoExceptionsDescription",
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 269 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
263 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get()); 270 CopyOriginInfoOfPasswordForm(*exception, languages_, entry.get());
264 entries.Append(entry.release()); 271 entries.Append(entry.release());
265 } 272 }
266 273
267 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 274 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
268 entries); 275 entries);
269 } 276 }
270 277
271 } // namespace options 278 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/password_manager_presenter.cc ('k') | components/autofill/core/common/password_form.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698