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" |
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) const { |
43 Profile* profile = static_cast<Profile*>(context); | 48 Profile* profile = static_cast<Profile*>(context); |
44 | 49 |
45 bool is_normal_session = !profile->IsGuestSession() && | 50 bool is_normal_session = !profile->IsGuestSession() && |
46 !profile->IsSystemProfile(); | 51 !profile->IsSystemProfile(); |
47 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
48 is_normal_session = is_normal_session && | 53 if (is_normal_session) { |
49 user_manager::UserManager::Get()->IsUserLoggedIn(); | 54 const bool user_logged_in = |
55 user_manager::UserManager::Get()->IsUserLoggedIn(); | |
56 const bool is_signin_profile = | |
57 chromeos::ProfileHelper::IsSigninProfile(profile); | |
58 const bool login_apps_enabled = | |
59 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
60 switches::kEnableLoginApps); | |
61 const bool login_apps_installed = | |
62 !ExtensionManagementFactory::GetForBrowserContext(profile) | |
emaxx
2016/07/15 16:31:09
nit: The function accetps BrowserContext*, so ther
achuithb
2016/07/21 00:13:43
Done.
| |
63 ->GetForceInstallList() | |
64 ->empty(); | |
65 is_normal_session = | |
66 user_logged_in || | |
67 (is_signin_profile && login_apps_enabled && login_apps_installed); | |
emaxx
2016/07/15 16:31:09
I think it's better to use another boolean variabl
achuithb
2016/07/21 00:13:43
Done.
| |
68 } | |
50 #endif | 69 #endif |
51 | 70 |
52 // Disallow if the current session is a Guest mode session or login screen but | 71 // 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 | 72 // the current browser context is *not* off-the-record. Such context is |
54 // artificial and background page shouldn't be created in it. | 73 // artificial and background page shouldn't be created in it. |
55 // http://crbug.com/329498 | 74 // http://crbug.com/329498 |
56 return is_normal_session || profile->IsOffTheRecord(); | 75 return is_normal_session || profile->IsOffTheRecord(); |
57 } | 76 } |
58 | 77 |
59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( | 78 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 ProcessManager* incognito_manager = | 183 ProcessManager* incognito_manager = |
165 ProcessManagerFactory::GetForBrowserContextIfExists( | 184 ProcessManagerFactory::GetForBrowserContextIfExists( |
166 profile->GetOffTheRecordProfile()); | 185 profile->GetOffTheRecordProfile()); |
167 if (incognito_manager) { | 186 if (incognito_manager) { |
168 incognito_manager->CloseBackgroundHosts(); | 187 incognito_manager->CloseBackgroundHosts(); |
169 } | 188 } |
170 } | 189 } |
171 } | 190 } |
172 | 191 |
173 } // namespace extensions | 192 } // namespace extensions |
OLD | NEW |