Commit b373cba5 authored by khmel@google.com's avatar khmel@google.com Committed by Commit Bot

app_launcher: Update list of apps on Active User change.

Test: Manually
Bug: 836266
Change-Id: I90ffbc6222d0af85c307eda29974156e9ff314bd
Reviewed-on: https://chromium-review.googlesource.com/1043485Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556099}
parent 11b87f51
......@@ -49,9 +49,13 @@ AppListClientImpl::AppListClientImpl()
AppListServiceImpl::GetInstance()->SetAppListControllerAndClient(
app_list_controller_.get(), this);
user_manager::UserManager::Get()->AddSessionStateObserver(this);
}
AppListClientImpl::~AppListClientImpl() = default;
AppListClientImpl::~AppListClientImpl() {
user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
}
void AppListClientImpl::StartSearch(const base::string16& raw_query) {
if (search_controller_) {
......@@ -188,6 +192,13 @@ void AppListClientImpl::OnItemUpdated(ash::mojom::AppListItemMetadataPtr item) {
model_updater_->OnItemUpdated(std::move(item));
}
void AppListClientImpl::ActiveUserChanged(
const user_manager::User* active_user) {
if (!active_user->is_profile_created())
return;
UpdateProfile();
}
void AppListClientImpl::UpdateProfile() {
Profile* profile = ProfileManager::GetActiveUserProfile();
app_list::AppListSyncableService* syncable_service =
......@@ -223,12 +234,12 @@ void AppListClientImpl::SetProfile(Profile* new_profile) {
DCHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord())
<< "Guest mode must use incognito profile";
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile_);
template_url_service_observer_.Add(template_url_service);
template_url_service_observer_.Add(
TemplateURLServiceFactory::GetForProfile(profile_));
app_list::AppListSyncableService* syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile_);
model_updater_ = syncable_service->GetModelUpdater();
model_updater_->SetActive(true);
......
......@@ -17,6 +17,7 @@
#include "base/scoped_observer.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_observer.h"
#include "components/user_manager/user_manager.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -30,8 +31,10 @@ class AppListModelUpdater;
class AppSyncUIStateWatcher;
class Profile;
class AppListClientImpl : public ash::mojom::AppListClient,
public TemplateURLServiceObserver {
class AppListClientImpl
: public ash::mojom::AppListClient,
public user_manager::UserManager::UserSessionStateObserver,
public TemplateURLServiceObserver {
public:
AppListClientImpl();
~AppListClientImpl() override;
......@@ -63,8 +66,11 @@ class AppListClientImpl : public ash::mojom::AppListClient,
void OnFolderDeleted(ash::mojom::AppListItemMetadataPtr item) override;
void OnItemUpdated(ash::mojom::AppListItemMetadataPtr item) override;
// user_manager::UserManager::UserSessionStateObserver:
void ActiveUserChanged(const user_manager::User* active_user) override;
// Associates this client with the current active user, called when this
// client is accessed.
// client is accessed or active user is changed.
void UpdateProfile();
void set_controller_delegate(AppListControllerDelegate* controller_delegate) {
......
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