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..06cf846d34cc247848309100413b6fc502e0e615 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" |
@@ -21,6 +22,10 @@ |
#include "extensions/browser/process_manager_factory.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() { |
@@ -39,21 +44,53 @@ ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() { |
} |
bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed( |
- content::BrowserContext* context) const { |
+ content::BrowserContext* context, |
+ const Extension* extension) const { |
Profile* profile = static_cast<Profile*>(context); |
bool is_normal_session = !profile->IsGuestSession() && |
emaxx
2017/03/06 17:04:03
As per offline discussion and as per previous iter
achuithb
2017/03/06 18:21:05
I've re-added the else statment. My objection to t
emaxx
2017/03/07 01:36:42
It's your call anyway, but in the end I think we b
achuithb
2017/03/07 14:17:39
I like this idea. It isolates our changes in this
|
!profile->IsSystemProfile(); |
+ bool allow_for_login_profile = false; |
+ |
#if defined(OS_CHROMEOS) |
- is_normal_session = is_normal_session && |
- user_manager::UserManager::Get()->IsUserLoggedIn(); |
+ is_normal_session = |
+ is_normal_session && user_manager::UserManager::Get()->IsUserLoggedIn(); |
+ |
+ const bool is_signin_profile = |
+ chromeos::ProfileHelper::IsSigninProfile(profile) && |
+ !profile->IsOffTheRecord(); |
+ |
+ if (is_signin_profile) { |
+ is_normal_session = false; |
+ |
+ // Check for flag. |
+ const bool login_screen_apps_enabled = |
emaxx
2017/03/06 17:04:03
I'm still feeling that this check here is excessiv
achuithb
2017/03/06 18:21:05
I prefer to keep this for the following reasons:
1
emaxx
2017/03/07 01:36:42
Acknowledged.
|
+ base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableLoginScreenApps); |
+ |
+ // Check that login screen apps are installed by policy. |
+ std::unique_ptr<base::DictionaryValue> login_screen_apps_list = |
+ ExtensionManagementFactory::GetForBrowserContext(context) |
+ ->GetForceInstallList(); |
+ const bool login_screen_apps_installed = !login_screen_apps_list->empty(); |
+ |
+ // Check match of extension id (if specified) with login screen app list. |
+ bool is_login_screen_app = true; |
+ if (login_screen_apps_installed && extension) |
+ is_login_screen_app = login_screen_apps_list->HasKey(extension->id()); |
emaxx
2017/03/06 17:04:04
nit: #include "extensions/common/extension.h"
achuithb
2017/03/06 18:21:05
Done.
|
+ |
+ allow_for_login_profile = login_screen_apps_enabled && |
+ login_screen_apps_installed && |
+ is_login_screen_app; |
+ } |
#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 |
// artificial and background page shouldn't be created in it. |
// http://crbug.com/329498 |
- return is_normal_session || profile->IsOffTheRecord(); |
+ return is_normal_session || profile->IsOffTheRecord() || |
+ allow_for_login_profile; |
} |
bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( |