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

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

Issue 682133003: [Password Manager] Add link to remotely manage passowrds on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 6 years, 1 month 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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #if defined(OS_WIN) && defined(USE_ASH) 15 #if defined(OS_WIN) && defined(USE_ASH)
15 #include "chrome/browser/ui/ash/ash_util.h" 16 #include "chrome/browser/ui/ash/ash_util.h"
16 #endif 17 #endif
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
20 #include "components/autofill/core/common/password_form.h" 21 #include "components/autofill/core/common/password_form.h"
22 #include "components/password_manager/core/common/experiments.h"
21 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
23 #include "content/public/browser/user_metrics.h" 25 #include "content/public/browser/user_metrics.h"
24 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_ui.h" 27 #include "content/public/browser/web_ui.h"
26 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
29 #include "ui/base/l10n/l10n_util.h"
27 30
28 namespace options { 31 namespace options {
29 32
30 PasswordManagerHandler::PasswordManagerHandler() 33 PasswordManagerHandler::PasswordManagerHandler()
31 : password_manager_presenter_(this) {} 34 : password_manager_presenter_(this) {}
32 35
33 PasswordManagerHandler::~PasswordManagerHandler() {} 36 PasswordManagerHandler::~PasswordManagerHandler() {}
34 37
35 Profile* PasswordManagerHandler::GetProfile() { 38 Profile* PasswordManagerHandler::GetProfile() {
36 return Profile::FromWebUI(web_ui()); 39 return Profile::FromWebUI(web_ui());
(...skipping 25 matching lines...) Expand all
62 { "passwordsNoExceptionsDescription", 65 { "passwordsNoExceptionsDescription",
63 IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION }, 66 IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION },
64 }; 67 };
65 68
66 RegisterStrings(localized_strings, resources, arraysize(resources)); 69 RegisterStrings(localized_strings, resources, arraysize(resources));
67 RegisterTitle(localized_strings, "passwordsPage", 70 RegisterTitle(localized_strings, "passwordsPage",
68 IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE); 71 IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE);
69 72
70 localized_strings->SetString("passwordManagerLearnMoreURL", 73 localized_strings->SetString("passwordManagerLearnMoreURL",
71 chrome::kPasswordManagerLearnMoreURL); 74 chrome::kPasswordManagerLearnMoreURL);
75 localized_strings->SetString("passwordsManagePasswordsLink",
76 chrome::kPasswordManagerAccountDashboardURL);
77
78 std::vector<base::string16> pieces;
79 base::SplitStringDontTrim(
80 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_REMOTE_TEXT),
81 '|', // separator
82 &pieces);
83 DCHECK_EQ(3U, pieces.size());
84 localized_strings->SetString("passwordsManagePasswordsBeforeLinkText",
85 pieces[0]);
86 localized_strings->SetString("passwordsManagePasswordsLinkText", pieces[1]);
87 localized_strings->SetString("passwordsManagePasswordsAfterLinkText",
88 pieces[2]);
89
72 bool disable_show_passwords = false; 90 bool disable_show_passwords = false;
73 91
74 #if defined(OS_WIN) && defined(USE_ASH) 92 #if defined(OS_WIN) && defined(USE_ASH)
75 // We disable the ability to show passwords when running in Windows Metro 93 // We disable the ability to show passwords when running in Windows Metro
76 // interface. This is because we cannot pop native Win32 dialogs from the 94 // interface. This is because we cannot pop native Win32 dialogs from the
77 // Metro process. 95 // Metro process.
78 // TODO(wfh): Revisit this if Metro usage grows. 96 // TODO(wfh): Revisit this if Metro usage grows.
79 if (chrome::IsNativeWindowInAsh(GetNativeWindow())) 97 if (chrome::IsNativeWindowInAsh(GetNativeWindow()))
80 disable_show_passwords = true; 98 disable_show_passwords = true;
81 #endif 99 #endif
(...skipping 17 matching lines...) Expand all
99 web_ui()->RegisterMessageCallback( 117 web_ui()->RegisterMessageCallback(
100 "requestShowPassword", 118 "requestShowPassword",
101 base::Bind(&PasswordManagerHandler::HandleRequestShowPassword, 119 base::Bind(&PasswordManagerHandler::HandleRequestShowPassword,
102 base::Unretained(this))); 120 base::Unretained(this)));
103 } 121 }
104 122
105 void PasswordManagerHandler::InitializeHandler() { 123 void PasswordManagerHandler::InitializeHandler() {
106 password_manager_presenter_.Initialize(); 124 password_manager_presenter_.Initialize();
107 } 125 }
108 126
127 void PasswordManagerHandler::InitializePage() {
128 base::FundamentalValue visible(
129 password_manager::ManageAccountLinkExperimentEnabled());
130 web_ui()->CallJavascriptFunction(
131 "PasswordManager.setManageAccountLinkVisibility", visible);
132 }
133
109 void PasswordManagerHandler::HandleRemoveSavedPassword( 134 void PasswordManagerHandler::HandleRemoveSavedPassword(
110 const base::ListValue* args) { 135 const base::ListValue* args) {
111 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); 136 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args));
112 int index; 137 int index;
113 if (base::StringToInt(string_value, &index) && index >= 0) { 138 if (base::StringToInt(string_value, &index) && index >= 0) {
114 password_manager_presenter_.RemoveSavedPassword(static_cast<size_t>(index)); 139 password_manager_presenter_.RemoveSavedPassword(static_cast<size_t>(index));
115 } 140 }
116 } 141 }
117 142
118 void PasswordManagerHandler::HandleRemovePasswordException( 143 void PasswordManagerHandler::HandleRemovePasswordException(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 for (size_t i = 0; i < password_exception_list.size(); ++i) { 205 for (size_t i = 0; i < password_exception_list.size(); ++i) {
181 entries.Append(new base::StringValue( 206 entries.Append(new base::StringValue(
182 net::FormatUrl(password_exception_list[i]->origin, languages_))); 207 net::FormatUrl(password_exception_list[i]->origin, languages_)));
183 } 208 }
184 209
185 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 210 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
186 entries); 211 entries);
187 } 212 }
188 213
189 } // namespace options 214 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/password_manager_handler.h ('k') | components/password_manager.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698