Commit 9b161472 authored by Bettina's avatar Bettina Committed by Commit Bot

Remove change_password_handler code.

The change password card in the settings is not triggered
from password protection so it should be removed completely.
This is part 2 of the removal of the change password handler.
First part was crrev.com/c/1834950.

Bug: 991764
Change-Id: I2d877366f67bb7e30763b232211df62458554084
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834906
Commit-Queue: Bettina Dea <bdea@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarNathan Parker <nparker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704421}
parent 1b6a80bf
...@@ -68,7 +68,6 @@ group("closure_compile") { ...@@ -68,7 +68,6 @@ group("closure_compile") {
"appearance_page:closure_compile", "appearance_page:closure_compile",
"autofill_page:closure_compile", "autofill_page:closure_compile",
"basic_page:closure_compile", "basic_page:closure_compile",
"change_password_page:closure_compile",
"clear_browsing_data_dialog:closure_compile", "clear_browsing_data_dialog:closure_compile",
"controls:closure_compile", "controls:closure_compile",
"downloads_page:closure_compile", "downloads_page:closure_compile",
......
...@@ -16,7 +16,6 @@ js_library("basic_page") { ...@@ -16,7 +16,6 @@ js_library("basic_page") {
"..:route", "..:route",
"..:search_settings", "..:search_settings",
"../android_apps_page:android_apps_browser_proxy", "../android_apps_page:android_apps_browser_proxy",
"../change_password_page:change_password_browser_proxy",
"../chrome_cleanup_page:chrome_cleanup_proxy", "../chrome_cleanup_page:chrome_cleanup_proxy",
"../prefs:prefs_behavior", "../prefs:prefs_behavior",
"../settings_page:main_page_behavior", "../settings_page:main_page_behavior",
......
...@@ -56,11 +56,6 @@ Polymer({ ...@@ -56,11 +56,6 @@ Polymer({
/** @type {!AndroidAppsInfo|undefined} */ /** @type {!AndroidAppsInfo|undefined} */
androidAppsInfo: Object, androidAppsInfo: Object,
showChangePassword: {
type: Boolean,
value: false,
},
/** /**
* Dictionary defining page visibility. * Dictionary defining page visibility.
* @type {!PageVisibility} * @type {!PageVisibility}
...@@ -149,10 +144,6 @@ Polymer({ ...@@ -149,10 +144,6 @@ Polymer({
this.allowCrostini_ = loadTimeData.valueExists('allowCrostini') && this.allowCrostini_ = loadTimeData.valueExists('allowCrostini') &&
loadTimeData.getBoolean('allowCrostini'); loadTimeData.getBoolean('allowCrostini');
this.addWebUIListener('change-password-visibility', visibility => {
this.showChangePassword = visibility;
});
if (settings.AndroidAppsBrowserProxyImpl) { if (settings.AndroidAppsBrowserProxyImpl) {
this.addWebUIListener( this.addWebUIListener(
'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this)); 'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this));
......
# Copyright 2018 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.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
deps = [
":change_password_browser_proxy",
":change_password_page",
]
}
js_library("change_password_browser_proxy") {
deps = [
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
]
}
js_library("change_password_page") {
deps = [
":change_password_browser_proxy",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:util",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
externs_list = [ "$externs_path/settings_private.js" ]
}
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html">
<script src="change_password_browser_proxy.js"></script>
// Copyright 2017 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.
cr.define('settings', function() {
/** @interface */
class ChangePasswordBrowserProxy {
/** Initialize the change password handler.*/
initializeChangePasswordHandler() {}
/**
* Initiate the change password process. e.g., for Gmail users, it
* navigates to accounts.google.com; for GSuite users, it navigates to the
* corresponding change password URLs.
*/
changePassword() {}
}
/**
* @implements {settings.ChangePasswordBrowserProxy}
*/
class ChangePasswordBrowserProxyImpl {
/** @override */
initializeChangePasswordHandler() {
chrome.send('initializeChangePasswordHandler');
}
/** @override */
changePassword() {
chrome.send('changePassword');
}
}
cr.addSingletonGetter(ChangePasswordBrowserProxyImpl);
return {
ChangePasswordBrowserProxy: ChangePasswordBrowserProxy,
ChangePasswordBrowserProxyImpl: ChangePasswordBrowserProxyImpl,
};
});
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="change_password_browser_proxy.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<dom-module id="settings-change-password-page">
<template>
<style include="settings-shared">
.icon-container {
padding-inline-end: var(--cr-section-padding);
}
.change-password-icon {
vertical-align: top;
}
iron-icon[icon='cr:warning'] {
--iron-icon-fill-color: var(--settings-error-color);
}
.top-aligned-settings-box {
align-items: start;
min-height: 0;
padding: var(--cr-section-vertical-padding) var(--cr-section-padding);
}
</style>
<div class="settings-box first top-aligned-settings-box">
<div class="icon-container">
<iron-icon icon="cr:security"
class="change-password-icon"></iron-icon>
</div>
<div class="start">
<div>$i18n{changePasswordPageTitle}</div>
<div class="secondary">
$i18n{changePasswordPageDetails}
</div>
</div>
<div class="separator"></div>
<cr-button class="action-button" id="changePassword"
on-click="changePassword_">
$i18n{changePasswordPageButton}
</cr-button>
</div>
</template>
<script src="change_password_page.js"></script>
</dom-module>
// Copyright 2017 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.
/**
* @fileoverview
* 'change-password-page' is the settings page containing change password
* settings.
*/
Polymer({
is: 'settings-change-password-page',
/** @private */
changePassword_: function() {
settings.ChangePasswordBrowserProxyImpl.getInstance().changePassword();
},
});
...@@ -374,20 +374,6 @@ ...@@ -374,20 +374,6 @@
<structure name="IDR_OS_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_JS" <structure name="IDR_OS_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_JS"
file="global_scroll_target_behavior.js" file="global_scroll_target_behavior.js"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_HTML"
file="change_password_page/change_password_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_JS"
file="change_password_page/change_password_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_PAGE_HTML"
file="change_password_page/change_password_page.html"
type="chrome_html"
preprocess="true" />
<structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_PAGE_JS"
file="change_password_page/change_password_page.js"
type="chrome_html"
preprocess="true" />
<structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_BROWSER_PROXY_HTML" <structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_BROWSER_PROXY_HTML"
file="clear_browsing_data_dialog/clear_browsing_data_browser_proxy.html" file="clear_browsing_data_dialog/clear_browsing_data_browser_proxy.html"
type="chrome_html" /> type="chrome_html" />
......
...@@ -319,20 +319,6 @@ ...@@ -319,20 +319,6 @@
<structure name="IDR_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_JS" <structure name="IDR_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_JS"
file="global_scroll_target_behavior.js" file="global_scroll_target_behavior.js"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_HTML"
file="change_password_page/change_password_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_JS"
file="change_password_page/change_password_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_CHANGE_PASSWORD_PAGE_HTML"
file="change_password_page/change_password_page.html"
type="chrome_html"
preprocess="true" />
<structure name="IDR_SETTINGS_CHANGE_PASSWORD_PAGE_JS"
file="change_password_page/change_password_page.js"
type="chrome_html"
preprocess="true" />
<if expr="is_win"> <if expr="is_win">
<structure name="IDR_SETTINGS_CHROME_CLEANUP_PROXY_HTML" <structure name="IDR_SETTINGS_CHROME_CLEANUP_PROXY_HTML"
file="chrome_cleanup_page/chrome_cleanup_proxy.html" file="chrome_cleanup_page/chrome_cleanup_proxy.html"
......
...@@ -309,19 +309,6 @@ ChromePasswordProtectionService::GetPasswordProtectionService( ...@@ -309,19 +309,6 @@ ChromePasswordProtectionService::GetPasswordProtectionService(
} }
#if defined(SYNC_PASSWORD_REUSE_WARNING_ENABLED) #if defined(SYNC_PASSWORD_REUSE_WARNING_ENABLED)
// static
bool ChromePasswordProtectionService::ShouldShowChangePasswordSettingUI(
Profile* profile) {
ChromePasswordProtectionService* service =
ChromePasswordProtectionService::GetPasswordProtectionService(profile);
if (!service)
return false;
auto* unhandled_sync_password_reuses = profile->GetPrefs()->GetDictionary(
prefs::kSafeBrowsingUnhandledGaiaPasswordReuses);
return unhandled_sync_password_reuses &&
!unhandled_sync_password_reuses->empty();
}
// static // static
bool ChromePasswordProtectionService::ShouldShowPasswordReusePageInfoBubble( bool ChromePasswordProtectionService::ShouldShowPasswordReusePageInfoBubble(
content::WebContents* web_contents, content::WebContents* web_contents,
......
...@@ -102,8 +102,6 @@ class ChromePasswordProtectionService : public PasswordProtectionService { ...@@ -102,8 +102,6 @@ class ChromePasswordProtectionService : public PasswordProtectionService {
Profile* profile); Profile* profile);
#if defined(SYNC_PASSWORD_REUSE_WARNING_ENABLED) #if defined(SYNC_PASSWORD_REUSE_WARNING_ENABLED)
static bool ShouldShowChangePasswordSettingUI(Profile* profile);
// Called by SecurityStateTabHelper to determine if page info bubble should // Called by SecurityStateTabHelper to determine if page info bubble should
// show password reuse warning. // show password reuse warning.
static bool ShouldShowPasswordReusePageInfoBubble( static bool ShouldShowPasswordReusePageInfoBubble(
......
...@@ -1277,8 +1277,6 @@ jumbo_split_static_library("ui") { ...@@ -1277,8 +1277,6 @@ jumbo_split_static_library("ui") {
"webui/settings/appearance_handler.h", "webui/settings/appearance_handler.h",
"webui/settings/browser_lifetime_handler.cc", "webui/settings/browser_lifetime_handler.cc",
"webui/settings/browser_lifetime_handler.h", "webui/settings/browser_lifetime_handler.h",
"webui/settings/change_password_handler.cc",
"webui/settings/change_password_handler.h",
"webui/settings/custom_home_pages_table_model.cc", "webui/settings/custom_home_pages_table_model.cc",
"webui/settings/custom_home_pages_table_model.h", "webui/settings/custom_home_pages_table_model.h",
"webui/settings/downloads_handler.cc", "webui/settings/downloads_handler.cc",
......
// Copyright 2017 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/settings/change_password_handler.h"
#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/password_protection/metrics_util.h"
#include "components/safe_browsing/proto/csd.pb.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
namespace settings {
using password_manager::metrics_util::PasswordType;
using safe_browsing::ChromePasswordProtectionService;
using safe_browsing::LoginReputationClientResponse;
using safe_browsing::RequestOutcome;
ChangePasswordHandler::ChangePasswordHandler(
Profile* profile,
safe_browsing::ChromePasswordProtectionService* service)
: profile_(profile), service_(service) {
DCHECK(service_);
}
ChangePasswordHandler::~ChangePasswordHandler() {}
void ChangePasswordHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"initializeChangePasswordHandler",
base::BindRepeating(&ChangePasswordHandler::HandleInitialize,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"changePassword",
base::BindRepeating(&ChangePasswordHandler::HandleChangePassword,
base::Unretained(this)));
}
void ChangePasswordHandler::OnJavascriptAllowed() {
pref_registrar_.Init(profile_->GetPrefs());
pref_registrar_.Add(
prefs::kSafeBrowsingUnhandledGaiaPasswordReuses,
base::Bind(&ChangePasswordHandler::UpdateChangePasswordCardVisibility,
base::Unretained(this)));
}
void ChangePasswordHandler::OnJavascriptDisallowed() {
pref_registrar_.RemoveAll();
}
void ChangePasswordHandler::HandleInitialize(const base::ListValue* args) {
AllowJavascript();
UpdateChangePasswordCardVisibility();
}
void ChangePasswordHandler::HandleChangePassword(const base::ListValue* args) {
service_->OnUserAction(
web_ui()->GetWebContents(),
service_->reused_password_account_type_for_last_shown_warning(),
RequestOutcome::UNKNOWN,
LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, "unused_token",
safe_browsing::WarningUIType::CHROME_SETTINGS,
safe_browsing::WarningAction::CHANGE_PASSWORD);
}
void ChangePasswordHandler::UpdateChangePasswordCardVisibility() {
FireWebUIListener(
"change-password-visibility",
base::Value(
service_->IsWarningEnabled(
service_
->reused_password_account_type_for_last_shown_warning()) &&
safe_browsing::ChromePasswordProtectionService::
ShouldShowChangePasswordSettingUI(profile_)));
}
} // namespace settings
// Copyright 2017 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.
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHANGE_PASSWORD_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHANGE_PASSWORD_HANDLER_H_
#include "base/macros.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/prefs/pref_change_registrar.h"
class Profile;
namespace safe_browsing {
class ChromePasswordProtectionService;
}
namespace settings {
// Chrome "Change Password" settings page UI handler.
class ChangePasswordHandler : public SettingsPageUIHandler {
public:
explicit ChangePasswordHandler(
Profile* profile,
safe_browsing::ChromePasswordProtectionService* service);
~ChangePasswordHandler() override;
// settings::SettingsPageUIHandler:
void RegisterMessages() override;
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
private:
void HandleInitialize(const base::ListValue* args);
void HandleChangePassword(const base::ListValue* args);
void UpdateChangePasswordCardVisibility();
Profile* profile_;
PrefChangeRegistrar pref_registrar_;
safe_browsing::ChromePasswordProtectionService* service_;
DISALLOW_COPY_AND_ASSIGN(ChangePasswordHandler);
};
} // namespace settings
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHANGE_PASSWORD_HANDLER_H_
// Copyright 2017 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.
/** @implements {settings.ChangePasswordBrowserProxy} */
class TestChangePasswordBrowserProxy extends TestBrowserProxy {
constructor() {
super([
'changePassword',
]);
}
/** @override */
changePassword() {
this.methodCalled('changePassword');
}
}
suite('ChangePasswordHandler', function() {
let changePasswordPage = null;
/** @type {?TestChangePasswordBrowserProxy} */
let browserProxy = null;
setup(function() {
browserProxy = new TestChangePasswordBrowserProxy();
settings.ChangePasswordBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
changePasswordPage =
document.createElement('settings-change-password-page');
document.body.appendChild(changePasswordPage);
});
teardown(function() {
changePasswordPage.remove();
});
test('changePasswordButtonPressed', function() {
let actionButton = changePasswordPage.$$('#changePassword');
assertTrue(!!actionButton);
actionButton.click();
return browserProxy.whenCalled('changePassword');
});
});
...@@ -2407,30 +2407,6 @@ TEST_F('CrSettingsExtensionControlledIndicatorTest', 'All', function() { ...@@ -2407,30 +2407,6 @@ TEST_F('CrSettingsExtensionControlledIndicatorTest', 'All', function() {
mocha.run(); mocha.run();
}); });
/**
* @constructor
* @extends {CrSettingsBrowserTest}
*/
function CrSettingsChangePasswordPageTest() {}
CrSettingsChangePasswordPageTest.prototype = {
__proto__: CrSettingsBrowserTest.prototype,
/** @override */
browsePreload:
'chrome://settings/change_password_page/change_password_page.html',
/** @override */
extraLibraries: CrSettingsBrowserTest.prototype.extraLibraries.concat([
'../test_browser_proxy.js',
'change_password_page_test.js',
]),
};
TEST_F('CrSettingsChangePasswordPageTest', 'All', function() {
mocha.run();
});
/** /**
* @constructor * @constructor
* @extends {CrSettingsBrowserTest} * @extends {CrSettingsBrowserTest}
......
...@@ -349,25 +349,6 @@ cr.define('settings_main_page', function() { ...@@ -349,25 +349,6 @@ cr.define('settings_main_page', function() {
return assertPageVisibility('block', 'block'); return assertPageVisibility('block', 'block');
}); });
test('verify showChangePassword value', function() {
settings.navigateTo(settings.routes.BASIC);
Polymer.dom.flush();
const basicPage = settingsMain.$$('settings-basic-page');
assertTrue(!!basicPage);
assertFalse(basicPage.showChangePassword);
assertFalse(!!basicPage.$$('settings-change-password-page'));
cr.webUIListenerCallback('change-password-visibility', true);
Polymer.dom.flush();
assertTrue(basicPage.showChangePassword);
assertTrue(!!basicPage.$$('settings-change-password-page'));
cr.webUIListenerCallback('change-password-visibility', false);
Polymer.dom.flush();
assertFalse(basicPage.showChangePassword);
assertFalse(!!basicPage.$$('settings-change-password-page'));
});
test('updates the title based on current route', function() { test('updates the title based on current route', function() {
settings.navigateTo(settings.routes.BASIC); settings.navigateTo(settings.routes.BASIC);
assertEquals(document.title, loadTimeData.getString('settings')); assertEquals(document.title, loadTimeData.getString('settings'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment