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/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::IsBackgroundPageAllowed( |
42 content::BrowserContext* context) const { | 48 content::BrowserContext* context, |
49 const Extension* extension) const { | |
43 Profile* profile = static_cast<Profile*>(context); | 50 Profile* profile = static_cast<Profile*>(context); |
44 | 51 |
45 bool is_normal_session = !profile->IsGuestSession() && | 52 bool is_normal_session = !profile->IsGuestSession() && |
46 !profile->IsSystemProfile(); | 53 !profile->IsSystemProfile(); |
54 | |
47 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
48 is_normal_session = is_normal_session && | 56 const bool is_signin_profile = |
49 user_manager::UserManager::Get()->IsUserLoggedIn(); | 57 chromeos::ProfileHelper::IsSigninProfile(profile) && |
58 !profile->IsOffTheRecord(); | |
59 | |
60 if (is_signin_profile) { | |
61 // If an extension is specified, allow background pages only if that | |
62 // extension is in the login screen app list. Otherwise allow | |
63 // background pages. | |
64 bool is_login_screen_app = true; | |
65 if (extension) { | |
emaxx
2017/03/08 17:11:25
Maybe reduce the nested level here by inverting th
Devlin
2017/03/08 17:24:32
When can |extension| be null?
achuithb
2017/03/09 14:31:05
Done.
achuithb
2017/03/09 14:31:05
I'll add a comment to the line where it's null
| |
66 // Check for flag. | |
67 const bool login_screen_apps_enabled = | |
68 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
69 switches::kEnableLoginScreenApps); | |
70 | |
71 // Get login screen apps installed by policy. | |
72 std::unique_ptr<base::DictionaryValue> login_screen_apps_list = | |
73 ExtensionManagementFactory::GetForBrowserContext(context) | |
74 ->GetForceInstallList(); | |
75 | |
76 is_login_screen_app = login_screen_apps_enabled && | |
77 login_screen_apps_list->HasKey(extension->id()); | |
Devlin
2017/03/08 17:24:32
I would expect CreateBackgroundHost() to only be c
achuithb
2017/03/09 14:31:05
I don't entirely follow your question.
We're act
Devlin
2017/03/13 19:39:35
To rephrase my question: If this is the signin pro
achuithb
2017/03/15 00:40:25
Component extensions are loaded into the signin pr
| |
78 } | |
79 | |
80 return is_login_screen_app; | |
81 } | |
82 | |
83 is_normal_session = | |
84 is_normal_session && user_manager::UserManager::Get()->IsUserLoggedIn(); | |
50 #endif | 85 #endif |
51 | 86 |
52 // Disallow if the current session is a Guest mode session or login screen but | 87 // 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 | 88 // the current browser context is *not* off-the-record. Such context is |
54 // artificial and background page shouldn't be created in it. | 89 // artificial and background page shouldn't be created in it. |
55 // http://crbug.com/329498 | 90 // http://crbug.com/329498 |
56 return is_normal_session || profile->IsOffTheRecord(); | 91 return is_normal_session || profile->IsOffTheRecord(); |
57 } | 92 } |
58 | 93 |
59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( | 94 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 ProcessManager* incognito_manager = | 199 ProcessManager* incognito_manager = |
165 ProcessManagerFactory::GetForBrowserContextIfExists( | 200 ProcessManagerFactory::GetForBrowserContextIfExists( |
166 profile->GetOffTheRecordProfile()); | 201 profile->GetOffTheRecordProfile()); |
167 if (incognito_manager) { | 202 if (incognito_manager) { |
168 incognito_manager->CloseBackgroundHosts(); | 203 incognito_manager->CloseBackgroundHosts(); |
169 } | 204 } |
170 } | 205 } |
171 } | 206 } |
172 | 207 |
173 } // namespace extensions | 208 } // namespace extensions |
OLD | NEW |