Commit c9094c99 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Smart Lock: Remove EasyUnlockBrowserProxy.

The get*Enabled method is no longer called in release.

R=hansberry@chromium.org

Bug: 899324
Test: none
Change-Id: I91261c61ae5f666cf45c14e6c71512f3a7c70a42
Reviewed-on: https://chromium-review.googlesource.com/c/1312094Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604631}
parent 56d152ff
......@@ -10,7 +10,6 @@ js_type_check("closure_compile") {
":account_manager_browser_proxy",
":change_picture",
":change_picture_browser_proxy",
":easy_unlock_browser_proxy",
":fingerprint_browser_proxy",
":fingerprint_list",
":import_data_browser_proxy",
......@@ -71,12 +70,6 @@ js_library("change_picture_browser_proxy") {
]
}
js_library("easy_unlock_browser_proxy") {
deps = [
"//ui/webui/resources/js:cr",
]
}
js_library("fingerprint_browser_proxy") {
deps = [
"//ui/webui/resources/js:cr",
......@@ -106,7 +99,6 @@ js_library("import_data_browser_proxy") {
js_library("lock_screen") {
deps = [
":easy_unlock_browser_proxy",
":fingerprint_browser_proxy",
":lock_screen_password_prompt_dialog",
":lock_state_behavior",
......
// 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.
/**
* @fileoverview A helper object used from the the People section to interact
* with the Easy Unlock functionality of the browser. ChromeOS only.
*/
cr.exportPath('settings');
cr.define('settings', function() {
/** @interface */
class EasyUnlockBrowserProxy {
/**
* Returns a true promise if Easy Unlock is already enabled on the device.
* @return {!Promise<boolean>}
*/
getEnabledStatus() {}
}
/**
* @implements {settings.EasyUnlockBrowserProxy}
*/
class EasyUnlockBrowserProxyImpl {
/** @override */
getEnabledStatus() {
return cr.sendWithPromise('easyUnlockGetEnabledStatus');
}
}
// The singleton instance_ is replaced with a test version of this wrapper
// during testing.
cr.addSingletonGetter(EasyUnlockBrowserProxyImpl);
return {
EasyUnlockBrowserProxy: EasyUnlockBrowserProxy,
EasyUnlockBrowserProxyImpl: EasyUnlockBrowserProxyImpl,
};
});
......@@ -9,7 +9,6 @@
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="easy_unlock_browser_proxy.html">
<link rel="import" href="fingerprint_browser_proxy.html">
<link rel="import" href="lock_state_behavior.html">
<link rel="import" href="lock_screen_password_prompt_dialog.html">
......
......@@ -220,9 +220,6 @@ Polymer({
showSetupPinDialog_: Boolean,
},
/** @private {?settings.EasyUnlockBrowserProxy} */
easyUnlockBrowserProxy_: null,
/** @private {?settings.FingerprintBrowserProxy} */
fingerprintBrowserProxy_: null,
......@@ -234,8 +231,6 @@ Polymer({
if (this.shouldAskForPassword_(settings.getCurrentRoute()))
this.openPasswordPromptDialog_();
this.easyUnlockBrowserProxy_ =
settings.EasyUnlockBrowserProxyImpl.getInstance();
this.fingerprintBrowserProxy_ =
settings.FingerprintBrowserProxyImpl.getInstance();
this.updateNumFingerprints_();
......@@ -244,8 +239,6 @@ Polymer({
this.addWebUIListener(
'easy-unlock-enabled-status',
this.handleEasyUnlockEnabledStatusChanged_.bind(this));
this.easyUnlockBrowserProxy_.getEnabledStatus().then(
this.handleEasyUnlockEnabledStatusChanged_.bind(this));
}
},
......
......@@ -1455,14 +1455,6 @@
type="chrome_html"
preprocess="true"
allowexternalscript="true" />
<structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_BROWSER_PROXY_JS"
file="people_page/easy_unlock_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_BROWSER_PROXY_HTML"
file="people_page/easy_unlock_browser_proxy.html"
type="chrome_html"
preprocess="true"
allowexternalscript="true" />
<structure name="IDR_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_PROMPT_DIALOG_JS"
file="people_page/lock_screen_password_prompt_dialog.js"
type="chrome_html" />
......
......@@ -49,12 +49,7 @@ EasyUnlockSettingsHandler* EasyUnlockSettingsHandler::Create(
return new EasyUnlockSettingsHandler(profile);
}
void EasyUnlockSettingsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"easyUnlockGetEnabledStatus",
base::BindRepeating(&EasyUnlockSettingsHandler::HandleGetEnabledStatus,
base::Unretained(this)));
}
void EasyUnlockSettingsHandler::RegisterMessages() {}
void EasyUnlockSettingsHandler::OnJavascriptAllowed() {
profile_pref_registrar_.Add(
......@@ -73,16 +68,5 @@ void EasyUnlockSettingsHandler::SendEnabledStatus() {
base::Value(EasyUnlockService::Get(profile_)->IsEnabled()));
}
void EasyUnlockSettingsHandler::HandleGetEnabledStatus(
const base::ListValue* args) {
AllowJavascript();
CHECK_EQ(1U, args->GetSize());
const base::Value* callback_id;
CHECK(args->Get(0, &callback_id));
ResolveJavascriptCallback(
*callback_id, base::Value(EasyUnlockService::Get(profile_)->IsEnabled()));
}
} // namespace settings
} // namespace chromeos
......@@ -40,9 +40,6 @@ class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler {
void SendEnabledStatus();
// JS callbacks.
void HandleGetEnabledStatus(const base::ListValue* args);
Profile* const profile_;
PrefChangeRegistrar profile_pref_registrar_;
......
......@@ -151,37 +151,5 @@ TEST_F(EasyUnlockSettingsHandlerTest, NotCreatedWhenEasyUnlockServiceNull) {
EXPECT_FALSE(handler.get());
}
TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) {
std::unique_ptr<EasyUnlockSettingsHandler> handler;
handler.reset(new TestEasyUnlockSettingsHandler(profile()));
handler->set_web_ui(web_ui());
// Test the JS -> C++ -> JS callback path.
base::ListValue list_args;
list_args.AppendString("test-callback-id");
handler->HandleGetEnabledStatus(&list_args);
EXPECT_EQ(1U, web_ui()->call_data().size());
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
std::string callback_id;
ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
EXPECT_EQ("test-callback-id", callback_id);
bool enabled_status = false;
ASSERT_TRUE(data.arg3()->GetAsBoolean(&enabled_status));
EXPECT_FALSE(enabled_status);
// Test the C++ -> JS push path.
handler->SendEnabledStatus();
VerifyEnabledStatusCallback(2U, false);
fake_easy_unlock_service()->set_is_enabled(true);
handler->SendEnabledStatus();
VerifyEnabledStatusCallback(3U, true);
}
} // namespace settings
} // namespace chromeos
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