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

Unified Diff: chrome/browser/ui/webui/settings/passwords_handler.cc

Issue 1591053002: Add a password handler to get the list of passwords in md-settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback + closure compile Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/passwords_handler.cc
diff --git a/chrome/browser/ui/webui/options/password_manager_handler.cc b/chrome/browser/ui/webui/settings/passwords_handler.cc
similarity index 56%
copy from chrome/browser/ui/webui/options/password_manager_handler.cc
copy to chrome/browser/ui/webui/settings/passwords_handler.cc
index 645eacf926ae169abf97ee43e7e6366c37c0559e..0d8f1708cb9f3e018054a212ac4fc3444b03f2dc 100644
--- a/chrome/browser/ui/webui/options/password_manager_handler.cc
+++ b/chrome/browser/ui/webui/settings/passwords_handler.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/options/password_manager_handler.h"
+#include "chrome/browser/ui/webui/settings/passwords_handler.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -40,7 +40,7 @@
#include "chrome/browser/ui/ash/ash_util.h"
#endif
-namespace options {
+namespace settings {
namespace {
// The following constants should be synchronized with the constants in
@@ -72,112 +72,41 @@ void CopyOriginInfoOfPasswordForm(const autofill::PasswordForm& form,
} // namespace
-PasswordManagerHandler::PasswordManagerHandler()
- : password_manager_presenter_(this) {}
+PasswordsHandler::PasswordsHandler() : password_manager_presenter_(this) {}
-PasswordManagerHandler::~PasswordManagerHandler() {}
+PasswordsHandler::~PasswordsHandler() {}
-Profile* PasswordManagerHandler::GetProfile() {
+Profile* PasswordsHandler::GetProfile() {
return Profile::FromWebUI(web_ui());
}
#if !defined(OS_ANDROID)
-gfx::NativeWindow PasswordManagerHandler::GetNativeWindow() const {
+gfx::NativeWindow PasswordsHandler::GetNativeWindow() const {
return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
}
#endif
-void PasswordManagerHandler::GetLocalizedValues(
- base::DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- static const OptionsStringResource resources[] = {
- {"autoSigninTitle", IDS_PASSWORDS_AUTO_SIGNIN_TITLE},
- {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION},
- {"savedPasswordsTitle", IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE},
- {"passwordExceptionsTitle", IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE},
- {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS},
- {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON},
- {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON},
- {"passwordsNoPasswordsDescription",
- IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION},
- {"passwordsNoExceptionsDescription",
- IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION},
- };
-
- RegisterStrings(localized_strings, resources, arraysize(resources));
-
- const ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(GetProfile());
- int title_id =
- password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service)
- ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS
- : IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE;
- RegisterTitle(localized_strings, "passwordsPage", title_id);
-
- localized_strings->SetString("passwordManagerLearnMoreURL",
- chrome::kPasswordManagerLearnMoreURL);
- localized_strings->SetString(
- "passwordsManagePasswordsLink",
- password_manager::kPasswordManagerAccountDashboardURL);
-
- std::string management_hostname =
- GURL(password_manager::kPasswordManagerAccountDashboardURL).host();
- base::string16 link_text = base::UTF8ToUTF16(management_hostname);
- size_t offset;
- base::string16 full_text = l10n_util::GetStringFUTF16(
- IDS_MANAGE_PASSWORDS_REMOTE_TEXT, link_text, &offset);
-
- localized_strings->SetString("passwordsManagePasswordsBeforeLinkText",
- full_text.substr(0, offset));
- localized_strings->SetString("passwordsManagePasswordsLinkText",
- full_text.substr(offset, link_text.size()));
- localized_strings->SetString("passwordsManagePasswordsAfterLinkText",
- full_text.substr(offset + link_text.size()));
-
- bool disable_show_passwords = false;
-
-#if defined(OS_WIN) && defined(USE_ASH)
- // We disable the ability to show passwords when running in Windows Metro
- // interface. This is because we cannot pop native Win32 dialogs from the
- // Metro process.
- // TODO(wfh): Revisit this if Metro usage grows.
- if (chrome::IsNativeWindowInAsh(GetNativeWindow()))
- disable_show_passwords = true;
-#endif
-
- localized_strings->SetBoolean("disableShowPasswords", disable_show_passwords);
- localized_strings->SetBoolean(
- "enableCredentialManagerAPI",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableCredentialManagerAPI));
-}
-
-void PasswordManagerHandler::RegisterMessages() {
+void PasswordsHandler::RegisterMessages() {
+ password_manager_presenter_.Initialize();
web_ui()->RegisterMessageCallback(
"updatePasswordLists",
- base::Bind(&PasswordManagerHandler::HandleUpdatePasswordLists,
+ base::Bind(&PasswordsHandler::HandleUpdatePasswordLists,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"removeSavedPassword",
- base::Bind(&PasswordManagerHandler::HandleRemoveSavedPassword,
+ base::Bind(&PasswordsHandler::HandleRemoveSavedPassword,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"removePasswordException",
- base::Bind(&PasswordManagerHandler::HandleRemovePasswordException,
+ base::Bind(&PasswordsHandler::HandleRemovePasswordException,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"requestShowPassword",
- base::Bind(&PasswordManagerHandler::HandleRequestShowPassword,
+ base::Bind(&PasswordsHandler::HandleRequestShowPassword,
base::Unretained(this)));
}
-void PasswordManagerHandler::InitializeHandler() {
- password_manager_presenter_.Initialize();
-}
-
-void PasswordManagerHandler::HandleRemoveSavedPassword(
- const base::ListValue* args) {
+void PasswordsHandler::HandleRemoveSavedPassword(const base::ListValue* args) {
std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args));
int index;
if (base::StringToInt(string_value, &index) && index >= 0) {
@@ -185,7 +114,7 @@ void PasswordManagerHandler::HandleRemoveSavedPassword(
}
}
-void PasswordManagerHandler::HandleRemovePasswordException(
+void PasswordsHandler::HandleRemovePasswordException(
const base::ListValue* args) {
std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args));
int index;
@@ -195,8 +124,7 @@ void PasswordManagerHandler::HandleRemovePasswordException(
}
}
-void PasswordManagerHandler::HandleRequestShowPassword(
- const base::ListValue* args) {
+void PasswordsHandler::HandleRequestShowPassword(const base::ListValue* args) {
int index;
if (!ExtractIntegerValue(args, &index))
NOTREACHED();
@@ -204,24 +132,22 @@ void PasswordManagerHandler::HandleRequestShowPassword(
password_manager_presenter_.RequestShowPassword(static_cast<size_t>(index));
}
-void PasswordManagerHandler::ShowPassword(
- size_t index,
- const std::string& origin_url,
- const std::string& username,
- const base::string16& password_value) {
+void PasswordsHandler::ShowPassword(size_t index,
+ const std::string& origin_url,
+ const std::string& username,
+ const base::string16& password_value) {
// Call back the front end to reveal the password.
web_ui()->CallJavascriptFunction(
- "PasswordManager.showPassword",
+ "settings.PasswordsPrivateApi.showPassword",
base::FundamentalValue(static_cast<int>(index)),
base::StringValue(password_value));
}
-void PasswordManagerHandler::HandleUpdatePasswordLists(
- const base::ListValue* args) {
+void PasswordsHandler::HandleUpdatePasswordLists(const base::ListValue* args) {
password_manager_presenter_.UpdatePasswordLists();
}
-void PasswordManagerHandler::SetPasswordList(
+void PasswordsHandler::SetPasswordList(
const std::vector<scoped_ptr<autofill::PasswordForm>>& password_list,
bool show_passwords) {
base::ListValue entries;
@@ -251,11 +177,11 @@ void PasswordManagerHandler::SetPasswordList(
entries.Append(entry.release());
}
- web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList",
- entries);
+ web_ui()->CallJavascriptFunction(
+ "settings.PasswordsPrivateApi.setSavedPasswordsList", entries);
}
-void PasswordManagerHandler::SetPasswordExceptionList(
+void PasswordsHandler::SetPasswordExceptionList(
const std::vector<scoped_ptr<autofill::PasswordForm>>&
password_exception_list) {
base::ListValue entries;
@@ -265,8 +191,8 @@ void PasswordManagerHandler::SetPasswordExceptionList(
entries.Append(entry.release());
}
- web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList",
- entries);
+ web_ui()->CallJavascriptFunction(
+ "settings.PasswordsPrivateApi.setPasswordExceptionsList", entries);
}
-} // namespace options
+} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698