Commit e8eed4d1 authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

Fix adding users to whitelist

-This change will resolve the whitelisted users list flickering when
 adding a new user after OOBE.

-The original CL(https://crrev.com/c/1786862) should not have
 included the call to GetUsersList. It was added because the tests
 failed which led me to believe it was needed for refreshing
 the user cache. In actuality the tests needed to be refactored to
 correct the failing tests.

Bug: 1011774
Change-Id: I9fd03a463bd8a6375cf806a22cacaed025904e4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940712Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720785}
parent 8acb659c
...@@ -197,9 +197,6 @@ ExtensionFunction::ResponseAction UsersPrivateIsWhitelistedUserFunction::Run() { ...@@ -197,9 +197,6 @@ ExtensionFunction::ResponseAction UsersPrivateIsWhitelistedUserFunction::Run() {
api::users_private::IsWhitelistedUser::Params::Create(*args_); api::users_private::IsWhitelistedUser::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get()); EXTENSION_FUNCTION_VALIDATE(parameters.get());
// GetUsersList called to clear the stale user name cache
GetUsersList(chrome_details_.GetProfile(), browser_context());
std::string username = gaia::CanonicalizeEmail(parameters->email); std::string username = gaia::CanonicalizeEmail(parameters->email);
if (IsExistingWhitelistedUser(username)) { if (IsExistingWhitelistedUser(username)) {
return RespondNow(OneArgument(std::make_unique<base::Value>(true))); return RespondNow(OneArgument(std::make_unique<base::Value>(true)));
......
...@@ -78,12 +78,22 @@ var availableTests = [ ...@@ -78,12 +78,22 @@ var availableTests = [
function(result) { function(result) {
callbackResult(result); callbackResult(result);
//Confirm kEmail2 was added to the list of users.
chrome.usersPrivate.getWhitelistedUsers(
function(users) {
chrome.test.assertTrue(users.length == 1);
chrome.test.assertEq(kEmail2, users[0].email);
chrome.test.assertEq(kName2, users[0].name);
chrome.test.succeed();
});
// We never added kEmail1 so this should return false. // We never added kEmail1 so this should return false.
chrome.usersPrivate.isWhitelistedUser( chrome.usersPrivate.isWhitelistedUser(
kEmail1, kEmail1,
function(result) { function(result) {
chrome.test.assertFalse(result); chrome.test.assertFalse(result);
// We did add kEmail2 so this should return true.
chrome.usersPrivate.isWhitelistedUser( chrome.usersPrivate.isWhitelistedUser(
kEmail2, kEmail2,
function(user) { function(user) {
......
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