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

Side by Side 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 is_normal_session logic 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/chrome_process_manager_delegate.h" 5 #include "chrome/browser/extensions/chrome_process_manager_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/extension_management.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_finder.h" 16 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "components/user_manager/user_manager.h" 18 #include "components/user_manager/user_manager.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
21 #include "extensions/browser/process_manager_factory.h" 22 #include "extensions/browser/process_manager_factory.h"
22 #include "extensions/common/one_shot_event.h" 23 #include "extensions/common/one_shot_event.h"
23 24
25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/profiles/profile_helper.h"
27 #endif
28
24 namespace extensions { 29 namespace extensions {
25 30
26 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() { 31 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() {
27 registrar_.Add(this, 32 registrar_.Add(this,
28 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 33 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
29 content::NotificationService::AllSources()); 34 content::NotificationService::AllSources());
30 registrar_.Add(this, 35 registrar_.Add(this,
31 chrome::NOTIFICATION_PROFILE_CREATED, 36 chrome::NOTIFICATION_PROFILE_CREATED,
32 content::NotificationService::AllSources()); 37 content::NotificationService::AllSources());
33 registrar_.Add(this, 38 registrar_.Add(this,
34 chrome::NOTIFICATION_PROFILE_DESTROYED, 39 chrome::NOTIFICATION_PROFILE_DESTROYED,
35 content::NotificationService::AllSources()); 40 content::NotificationService::AllSources());
36 } 41 }
37 42
38 ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() { 43 ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() {
39 } 44 }
40 45
41 bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed( 46 bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed(
42 content::BrowserContext* context) const { 47 content::BrowserContext* context,
48 const Extension* extension) const {
43 Profile* profile = static_cast<Profile*>(context); 49 Profile* profile = static_cast<Profile*>(context);
44 50
45 bool is_normal_session = !profile->IsGuestSession() && 51 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
46 !profile->IsSystemProfile(); 52 !profile->IsSystemProfile();
53 bool allow_for_login_profile = false;
54
47 #if defined(OS_CHROMEOS) 55 #if defined(OS_CHROMEOS)
48 is_normal_session = is_normal_session && 56 is_normal_session =
49 user_manager::UserManager::Get()->IsUserLoggedIn(); 57 is_normal_session && user_manager::UserManager::Get()->IsUserLoggedIn();
58
59 const bool is_signin_profile =
60 chromeos::ProfileHelper::IsSigninProfile(profile) &&
61 !profile->IsOffTheRecord();
62
63 if (is_signin_profile) {
64 is_normal_session = false;
65
66 // Check for flag.
67 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.
68 base::CommandLine::ForCurrentProcess()->HasSwitch(
69 switches::kEnableLoginScreenApps);
70
71 // Check that login screen apps are installed by policy.
72 std::unique_ptr<base::DictionaryValue> login_screen_apps_list =
73 ExtensionManagementFactory::GetForBrowserContext(context)
74 ->GetForceInstallList();
75 const bool login_screen_apps_installed = !login_screen_apps_list->empty();
76
77 // Check match of extension id (if specified) with login screen app list.
78 bool is_login_screen_app = true;
79 if (login_screen_apps_installed && extension)
80 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.
81
82 allow_for_login_profile = login_screen_apps_enabled &&
83 login_screen_apps_installed &&
84 is_login_screen_app;
85 }
50 #endif 86 #endif
51 87
52 // Disallow if the current session is a Guest mode session or login screen but 88 // Disallow if the current session is a Guest mode session or login screen but
53 // the current browser context is *not* off-the-record. Such context is 89 // the current browser context is *not* off-the-record. Such context is
54 // artificial and background page shouldn't be created in it. 90 // artificial and background page shouldn't be created in it.
55 // http://crbug.com/329498 91 // http://crbug.com/329498
56 return is_normal_session || profile->IsOffTheRecord(); 92 return is_normal_session || profile->IsOffTheRecord() ||
93 allow_for_login_profile;
57 } 94 }
58 95
59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( 96 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts(
60 content::BrowserContext* context) const { 97 content::BrowserContext* context) const {
61 Profile* profile = static_cast<Profile*>(context); 98 Profile* profile = static_cast<Profile*>(context);
62 99
63 // The profile may not be valid yet if it is still being initialized. 100 // The profile may not be valid yet if it is still being initialized.
64 // In that case, defer loading, since it depends on an initialized profile. 101 // In that case, defer loading, since it depends on an initialized profile.
65 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED. 102 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED.
66 // http://crbug.com/222473 103 // http://crbug.com/222473
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ProcessManager* incognito_manager = 201 ProcessManager* incognito_manager =
165 ProcessManagerFactory::GetForBrowserContextIfExists( 202 ProcessManagerFactory::GetForBrowserContextIfExists(
166 profile->GetOffTheRecordProfile()); 203 profile->GetOffTheRecordProfile());
167 if (incognito_manager) { 204 if (incognito_manager) {
168 incognito_manager->CloseBackgroundHosts(); 205 incognito_manager->CloseBackgroundHosts();
169 } 206 }
170 } 207 }
171 } 208 }
172 209
173 } // namespace extensions 210 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698