Commit 5f986e03 authored by mahmadi's avatar mahmadi Committed by Commit bot

Updates the list of signed-in profiles in user manager on ProfileAuthInfoChanged

BUG=627072

Review-Url: https://codereview.chromium.org/2163173004
Cr-Commit-Position: refs/heads/master@{#406983}
parent 3d7d4156
......@@ -55,13 +55,18 @@
SigninCreateProfileHandler::SigninCreateProfileHandler()
: profile_creation_type_(NO_CREATION_IN_PROGRESS),
weak_ptr_factory_(this) {}
weak_ptr_factory_(this) {
g_browser_process->profile_manager()->
GetProfileAttributesStorage().AddObserver(this);
}
SigninCreateProfileHandler::~SigninCreateProfileHandler() {
#if defined(ENABLE_SUPERVISED_USERS)
// Cancellation is only supported for supervised users.
CancelProfileRegistration(false);
#endif
g_browser_process->profile_manager()->
GetProfileAttributesStorage().RemoveObserver(this);
}
void SigninCreateProfileHandler::GetLocalizedValues(
......@@ -214,6 +219,11 @@ void SigninCreateProfileHandler::RequestSignedInProfiles(
user_info_list);
}
void SigninCreateProfileHandler::OnProfileAuthInfoChanged(
const base::FilePath& profile_path) {
RequestSignedInProfiles(nullptr);
}
void SigninCreateProfileHandler::CreateProfile(const base::ListValue* args) {
if (!profiles::IsMultipleProfilesEnabled())
return;
......
......@@ -11,6 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_window.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
......@@ -28,7 +29,8 @@ class SupervisedUserRegistrationUtility;
// Handler for the 'create profile' page.
class SigninCreateProfileHandler : public content::WebUIMessageHandler,
public content::NotificationObserver {
public content::NotificationObserver,
public ProfileAttributesStorage::Observer {
public:
SigninCreateProfileHandler();
~SigninCreateProfileHandler() override;
......@@ -65,6 +67,9 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// ProfileAttributesStorage::Observer implementation:
void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override;
// Represents the final profile creation status. It is used to map
// the status to the javascript method to be called.
enum ProfileCreationStatus {
......
......@@ -228,8 +228,8 @@ class SigninCreateProfileHandlerTest : public BrowserWithTestWindowTest {
}
void TearDown() override {
profile_manager_.reset();
handler_.reset();
profile_manager_.reset();
BrowserWithTestWindowTest::TearDown();
}
......@@ -305,10 +305,6 @@ TEST_F(SigninCreateProfileHandlerTest, ReturnSignedInProfiles) {
GetProfileAttributesWithPath(profile_2->GetPath(), &entry));
entry->SetAuthInfo(kTestGaiaId2, base::UTF8ToUTF16(kTestEmail2));
// Request a list of signed in profiles.
base::ListValue list_args;
handler()->RequestSignedInProfiles(&list_args);
// Expect a JS callback with a list containing profile_2.
EXPECT_EQ(1U, web_ui()->call_data().size());
......
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