OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.
h" | |
6 | |
7 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | |
8 #include "chrome/browser/chromeos/login/users/user.h" | |
9 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
10 #include "chrome/browser/managed_mode/chromeos/manager_password_service.h" | |
11 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" | |
12 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | |
13 #include "chrome/browser/profiles/incognito_helpers.h" | |
14 #include "chrome/browser/profiles/profile.h" | |
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
16 | |
17 namespace chromeos { | |
18 | |
19 // static | |
20 ManagerPasswordService* | |
21 ManagerPasswordServiceFactory::GetForProfile(Profile* profile) { | |
22 return static_cast<ManagerPasswordService*>( | |
23 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
24 } | |
25 | |
26 // static | |
27 ManagerPasswordServiceFactory* | |
28 ManagerPasswordServiceFactory::GetInstance() { | |
29 return Singleton<ManagerPasswordServiceFactory>::get(); | |
30 } | |
31 | |
32 ManagerPasswordServiceFactory::ManagerPasswordServiceFactory() | |
33 : BrowserContextKeyedServiceFactory( | |
34 "ManagerPasswordService", | |
35 BrowserContextDependencyManager::GetInstance()) { | |
36 DependsOn(ManagedUserSharedSettingsServiceFactory::GetInstance()); | |
37 DependsOn(ManagedUserSyncServiceFactory::GetInstance()); | |
38 } | |
39 | |
40 ManagerPasswordServiceFactory:: | |
41 ~ManagerPasswordServiceFactory() {} | |
42 | |
43 KeyedService* ManagerPasswordServiceFactory::BuildServiceInstanceFor( | |
44 content::BrowserContext* context) const { | |
45 Profile* profile= static_cast<Profile*>(context); | |
46 chromeos::User* user = chromeos::UserManager::Get()-> | |
47 GetUserByProfile(profile); | |
48 if (chromeos::UserManager::Get()->GetSupervisedUserManager()-> | |
49 HasSupervisedUsers(user->email())) { | |
50 ManagerPasswordService* result = new ManagerPasswordService(); | |
51 result->Init( | |
52 user->email(), | |
53 ManagedUserSyncServiceFactory::GetForProfile(profile), | |
54 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile)); | |
55 return result; | |
56 } | |
57 return NULL; | |
58 } | |
59 | |
60 content::BrowserContext* | |
61 ManagerPasswordServiceFactory::GetBrowserContextToUse( | |
62 content::BrowserContext* context) const { | |
63 return chrome::GetBrowserContextRedirectedInIncognito(context); | |
64 } | |
65 | |
66 } // namespace chromeos | |
OLD | NEW |