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 #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
17 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
18 #include "chromeos/tpm_token_loader.h" | |
19 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
20 #include "components/ownership/owner_key_util.h" | 19 #include "components/ownership/owner_key_util.h" |
21 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
23 | 22 |
24 class Profile; | 23 class Profile; |
25 | 24 |
26 namespace chromeos { | 25 namespace chromeos { |
27 | 26 |
28 class SessionManagerOperation; | 27 class SessionManagerOperation; |
29 | 28 |
30 // This class reloads owner key from profile NSS slots. | 29 // This class reloads owner key from profile NSS slots. |
31 // | 30 // |
32 // TODO (ygorshenin@): move write path for device settings here | 31 // TODO (ygorshenin@): move write path for device settings here |
33 // (crbug.com/230018). | 32 // (crbug.com/230018). |
34 class OwnerSettingsService : public DeviceSettingsService::PrivateKeyDelegate, | 33 class OwnerSettingsService : public DeviceSettingsService::PrivateKeyDelegate, |
35 public KeyedService, | 34 public KeyedService, |
36 public content::NotificationObserver, | 35 public content::NotificationObserver, |
37 public TPMTokenLoader::Observer, | |
38 public SessionManagerClient::Observer { | 36 public SessionManagerClient::Observer { |
39 public: | 37 public: |
40 virtual ~OwnerSettingsService(); | 38 virtual ~OwnerSettingsService(); |
41 | 39 |
42 base::WeakPtr<OwnerSettingsService> as_weak_ptr() { | 40 base::WeakPtr<OwnerSettingsService> as_weak_ptr() { |
43 return weak_factory_.GetWeakPtr(); | 41 return weak_factory_.GetWeakPtr(); |
44 } | 42 } |
45 | 43 |
| 44 void OnTPMTokenReady(bool tpm_token_enabled); |
| 45 |
46 // DeviceSettingsService::PrivateKeyDelegate implementation: | 46 // DeviceSettingsService::PrivateKeyDelegate implementation: |
47 virtual bool IsOwner() OVERRIDE; | 47 virtual bool IsOwner() OVERRIDE; |
48 virtual void IsOwnerAsync(const IsOwnerCallback& callback) OVERRIDE; | 48 virtual void IsOwnerAsync(const IsOwnerCallback& callback) OVERRIDE; |
49 virtual bool AssembleAndSignPolicyAsync( | 49 virtual bool AssembleAndSignPolicyAsync( |
50 scoped_ptr<enterprise_management::PolicyData> policy, | 50 scoped_ptr<enterprise_management::PolicyData> policy, |
51 const AssembleAndSignPolicyCallback& callback) OVERRIDE; | 51 const AssembleAndSignPolicyCallback& callback) OVERRIDE; |
52 virtual void SignAndStoreAsync( | 52 virtual void SignAndStoreAsync( |
53 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> settings, | 53 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> settings, |
54 const base::Closure& callback) OVERRIDE; | 54 const base::Closure& callback) OVERRIDE; |
55 virtual void SetManagementSettingsAsync( | 55 virtual void SetManagementSettingsAsync( |
56 enterprise_management::PolicyData::ManagementMode management_mode, | 56 enterprise_management::PolicyData::ManagementMode management_mode, |
57 const std::string& request_token, | 57 const std::string& request_token, |
58 const std::string& device_id, | 58 const std::string& device_id, |
59 const base::Closure& callback) OVERRIDE; | 59 const base::Closure& callback) OVERRIDE; |
60 | 60 |
61 // NotificationObserver implementation: | 61 // NotificationObserver implementation: |
62 virtual void Observe(int type, | 62 virtual void Observe(int type, |
63 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
64 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
65 | 65 |
66 // TPMTokenLoader::Observer: | |
67 virtual void OnTPMTokenReady() OVERRIDE; | |
68 | |
69 // SessionManagerClient::Observer: | 66 // SessionManagerClient::Observer: |
70 virtual void OwnerKeySet(bool success) OVERRIDE; | 67 virtual void OwnerKeySet(bool success) OVERRIDE; |
71 | 68 |
72 // Checks if the user is the device owner, without the user profile having to | 69 // Checks if the user is the device owner, without the user profile having to |
73 // been initialized. Should be used only if login state is in safe mode. | 70 // been initialized. Should be used only if login state is in safe mode. |
74 static void IsOwnerForSafeModeAsync(const std::string& user_hash, | 71 static void IsOwnerForSafeModeAsync(const std::string& user_hash, |
75 const IsOwnerCallback& callback); | 72 const IsOwnerCallback& callback); |
76 | 73 |
77 static scoped_refptr<ownership::OwnerKeyUtil> MakeOwnerKeyUtil(); | 74 static scoped_refptr<ownership::OwnerKeyUtil> MakeOwnerKeyUtil(); |
78 | 75 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::ThreadChecker thread_checker_; | 146 base::ThreadChecker thread_checker_; |
150 | 147 |
151 base::WeakPtrFactory<OwnerSettingsService> weak_factory_; | 148 base::WeakPtrFactory<OwnerSettingsService> weak_factory_; |
152 | 149 |
153 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService); | 150 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService); |
154 }; | 151 }; |
155 | 152 |
156 } // namespace chromeos | 153 } // namespace chromeos |
157 | 154 |
158 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 155 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
OLD | NEW |