Chromium Code Reviews| 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(); |
| 52 bool allow_for_signin_profile = false; | |
| 53 | |
| 47 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
| 48 is_normal_session = is_normal_session && | 55 if (is_normal_session) { |
| 49 user_manager::UserManager::Get()->IsUserLoggedIn(); | 56 const bool user_logged_in = |
| 57 user_manager::UserManager::Get()->IsUserLoggedIn(); | |
| 58 is_normal_session = user_logged_in; | |
| 59 | |
| 60 const bool is_signin_profile = | |
| 61 chromeos::ProfileHelper::IsSigninProfile(profile); | |
| 62 const bool signin_apps_enabled = | |
| 63 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 64 switches::kEnableSigninApps); | |
| 65 const bool signin_apps_installed = | |
| 66 !ExtensionManagementFactory::GetForBrowserContext(context) | |
| 67 ->GetForceInstallList() | |
| 68 ->empty(); | |
| 69 | |
| 70 allow_for_signin_profile = | |
| 71 is_signin_profile && signin_apps_enabled && signin_apps_installed; | |
| 72 } | |
| 50 #endif | 73 #endif |
| 51 | 74 |
| 52 // Disallow if the current session is a Guest mode session or login screen but | 75 // 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 | 76 // the current browser context is *not* off-the-record. Such context is |
| 54 // artificial and background page shouldn't be created in it. | 77 // artificial and background page shouldn't be created in it. |
| 55 // http://crbug.com/329498 | 78 // http://crbug.com/329498 |
| 56 return is_normal_session || profile->IsOffTheRecord(); | 79 return is_normal_session || profile->IsOffTheRecord() || |
| 80 allow_for_signin_profile; | |
|
emaxx
2016/11/10 15:03:44
I think there's still something wrong with this ex
| |
| 57 } | 81 } |
| 58 | 82 |
| 59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( | 83 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( |
| 60 content::BrowserContext* context) const { | 84 content::BrowserContext* context) const { |
| 61 Profile* profile = static_cast<Profile*>(context); | 85 Profile* profile = static_cast<Profile*>(context); |
| 62 | 86 |
| 63 // The profile may not be valid yet if it is still being initialized. | 87 // 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. | 88 // In that case, defer loading, since it depends on an initialized profile. |
| 65 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED. | 89 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED. |
| 66 // http://crbug.com/222473 | 90 // http://crbug.com/222473 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 ProcessManager* incognito_manager = | 188 ProcessManager* incognito_manager = |
| 165 ProcessManagerFactory::GetForBrowserContextIfExists( | 189 ProcessManagerFactory::GetForBrowserContextIfExists( |
| 166 profile->GetOffTheRecordProfile()); | 190 profile->GetOffTheRecordProfile()); |
| 167 if (incognito_manager) { | 191 if (incognito_manager) { |
| 168 incognito_manager->CloseBackgroundHosts(); | 192 incognito_manager->CloseBackgroundHosts(); |
| 169 } | 193 } |
| 170 } | 194 } |
| 171 } | 195 } |
| 172 | 196 |
| 173 } // namespace extensions | 197 } // namespace extensions |
| OLD | NEW |