Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 // profile is created and TPM token is ready. Note that the private part of a | 34 // profile is created and TPM token is ready. Note that the private part of a |
| 35 // key can be loaded only for the owner. | 35 // key can be loaded only for the owner. |
| 36 // | 36 // |
| 37 // TODO (ygorshenin@): move write path for device settings here | 37 // TODO (ygorshenin@): move write path for device settings here |
| 38 // (crbug.com/230018). | 38 // (crbug.com/230018). |
| 39 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, | 39 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| 40 public content::NotificationObserver, | 40 public content::NotificationObserver, |
| 41 public SessionManagerClient::Observer, | 41 public SessionManagerClient::Observer, |
| 42 public DeviceSettingsService::Observer { | 42 public DeviceSettingsService::Observer { |
| 43 public: | 43 public: |
| 44 struct ManagementSettingsSetRequest { | |
| 45 ManagementSettingsSetRequest(); | |
| 46 ~ManagementSettingsSetRequest(); | |
| 47 | |
| 48 typedef base::Callback<void(bool success)> RequestProcessedCallback; | |
| 49 | |
| 50 enterprise_management::PolicyData::ManagementMode management_mode; | |
| 51 std::string request_token; | |
| 52 std::string device_id; | |
| 53 RequestProcessedCallback callback; | |
| 54 }; | |
| 55 | |
| 44 virtual ~OwnerSettingsServiceChromeOS(); | 56 virtual ~OwnerSettingsServiceChromeOS(); |
| 45 | 57 |
| 46 void OnTPMTokenReady(bool tpm_token_enabled); | 58 void OnTPMTokenReady(bool tpm_token_enabled); |
| 47 | 59 |
| 48 // ownership::OwnerSettingsService implementation: | 60 // ownership::OwnerSettingsService implementation: |
| 49 virtual bool HandlesSetting(const std::string& setting) override; | 61 virtual bool HandlesSetting(const std::string& setting) override; |
| 50 virtual bool Set(const std::string& setting, | 62 virtual bool Set(const std::string& setting, |
| 51 const base::Value& value) override; | 63 const base::Value& value) override; |
| 52 virtual bool CommitTentativeDeviceSettings( | 64 virtual bool CommitTentativeDeviceSettings( |
| 53 scoped_ptr<enterprise_management::PolicyData> policy) override; | 65 scoped_ptr<enterprise_management::PolicyData> policy) override; |
| 54 | 66 |
| 55 // NotificationObserver implementation: | 67 // NotificationObserver implementation: |
| 56 virtual void Observe(int type, | 68 virtual void Observe(int type, |
| 57 const content::NotificationSource& source, | 69 const content::NotificationSource& source, |
| 58 const content::NotificationDetails& details) override; | 70 const content::NotificationDetails& details) override; |
| 59 | 71 |
| 60 // SessionManagerClient::Observer: | 72 // SessionManagerClient::Observer: |
| 61 virtual void OwnerKeySet(bool success) override; | 73 virtual void OwnerKeySet(bool success) override; |
| 62 | 74 |
| 63 // DeviceSettingsService::Observer: | 75 // DeviceSettingsService::Observer: |
| 64 virtual void OwnershipStatusChanged() override; | 76 virtual void OwnershipStatusChanged() override; |
| 65 virtual void DeviceSettingsUpdated() override; | 77 virtual void DeviceSettingsUpdated() override; |
| 66 virtual void OnDeviceSettingsServiceShutdown() override; | 78 virtual void OnDeviceSettingsServiceShutdown() override; |
| 67 | 79 |
| 80 // Sets the management related settings. | |
| 81 void SetManagementSettings(const ManagementSettingsSetRequest& request); | |
| 82 | |
| 68 // Checks if the user is the device owner, without the user profile having to | 83 // Checks if the user is the device owner, without the user profile having to |
| 69 // been initialized. Should be used only if login state is in safe mode. | 84 // been initialized. Should be used only if login state is in safe mode. |
| 70 static void IsOwnerForSafeModeAsync( | 85 static void IsOwnerForSafeModeAsync( |
| 71 const std::string& user_hash, | 86 const std::string& user_hash, |
| 72 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, | 87 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, |
| 73 const IsOwnerCallback& callback); | 88 const IsOwnerCallback& callback); |
| 74 | 89 |
| 75 // Assembles PolicyData based on |settings|, |policy_data| and | 90 // Assembles PolicyData based on |settings|, |policy_data| and |
| 76 // |user_id|. | 91 // |user_id|. |
| 77 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( | 92 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( |
| 78 const std::string& user_id, | 93 const std::string& user_id, |
| 79 const enterprise_management::PolicyData* policy_data, | 94 const enterprise_management::PolicyData* policy_data, |
| 80 const enterprise_management::ChromeDeviceSettingsProto* settings); | 95 const enterprise_management::ChromeDeviceSettingsProto* settings); |
| 81 | 96 |
| 82 // Updates device |settings|. | 97 // Updates device |settings|. |
| 83 static void UpdateDeviceSettings( | 98 static void UpdateDeviceSettings( |
| 84 const std::string& path, | 99 const std::string& path, |
| 85 const base::Value& value, | 100 const base::Value& value, |
| 86 enterprise_management::ChromeDeviceSettingsProto& settings); | 101 enterprise_management::ChromeDeviceSettingsProto& settings); |
| 87 | 102 |
| 88 bool has_pending_changes() const { | 103 bool has_pending_changes() const { |
| 89 return !pending_changes_.empty() || tentative_settings_.get(); | 104 return !pending_changes_.empty() || tentative_settings_.get() || |
| 105 !pending_management_settings_set_requests_.empty(); | |
| 90 } | 106 } |
| 91 | 107 |
| 92 private: | 108 private: |
| 93 friend class OwnerSettingsServiceChromeOSFactory; | 109 friend class OwnerSettingsServiceChromeOSFactory; |
| 94 | 110 |
| 95 OwnerSettingsServiceChromeOS( | 111 OwnerSettingsServiceChromeOS( |
| 96 DeviceSettingsService* device_settings_service, | 112 DeviceSettingsService* device_settings_service, |
| 97 Profile* profile, | 113 Profile* profile, |
| 98 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); | 114 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); |
| 99 | 115 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 150 |
| 135 // Whether profile still needs to be initialized. | 151 // Whether profile still needs to be initialized. |
| 136 bool waiting_for_profile_creation_; | 152 bool waiting_for_profile_creation_; |
| 137 | 153 |
| 138 // Whether TPM token still needs to be initialized. | 154 // Whether TPM token still needs to be initialized. |
| 139 bool waiting_for_tpm_token_; | 155 bool waiting_for_tpm_token_; |
| 140 | 156 |
| 141 // A set of pending changes to device settings. | 157 // A set of pending changes to device settings. |
| 142 base::ScopedPtrHashMap<std::string, base::Value> pending_changes_; | 158 base::ScopedPtrHashMap<std::string, base::Value> pending_changes_; |
| 143 | 159 |
| 160 // A set of pending changes to management settings. | |
| 161 std::vector<ManagementSettingsSetRequest> | |
| 162 pending_management_settings_set_requests_; | |
|
Mattias Nissler (ping if slow)
2014/12/02 08:52:40
I think we only ever need to store one of these. I
ygorshenin1
2014/12/02 19:18:58
Done.
| |
| 163 | |
| 164 // A set of callbacks that need to be run after signed policy is | |
| 165 // stored. | |
| 166 std::vector<ManagementSettingsSetRequest::RequestProcessedCallback> | |
| 167 pending_callbacks_; | |
| 168 | |
| 144 // A protobuf containing pending changes to device settings. | 169 // A protobuf containing pending changes to device settings. |
| 145 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> | 170 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> |
| 146 tentative_settings_; | 171 tentative_settings_; |
| 147 | 172 |
| 148 content::NotificationRegistrar registrar_; | 173 content::NotificationRegistrar registrar_; |
| 149 | 174 |
| 150 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; | 175 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; |
| 151 | 176 |
| 152 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; | 177 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; |
| 153 | 178 |
| 154 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); | 179 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); |
| 155 }; | 180 }; |
| 156 | 181 |
| 157 } // namespace chromeos | 182 } // namespace chromeos |
| 158 | 183 |
| 159 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ | 184 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| OLD | NEW |