Commit 25151c34 authored by wutao's avatar wutao Committed by Commit Bot

cros: Use guest profile in AppListSyncableService

In guest session, we use two different profiles for "Suggested App" and
apps in Launcher. The later uses the profile of AppListSyncableService
which alwasy uses the original profile. However, the original profile is
not allowed in guest session.

This cl fixes this bug by returning guest profile in
AppListSyncableService in guest mode.

Bug: 840293
Test: manual.
Change-Id: I30d9464597eaacba9a08560ca03e0679a9e906bf
Reviewed-on: https://chromium-review.googlesource.com/1049005
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557014}
parent 0ddf8b24
...@@ -903,6 +903,13 @@ syncer::SyncError AppListSyncableService::ProcessSyncChanges( ...@@ -903,6 +903,13 @@ syncer::SyncError AppListSyncableService::ProcessSyncChanges(
return syncer::SyncError(); return syncer::SyncError();
} }
void AppListSyncableService::Shutdown() {
internal_apps_builder_.reset();
crostini_apps_builder_.reset();
arc_apps_builder_.reset();
apps_builder_.reset();
}
// AppListSyncableService private // AppListSyncableService private
bool AppListSyncableService::ProcessSyncItemSpecifics( bool AppListSyncableService::ProcessSyncItemSpecifics(
......
...@@ -162,6 +162,9 @@ class AppListSyncableService : public syncer::SyncableService, ...@@ -162,6 +162,9 @@ class AppListSyncableService : public syncer::SyncableService,
const base::Location& from_here, const base::Location& from_here,
const syncer::SyncChangeList& change_list) override; const syncer::SyncChangeList& change_list) override;
// KeyedService
void Shutdown() override;
private: private:
class ModelUpdaterDelegate; class ModelUpdaterDelegate;
......
...@@ -86,6 +86,19 @@ void AppListSyncableServiceFactory::RegisterProfilePrefs( ...@@ -86,6 +86,19 @@ void AppListSyncableServiceFactory::RegisterProfilePrefs(
content::BrowserContext* AppListSyncableServiceFactory::GetBrowserContextToUse( content::BrowserContext* AppListSyncableServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const { content::BrowserContext* context) const {
Profile* const profile = Profile::FromBrowserContext(context);
// No service if |context| is not a profile.
if (!profile)
return nullptr;
// No service for system profile.
if (profile->IsSystemProfile())
return nullptr;
// Use profile as-is for guest session.
if (profile->IsGuestSession())
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
// This matches the logic in ExtensionSyncServiceFactory, which uses the // This matches the logic in ExtensionSyncServiceFactory, which uses the
// orginal browser context. // orginal browser context.
return chrome::GetBrowserContextRedirectedInIncognito(context); return chrome::GetBrowserContextRedirectedInIncognito(context);
......
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