OLD | NEW |
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/extensions/extension_management.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "components/user_manager/user_manager.h" | 18 #include "components/user_manager/user_manager.h" |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
21 #include "extensions/browser/process_manager.h" | 21 #include "extensions/browser/process_manager.h" |
22 #include "extensions/browser/process_manager_factory.h" | 22 #include "extensions/browser/process_manager_factory.h" |
23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 #include "extensions/common/one_shot_event.h" | 24 #include "extensions/common/one_shot_event.h" |
| 25 #include "extensions/common/permissions/permissions_data.h" |
25 | 26 |
26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
27 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 29 #include "chromeos/chromeos_switches.h" |
28 #endif | 30 #endif |
29 | 31 |
30 namespace extensions { | 32 namespace extensions { |
31 | 33 |
32 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() { | 34 ChromeProcessManagerDelegate::ChromeProcessManagerDelegate() { |
33 registrar_.Add(this, | 35 registrar_.Add(this, |
34 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 36 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
35 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
36 registrar_.Add(this, | 38 registrar_.Add(this, |
37 chrome::NOTIFICATION_PROFILE_CREATED, | 39 chrome::NOTIFICATION_PROFILE_CREATED, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 79 |
78 // Get login screen apps installed by policy. | 80 // Get login screen apps installed by policy. |
79 std::unique_ptr<base::DictionaryValue> login_screen_apps_list = | 81 std::unique_ptr<base::DictionaryValue> login_screen_apps_list = |
80 ExtensionManagementFactory::GetForBrowserContext(context) | 82 ExtensionManagementFactory::GetForBrowserContext(context) |
81 ->GetForceInstallList(); | 83 ->GetForceInstallList(); |
82 | 84 |
83 // For the ChromeOS login profile, only allow apps installed by device | 85 // For the ChromeOS login profile, only allow apps installed by device |
84 // policy. | 86 // policy. |
85 return login_screen_apps_list->HasKey(extension.id()); | 87 return login_screen_apps_list->HasKey(extension.id()); |
86 } | 88 } |
| 89 |
| 90 if (chromeos::ProfileHelper::IsLockScreenAppProfile(profile) && |
| 91 !profile->IsOffTheRecord()) { |
| 92 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 93 chromeos::switches::kEnableLockScreenApps) && |
| 94 extension.permissions_data()->HasAPIPermission( |
| 95 APIPermission::kLockScreen); |
| 96 } |
87 #endif | 97 #endif |
88 | 98 |
89 return AreBackgroundPagesAllowedForContext(context); | 99 return AreBackgroundPagesAllowedForContext(context); |
90 } | 100 } |
91 | 101 |
92 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( | 102 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( |
93 content::BrowserContext* context) const { | 103 content::BrowserContext* context) const { |
94 Profile* profile = Profile::FromBrowserContext(context); | 104 Profile* profile = Profile::FromBrowserContext(context); |
95 | 105 |
96 // The profile may not be valid yet if it is still being initialized. | 106 // The profile may not be valid yet if it is still being initialized. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 ProcessManager* incognito_manager = | 207 ProcessManager* incognito_manager = |
198 ProcessManagerFactory::GetForBrowserContextIfExists( | 208 ProcessManagerFactory::GetForBrowserContextIfExists( |
199 profile->GetOffTheRecordProfile()); | 209 profile->GetOffTheRecordProfile()); |
200 if (incognito_manager) { | 210 if (incognito_manager) { |
201 incognito_manager->CloseBackgroundHosts(); | 211 incognito_manager->CloseBackgroundHosts(); |
202 } | 212 } |
203 } | 213 } |
204 } | 214 } |
205 | 215 |
206 } // namespace extensions | 216 } // namespace extensions |
OLD | NEW |