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

Side by Side Diff: chrome/browser/extensions/chrome_process_manager_delegate.cc

Issue 2306143002: Plumbing for login apps device policy to extensions. (Closed)
Patch Set: Removed unnecessary logging Created 4 years, 1 month 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"
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 const bool is_signin_profile =
49 user_manager::UserManager::Get()->IsUserLoggedIn(); 56 chromeos::ProfileHelper::IsSigninProfile(profile);
57
58 if (is_signin_profile) {
59 const bool signin_apps_enabled =
60 base::CommandLine::ForCurrentProcess()->HasSwitch(
61 switches::kEnableSigninApps);
62 const bool signin_apps_installed =
63 !ExtensionManagementFactory::GetForBrowserContext(context)
64 ->GetForceInstallList()
65 ->empty();
66 allow_for_signin_profile = signin_apps_enabled && signin_apps_installed;
67 } else {
68 const bool user_logged_in =
69 user_manager::UserManager::Get()->IsUserLoggedIn();
70 is_normal_session &= user_logged_in;
71 }
50 #endif 72 #endif
51 73
52 // Disallow if the current session is a Guest mode session or login screen but 74 // 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 75 // the current browser context is *not* off-the-record. Such context is
54 // artificial and background page shouldn't be created in it. 76 // artificial and background page shouldn't be created in it.
55 // http://crbug.com/329498 77 // http://crbug.com/329498
56 return is_normal_session || profile->IsOffTheRecord(); 78 return is_normal_session || profile->IsOffTheRecord() ||
79 allow_for_signin_profile;
57 } 80 }
58 81
59 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts( 82 bool ChromeProcessManagerDelegate::DeferCreatingStartupBackgroundHosts(
60 content::BrowserContext* context) const { 83 content::BrowserContext* context) const {
61 Profile* profile = static_cast<Profile*>(context); 84 Profile* profile = static_cast<Profile*>(context);
62 85
63 // The profile may not be valid yet if it is still being initialized. 86 // 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. 87 // In that case, defer loading, since it depends on an initialized profile.
65 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED. 88 // Background hosts will be loaded later via NOTIFICATION_PROFILE_CREATED.
66 // http://crbug.com/222473 89 // http://crbug.com/222473
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ProcessManager* incognito_manager = 187 ProcessManager* incognito_manager =
165 ProcessManagerFactory::GetForBrowserContextIfExists( 188 ProcessManagerFactory::GetForBrowserContextIfExists(
166 profile->GetOffTheRecordProfile()); 189 profile->GetOffTheRecordProfile());
167 if (incognito_manager) { 190 if (incognito_manager) {
168 incognito_manager->CloseBackgroundHosts(); 191 incognito_manager->CloseBackgroundHosts();
169 } 192 }
170 } 193 }
171 } 194 }
172 195
173 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_management.h » ('j') | chrome/browser/extensions/extension_management.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698