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

Side by Side Diff: chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc

Issue 2945023002: Introduce profile for lock screen apps (Closed)
Patch Set: rebase Created 3 years, 5 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/policy/user_network_configuration_updater_fact ory.h" 5 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact ory.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" 8 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/policy/profile_policy_connector.h" 10 #include "chrome/browser/policy/profile_policy_connector.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const { 53 const {
54 return true; 54 return true;
55 } 55 }
56 56
57 bool UserNetworkConfigurationUpdaterFactory::ServiceIsNULLWhileTesting() const { 57 bool UserNetworkConfigurationUpdaterFactory::ServiceIsNULLWhileTesting() const {
58 return true; 58 return true;
59 } 59 }
60 60
61 KeyedService* UserNetworkConfigurationUpdaterFactory::BuildServiceInstanceFor( 61 KeyedService* UserNetworkConfigurationUpdaterFactory::BuildServiceInstanceFor(
62 content::BrowserContext* context) const { 62 content::BrowserContext* context) const {
63 // On the login/lock screen only device network policies apply.
63 Profile* profile = Profile::FromBrowserContext(context); 64 Profile* profile = Profile::FromBrowserContext(context);
64 if (chromeos::ProfileHelper::IsSigninProfile(profile)) 65 if (chromeos::ProfileHelper::IsSigninProfile(profile) ||
65 return NULL; // On the login screen only device network policies apply. 66 chromeos::ProfileHelper::IsLockScreenAppProfile(profile)) {
67 return nullptr;
68 }
66 69
67 const user_manager::User* user = 70 const user_manager::User* user =
68 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); 71 chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
69 DCHECK(user); 72 DCHECK(user);
70 // Currently, only the network policy of the primary user is supported. See 73 // Currently, only the network policy of the primary user is supported. See
71 // also http://crbug.com/310685 . 74 // also http://crbug.com/310685 .
72 if (user != user_manager::UserManager::Get()->GetPrimaryUser()) 75 if (user != user_manager::UserManager::Get()->GetPrimaryUser())
73 return NULL; 76 return nullptr;
74 77
75 ProfilePolicyConnector* profile_connector = 78 ProfilePolicyConnector* profile_connector =
76 ProfilePolicyConnectorFactory::GetForBrowserContext(context); 79 ProfilePolicyConnectorFactory::GetForBrowserContext(context);
77 80
78 return UserNetworkConfigurationUpdater::CreateForUserPolicy( 81 return UserNetworkConfigurationUpdater::CreateForUserPolicy(
79 profile, AllowTrustedCertsFromPolicy(user), *user, 82 profile, AllowTrustedCertsFromPolicy(user), *user,
80 profile_connector->policy_service(), 83 profile_connector->policy_service(),
81 chromeos::NetworkHandler::Get() 84 chromeos::NetworkHandler::Get()
82 ->managed_network_configuration_handler()) 85 ->managed_network_configuration_handler())
83 .release(); 86 .release();
84 } 87 }
85 88
86 // static 89 // static
87 bool UserNetworkConfigurationUpdaterFactory::AllowTrustedCertsFromPolicy( 90 bool UserNetworkConfigurationUpdaterFactory::AllowTrustedCertsFromPolicy(
88 const user_manager::User* user) { 91 const user_manager::User* user) {
89 user_manager::UserType user_type = user->GetType(); 92 user_manager::UserType user_type = user->GetType();
90 93
91 // Disallow trusted root certs for public sessions. 94 // Disallow trusted root certs for public sessions.
92 // Also, guest sessions don't get user policy, but a 95 // Also, guest sessions don't get user policy, but a
93 // UserNetworkCofnigurationUpdater can be created for them anyway. 96 // UserNetworkCofnigurationUpdater can be created for them anyway.
94 return user_type != user_manager::USER_TYPE_GUEST && 97 return user_type != user_manager::USER_TYPE_GUEST &&
95 user_type != user_manager::USER_TYPE_PUBLIC_ACCOUNT; 98 user_type != user_manager::USER_TYPE_PUBLIC_ACCOUNT;
96 } 99 }
97 100
98 } // namespace policy 101 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698