Index: chrome/browser/extensions/extension_service.cc |
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
index 865438513dd39f0ea0d461506492a3c0736b8112..37045a0e3d52f5acdd4ef9c84c5a5e145c7c06c5 100644 |
--- a/chrome/browser/extensions/extension_service.cc |
+++ b/chrome/browser/extensions/extension_service.cc |
@@ -352,6 +352,19 @@ ExtensionService::ExtensionService(Profile* profile, |
registrar_.Add(this, |
chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
content::Source<Profile>(profile_)); |
+#if defined(OS_CHROMEOS) |
+ // Sign in profile extension service should observe session start - when the |
+ // session is started, the context's process map should be updated to consider |
+ // extension scripts to run in lock screen context (as the sign-in profile |
+ // will be used to host lock screen apps from that point). |
+ // TODO(tbarzic): Consider introducing a profile dedicated to lock screen apps |
+ // so the process map's 'is lock screen context' flag does not have to be |
+ // changed when the user session starts. |
+ if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { |
+ registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, |
+ content::NotificationService::AllSources()); |
+ } |
+#endif |
extensions::ExtensionManagementFactory::GetForBrowserContext(profile_) |
->AddObserver(this); |
@@ -2258,6 +2271,20 @@ void ExtensionService::Observe(int type, |
OnProfileDestructionStarted(); |
break; |
} |
+#if defined(OS_CHROMEOS) |
+ case chrome::NOTIFICATION_SESSION_STARTED: { |
+ DCHECK(chromeos::ProfileHelper::IsSigninProfile(profile_)); |
+ |
+ // When the user session starts, mark the signin context as lock screen |
+ // context, as it will be used to host apps on lock screen. |
+ extensions::ProcessMap::Get(profile_)->set_is_lock_screen_context(true); |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::BindOnce(&extensions::InfoMap::SetIsLockScreenContext, |
+ system_->info_map(), true)); |
+ break; |
+ } |
+#endif |
default: |
NOTREACHED() << "Unexpected notification type."; |