| 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 16 matching lines...) Expand all Loading... |
| 27 namespace content { | 27 namespace content { |
| 28 class WebUI; | 28 class WebUI; |
| 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; | |
| 38 | |
| 39 // The class is a profile-keyed service which holds public/private | 37 // The class is a profile-keyed service which holds public/private |
| 40 // keypair corresponds to a profile. The keypair is reloaded automatically when | 38 // keypair corresponds to a profile. The keypair is reloaded automatically when |
| 41 // profile is created and TPM token is ready. Note that the private part of a | 39 // profile is created and TPM token is ready. Note that the private part of a |
| 42 // key can be loaded only for the owner. | 40 // key can be loaded only for the owner. |
| 43 // | 41 // |
| 44 // TODO (ygorshenin@): move write path for device settings here | 42 // TODO (ygorshenin@): move write path for device settings here |
| 45 // (crbug.com/230018). | 43 // (crbug.com/230018). |
| 46 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, | 44 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| 47 public content::NotificationObserver, | 45 public content::NotificationObserver, |
| 48 public SessionManagerClient::Observer, | 46 public SessionManagerClient::Observer, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 81 |
| 84 // SessionManagerClient::Observer: | 82 // SessionManagerClient::Observer: |
| 85 virtual void OwnerKeySet(bool success) override; | 83 virtual void OwnerKeySet(bool success) override; |
| 86 | 84 |
| 87 // DeviceSettingsService::Observer: | 85 // DeviceSettingsService::Observer: |
| 88 virtual void OwnershipStatusChanged() override; | 86 virtual void OwnershipStatusChanged() override; |
| 89 virtual void DeviceSettingsUpdated() override; | 87 virtual void DeviceSettingsUpdated() override; |
| 90 virtual void OnDeviceSettingsServiceShutdown() override; | 88 virtual void OnDeviceSettingsServiceShutdown() override; |
| 91 | 89 |
| 92 // Sets the management related settings. | 90 // Sets the management related settings. |
| 93 virtual void SetManagementSettings( | 91 void SetManagementSettings(const ManagementSettings& settings, |
| 94 const ManagementSettings& settings, | 92 const OnManagementSettingsSetCallback& callback); |
| 95 const OnManagementSettingsSetCallback& callback); | |
| 96 | 93 |
| 97 // Checks if the user is the device owner, without the user profile having to | 94 // Checks if the user is the device owner, without the user profile having to |
| 98 // been initialized. Should be used only if login state is in safe mode. | 95 // been initialized. Should be used only if login state is in safe mode. |
| 99 static void IsOwnerForSafeModeAsync( | 96 static void IsOwnerForSafeModeAsync( |
| 100 const std::string& user_hash, | 97 const std::string& user_hash, |
| 101 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, | 98 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, |
| 102 const IsOwnerCallback& callback); | 99 const IsOwnerCallback& callback); |
| 103 | 100 |
| 104 // Assembles PolicyData based on |settings|, |policy_data| and | 101 // Assembles PolicyData based on |settings|, |policy_data| and |
| 105 // |user_id|. | 102 // |user_id|. |
| 106 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( | 103 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( |
| 107 const std::string& user_id, | 104 const std::string& user_id, |
| 108 const enterprise_management::PolicyData* policy_data, | 105 const enterprise_management::PolicyData* policy_data, |
| 109 const enterprise_management::ChromeDeviceSettingsProto* settings); | 106 const enterprise_management::ChromeDeviceSettingsProto* settings); |
| 110 | 107 |
| 111 // Updates device |settings|. | 108 // Updates device |settings|. |
| 112 static void UpdateDeviceSettings( | 109 static void UpdateDeviceSettings( |
| 113 const std::string& path, | 110 const std::string& path, |
| 114 const base::Value& value, | 111 const base::Value& value, |
| 115 enterprise_management::ChromeDeviceSettingsProto& settings); | 112 enterprise_management::ChromeDeviceSettingsProto& settings); |
| 116 | 113 |
| 117 bool has_pending_changes() const { | 114 bool has_pending_changes() const { |
| 118 return !pending_changes_.empty() || tentative_settings_.get() || | 115 return !pending_changes_.empty() || tentative_settings_.get() || |
| 119 has_pending_management_settings_; | 116 has_pending_management_settings_; |
| 120 } | 117 } |
| 121 | 118 |
| 122 protected: | 119 private: |
| 120 friend class OwnerSettingsServiceChromeOSFactory; |
| 121 |
| 123 OwnerSettingsServiceChromeOS( | 122 OwnerSettingsServiceChromeOS( |
| 124 DeviceSettingsService* device_settings_service, | 123 DeviceSettingsService* device_settings_service, |
| 125 Profile* profile, | 124 Profile* profile, |
| 126 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); | 125 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); |
| 127 | 126 |
| 128 private: | |
| 129 friend class OwnerSettingsServiceChromeOSFactory; | |
| 130 | |
| 131 // OwnerSettingsService protected interface overrides: | 127 // OwnerSettingsService protected interface overrides: |
| 132 | 128 |
| 133 // Reloads private key from profile's NSS slots, responds via |callback|. | 129 // Reloads private key from profile's NSS slots, responds via |callback|. |
| 134 virtual void ReloadKeypairImpl(const base::Callback< | 130 virtual void ReloadKeypairImpl(const base::Callback< |
| 135 void(const scoped_refptr<ownership::PublicKey>& public_key, | 131 void(const scoped_refptr<ownership::PublicKey>& public_key, |
| 136 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback) | 132 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback) |
| 137 override; | 133 override; |
| 138 | 134 |
| 139 // Possibly notifies DeviceSettingsService that owner's keypair is loaded. | 135 // Possibly notifies DeviceSettingsService that owner's keypair is loaded. |
| 140 virtual void OnPostKeypairLoadedActions() override; | 136 virtual void OnPostKeypairLoadedActions() override; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; | 188 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; |
| 193 | 189 |
| 194 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; | 190 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; |
| 195 | 191 |
| 196 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); | 192 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); |
| 197 }; | 193 }; |
| 198 | 194 |
| 199 } // namespace chromeos | 195 } // namespace chromeos |
| 200 | 196 |
| 201 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ | 197 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| OLD | NEW |