| 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_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace ownership { | 31 namespace ownership { |
| 32 class OwnerKeyUtil; | 32 class OwnerKeyUtil; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace chromeos { | 35 namespace chromeos { |
| 36 | 36 |
| 37 class FakeOwnerSettingsService; | 37 class FakeOwnerSettingsService; |
| 38 | 38 |
| 39 // The class is a profile-keyed service which holds public/private | 39 // The class is a profile-keyed service which holds public/private keypair |
| 40 // keypair corresponds to a profile. The keypair is reloaded automatically when | 40 // corresponds to a profile. The keypair is reloaded automatically when profile |
| 41 // profile is created and TPM token is ready. Note that the private part of a | 41 // is created and TPM token is ready. Note that the private part of a key can be |
| 42 // key can be loaded only for the owner. | 42 // loaded only for the owner. |
| 43 // | 43 // |
| 44 // TODO (ygorshenin@): move write path for device settings here | 44 // TODO (ygorshenin@): move write path for device settings here |
| 45 // (crbug.com/230018). | 45 // (crbug.com/230018). |
| 46 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, | 46 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| 47 public content::NotificationObserver, | 47 public content::NotificationObserver, |
| 48 public SessionManagerClient::Observer, | 48 public SessionManagerClient::Observer, |
| 49 public DeviceSettingsService::Observer { | 49 public DeviceSettingsService::Observer { |
| 50 public: | 50 public: |
| 51 typedef base::Callback<void(bool success)> OnManagementSettingsSetCallback; | 51 typedef base::Callback<void(bool success)> OnManagementSettingsSetCallback; |
| 52 | 52 |
| 53 struct ManagementSettings { | 53 struct ManagementSettings { |
| 54 ManagementSettings(); | 54 ManagementSettings(); |
| 55 ~ManagementSettings(); | 55 ~ManagementSettings(); |
| 56 | 56 |
| 57 policy::ManagementMode management_mode; | |
| 58 std::string request_token; | 57 std::string request_token; |
| 59 std::string device_id; | 58 std::string device_id; |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 ~OwnerSettingsServiceChromeOS() override; | 61 ~OwnerSettingsServiceChromeOS() override; |
| 63 | 62 |
| 64 static OwnerSettingsServiceChromeOS* FromWebUI(content::WebUI* web_ui); | 63 static OwnerSettingsServiceChromeOS* FromWebUI(content::WebUI* web_ui); |
| 65 | 64 |
| 66 void OnTPMTokenReady(bool tpm_token_enabled); | 65 void OnTPMTokenReady(bool tpm_token_enabled); |
| 67 | 66 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 83 const content::NotificationDetails& details) override; | 82 const content::NotificationDetails& details) override; |
| 84 | 83 |
| 85 // SessionManagerClient::Observer: | 84 // SessionManagerClient::Observer: |
| 86 void OwnerKeySet(bool success) override; | 85 void OwnerKeySet(bool success) override; |
| 87 | 86 |
| 88 // DeviceSettingsService::Observer: | 87 // DeviceSettingsService::Observer: |
| 89 void OwnershipStatusChanged() override; | 88 void OwnershipStatusChanged() override; |
| 90 void DeviceSettingsUpdated() override; | 89 void DeviceSettingsUpdated() override; |
| 91 void OnDeviceSettingsServiceShutdown() override; | 90 void OnDeviceSettingsServiceShutdown() override; |
| 92 | 91 |
| 93 // Sets the management related settings. | |
| 94 virtual void SetManagementSettings( | |
| 95 const ManagementSettings& settings, | |
| 96 const OnManagementSettingsSetCallback& callback); | |
| 97 | |
| 98 // Checks if the user is the device owner, without the user profile having to | 92 // Checks if the user is the device owner, without the user profile having to |
| 99 // been initialized. Should be used only if login state is in safe mode. | 93 // been initialized. Should be used only if login state is in safe mode. |
| 100 static void IsOwnerForSafeModeAsync( | 94 static void IsOwnerForSafeModeAsync( |
| 101 const std::string& user_hash, | 95 const std::string& user_hash, |
| 102 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, | 96 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, |
| 103 const IsOwnerCallback& callback); | 97 const IsOwnerCallback& callback); |
| 104 | 98 |
| 105 // Assembles PolicyData based on |settings|, |policy_data|, |user_id| and | 99 // Assembles PolicyData based on |settings|, |policy_data|, |user_id| and |
| 106 // |pending_management_settings|. Applies local-owner policy fixups if needed. | 100 // |pending_management_settings|. Applies local-owner policy fixups if needed. |
| 107 static std::unique_ptr<enterprise_management::PolicyData> AssemblePolicy( | 101 static std::unique_ptr<enterprise_management::PolicyData> AssemblePolicy( |
| 108 const std::string& user_id, | 102 const std::string& user_id, |
| 109 const enterprise_management::PolicyData* policy_data, | 103 const enterprise_management::PolicyData* policy_data, |
| 110 bool apply_pending_mangement_settings, | |
| 111 const ManagementSettings& pending_management_settings, | |
| 112 enterprise_management::ChromeDeviceSettingsProto* settings); | 104 enterprise_management::ChromeDeviceSettingsProto* settings); |
| 113 | 105 |
| 114 // Updates device |settings|. | 106 // Updates device |settings|. |
| 115 static void UpdateDeviceSettings( | 107 static void UpdateDeviceSettings( |
| 116 const std::string& path, | 108 const std::string& path, |
| 117 const base::Value& value, | 109 const base::Value& value, |
| 118 enterprise_management::ChromeDeviceSettingsProto& settings); | 110 enterprise_management::ChromeDeviceSettingsProto& settings); |
| 119 | 111 |
| 120 protected: | 112 protected: |
| 121 OwnerSettingsServiceChromeOS( | 113 OwnerSettingsServiceChromeOS( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Whether TPM token still needs to be initialized. | 169 // Whether TPM token still needs to be initialized. |
| 178 bool waiting_for_tpm_token_; | 170 bool waiting_for_tpm_token_; |
| 179 | 171 |
| 180 // True if local-owner policy fixups are still pending. | 172 // True if local-owner policy fixups are still pending. |
| 181 bool has_pending_fixups_; | 173 bool has_pending_fixups_; |
| 182 | 174 |
| 183 // A set of pending changes to device settings. | 175 // A set of pending changes to device settings. |
| 184 base::ScopedPtrHashMap<std::string, std::unique_ptr<base::Value>> | 176 base::ScopedPtrHashMap<std::string, std::unique_ptr<base::Value>> |
| 185 pending_changes_; | 177 pending_changes_; |
| 186 | 178 |
| 187 // True if there're pending changes to management settings. | |
| 188 bool has_pending_management_settings_; | |
| 189 | |
| 190 // A set of pending changes to management settings. | |
| 191 ManagementSettings pending_management_settings_; | |
| 192 | |
| 193 // A set of callbacks that need to be run after management settings | |
| 194 // are set and policy is stored. | |
| 195 std::vector<OnManagementSettingsSetCallback> | |
| 196 pending_management_settings_callbacks_; | |
| 197 | |
| 198 // A protobuf containing pending changes to device settings. | 179 // A protobuf containing pending changes to device settings. |
| 199 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> | 180 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> |
| 200 tentative_settings_; | 181 tentative_settings_; |
| 201 | 182 |
| 202 content::NotificationRegistrar registrar_; | 183 content::NotificationRegistrar registrar_; |
| 203 | 184 |
| 204 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; | 185 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; |
| 205 | 186 |
| 206 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; | 187 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; |
| 207 | 188 |
| 208 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); | 189 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); |
| 209 }; | 190 }; |
| 210 | 191 |
| 211 } // namespace chromeos | 192 } // namespace chromeos |
| 212 | 193 |
| 213 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ | 194 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| OLD | NEW |