Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: chrome/browser/extensions/chrome_process_manager_delegate.cc

Issue 2149953002: Enable login screen apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittest Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/chrome_process_manager_delegate.cc
diff --git a/chrome/browser/extensions/chrome_process_manager_delegate.cc b/chrome/browser/extensions/chrome_process_manager_delegate.cc
index e5804aab7c89b436ade61cc18225ba081b7f3229..6cd6097b76f7a1b43d91e153855d571aca21adbb 100644
--- a/chrome/browser/extensions/chrome_process_manager_delegate.cc
+++ b/chrome/browser/extensions/chrome_process_manager_delegate.cc
@@ -9,6 +9,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
@@ -19,8 +20,13 @@
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_manager_factory.h"
+#include "extensions/common/extension.h"
#include "extensions/common/one_shot_event.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#endif
+
namespace extensions {
ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() {
@@ -38,16 +44,12 @@ ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() {
ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() {
}
-bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed(
+bool ChromeProcessManagerDelegate::AreBackgroundPagesAllowedForContext(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
bool is_normal_session = !profile->IsGuestSession() &&
!profile->IsSystemProfile();
-#if defined(OS_CHROMEOS)
- is_normal_session = is_normal_session &&
- user_manager::UserManager::Get()->IsUserLoggedIn();
-#endif
// Disallow if the current session is a Guest mode session or login screen but
// the current browser context is *not* off-the-record. Such context is
@@ -56,6 +58,39 @@ bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed(
return is_normal_session || profile->IsOffTheRecord();
}
+bool ChromeProcessManagerDelegate::IsExtensionBackgroundPageAllowed(
+ content::BrowserContext* context,
+ const Extension* extension) const {
+ DCHECK(extension);
+
+#if defined(OS_CHROMEOS)
+ Profile* profile = static_cast<Profile*>(context);
Devlin 2017/03/22 22:57:39 nitty nit: slightly prefer Profile::FromBrowserCon
achuithb 2017/03/23 00:26:26 Done for this function and the other 2 delegate fu
+
+ const bool is_signin_profile =
+ chromeos::ProfileHelper::IsSigninProfile(profile) &&
+ !profile->IsOffTheRecord();
+
+ if (is_signin_profile) {
+ // Check for flag.
+ const bool login_screen_apps_enabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableLoginScreenApps);
+
+ // Get login screen apps installed by policy.
+ std::unique_ptr<base::DictionaryValue> login_screen_apps_list =
+ ExtensionManagementFactory::GetForBrowserContext(context)
+ ->GetForceInstallList();
+
+ // For the ChromeOS login profile, only allow apps installed by device
+ // policy.
+ return login_screen_apps_enabled &&
+ login_screen_apps_list->HasKey(extension->id());
+ }
+#endif
+
+ return AreBackgroundPagesAllowedForContext(context);
+}
+
bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);

Powered by Google App Engine
This is Rietveld 408576698