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

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: Devlin comments 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"
23 #include "extensions/common/extension.h"
22 #include "extensions/common/one_shot_event.h" 24 #include "extensions/common/one_shot_event.h"
23 25
26 #if defined(OS_CHROMEOS)
27 #include "chrome/browser/chromeos/profiles/profile_helper.h"
28 #endif
29
24 namespace extensions { 30 namespace extensions {
25 31
26 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() { 32 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() {
27 registrar_.Add(this, 33 registrar_.Add(this,
28 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 34 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
29 content::NotificationService::AllSources()); 35 content::NotificationService::AllSources());
30 registrar_.Add(this, 36 registrar_.Add(this,
31 chrome::NOTIFICATION_PROFILE_CREATED, 37 chrome::NOTIFICATION_PROFILE_CREATED,
32 content::NotificationService::AllSources()); 38 content::NotificationService::AllSources());
33 registrar_.Add(this, 39 registrar_.Add(this,
34 chrome::NOTIFICATION_PROFILE_DESTROYED, 40 chrome::NOTIFICATION_PROFILE_DESTROYED,
35 content::NotificationService::AllSources()); 41 content::NotificationService::AllSources());
36 } 42 }
37 43
38 ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() { 44 ChromeProcessManagerDelegate::~ChromeProcessManagerDelegate() {
39 } 45 }
40 46
41 bool ChromeProcessManagerDelegate::IsBackgroundPageAllowed( 47 bool ChromeProcessManagerDelegate::AreBackgroundPagesAllowedForContext(
42 content::BrowserContext* context) const { 48 content::BrowserContext* context) const {
43 Profile* profile = static_cast<Profile*>(context); 49 Profile* profile = Profile::FromBrowserContext(context);
44 50
45 bool is_normal_session = !profile->IsGuestSession() && 51 bool is_normal_session = !profile->IsGuestSession() &&
46 !profile->IsSystemProfile(); 52 !profile->IsSystemProfile();
47 #if defined(OS_CHROMEOS)
48 is_normal_session = is_normal_session &&
49 user_manager::UserManager::Get()->IsUserLoggedIn();
50 #endif
51 53
52 // Disallow if the current session is a Guest mode session or login screen but 54 // 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 55 // the current browser context is *not* off-the-record. Such context is
54 // artificial and background page shouldn't be created in it. 56 // artificial and background page shouldn't be created in it.
55 // http://crbug.com/329498 57 // http://crbug.com/329498
56 return is_normal_session || profile->IsOffTheRecord(); 58 return is_normal_session || profile->IsOffTheRecord();
57 } 59 }
58 60
61 bool ChromeProcessManagerDelegate::IsExtensionBackgroundPageAllowed(
62 content::BrowserContext* context,
63 const Extension& extension) const {
64 #if defined(OS_CHROMEOS)
65 Profile* profile = Profile::FromBrowserContext(context);
66
67 const bool is_signin_profile =
68 chromeos::ProfileHelper::IsSigninProfile(profile) &&
69 !profile->IsOffTheRecord();
70
71 if (is_signin_profile) {
72 // Check for flag.
73 const bool login_screen_apps_enabled =
74 base::CommandLine::ForCurrentProcess()->HasSwitch(
75 switches::kEnableLoginScreenApps);
Mr4D (OOO till 08-26) 2017/03/23 14:38:37 You might consider to early out here if false.
achuithb 2017/03/23 17:55:50 Done.
76
77 // Get login screen apps installed by policy.
78 std::unique_ptr<base::DictionaryValue> login_screen_apps_list =
79 ExtensionManagementFactory::GetForBrowserContext(context)
80 ->GetForceInstallList();
81
82 // For the ChromeOS login profile, only allow apps installed by device
83 // policy.
84 return login_screen_apps_enabled &&
85 login_screen_apps_list->HasKey(extension.id());
86 }
87 #endif
88
89 return AreBackgroundPagesAllowedForContext(context);
90 }
91
59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( 92 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts(
60 content::BrowserContext* context) const { 93 content::BrowserContext* context) const {
61 Profile* profile = static_cast<Profile*>(context); 94 Profile* profile = Profile::FromBrowserContext(context);
62 95
63 // The profile may not be valid yet if it is still being initialized. 96 // 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. 97 // In that case, defer loading, since it depends on an initialized profile.
65 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED. 98 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED.
66 // http://crbug.com/222473 99 // http://crbug.com/222473
67 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 100 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
68 return true; 101 return true;
69 102
70 // There are no browser windows open and the browser process was 103 // There are no browser windows open and the browser process was
71 // started to show the app launcher. Background hosts will be loaded later 104 // started to show the app launcher. Background hosts will be loaded later
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ProcessManager* incognito_manager = 197 ProcessManager* incognito_manager =
165 ProcessManagerFactory::GetForBrowserContextIfExists( 198 ProcessManagerFactory::GetForBrowserContextIfExists(
166 profile->GetOffTheRecordProfile()); 199 profile->GetOffTheRecordProfile());
167 if (incognito_manager) { 200 if (incognito_manager) {
168 incognito_manager->CloseBackgroundHosts(); 201 incognito_manager->CloseBackgroundHosts();
169 } 202 }
170 } 203 }
171 } 204 }
172 205
173 } // namespace extensions 206 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/chrome_process_manager_delegate.h ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698