| 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 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.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 "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "components/ownership/owner_key_util.h" | 19 #include "components/ownership/owner_key_util.h" |
| 20 #include "components/ownership/owner_settings_service.h" | 20 #include "components/ownership/owner_settings_service.h" |
| 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 22 #include "components/user_manager/user_id.h" |
| 22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 24 | 25 |
| 25 class Profile; | 26 class Profile; |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 class WebUI; | 29 class WebUI; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace ownership { | 32 namespace ownership { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Checks if the user is the device owner, without the user profile having to | 99 // 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. | 100 // been initialized. Should be used only if login state is in safe mode. |
| 100 static void IsOwnerForSafeModeAsync( | 101 static void IsOwnerForSafeModeAsync( |
| 101 const std::string& user_hash, | 102 const std::string& user_hash, |
| 102 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, | 103 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, |
| 103 const IsOwnerCallback& callback); | 104 const IsOwnerCallback& callback); |
| 104 | 105 |
| 105 // Assembles PolicyData based on |settings|, |policy_data|, |user_id| and | 106 // Assembles PolicyData based on |settings|, |policy_data|, |user_id| and |
| 106 // |pending_management_settings|. Applies local-owner policy fixups if needed. | 107 // |pending_management_settings|. Applies local-owner policy fixups if needed. |
| 107 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( | 108 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy( |
| 108 const std::string& user_id, | 109 const user_manager::UserID& user_id, |
| 109 const enterprise_management::PolicyData* policy_data, | 110 const enterprise_management::PolicyData* policy_data, |
| 110 bool apply_pending_mangement_settings, | 111 bool apply_pending_mangement_settings, |
| 111 const ManagementSettings& pending_management_settings, | 112 const ManagementSettings& pending_management_settings, |
| 112 enterprise_management::ChromeDeviceSettingsProto* settings); | 113 enterprise_management::ChromeDeviceSettingsProto* settings); |
| 113 | 114 |
| 114 // Updates device |settings|. | 115 // Updates device |settings|. |
| 115 static void UpdateDeviceSettings( | 116 static void UpdateDeviceSettings( |
| 116 const std::string& path, | 117 const std::string& path, |
| 117 const base::Value& value, | 118 const base::Value& value, |
| 118 enterprise_management::ChromeDeviceSettingsProto& settings); | 119 enterprise_management::ChromeDeviceSettingsProto& settings); |
| 119 | 120 |
| 120 protected: | 121 protected: |
| 121 OwnerSettingsServiceChromeOS( | 122 OwnerSettingsServiceChromeOS( |
| 122 DeviceSettingsService* device_settings_service, | 123 DeviceSettingsService* device_settings_service, |
| 123 Profile* profile, | 124 Profile* profile, |
| 124 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); | 125 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); |
| 125 | 126 |
| 126 private: | 127 private: |
| 127 friend class OwnerSettingsServiceChromeOSFactory; | 128 friend class OwnerSettingsServiceChromeOSFactory; |
| 128 | 129 |
| 129 // Perform fixups required to ensure sensical local-owner device policy: | 130 // Perform fixups required to ensure sensical local-owner device policy: |
| 130 // 1) user whitelisting must be explicitly allowed or disallowed, and | 131 // 1) user whitelisting must be explicitly allowed or disallowed, and |
| 131 // 2) the owner user must be on the whitelist, if it's enforced. | 132 // 2) the owner user must be on the whitelist, if it's enforced. |
| 132 static void FixupLocalOwnerPolicy( | 133 static void FixupLocalOwnerPolicy( |
| 133 const std::string& user_id, | 134 const user_manager::UserID& user_id, |
| 134 enterprise_management::ChromeDeviceSettingsProto* settings); | 135 enterprise_management::ChromeDeviceSettingsProto* settings); |
| 135 | 136 |
| 136 // OwnerSettingsService protected interface overrides: | 137 // OwnerSettingsService protected interface overrides: |
| 137 | 138 |
| 138 // Reloads private key from profile's NSS slots, responds via |callback|. On | 139 // Reloads private key from profile's NSS slots, responds via |callback|. On |
| 139 // success, |private_key| is non-null, but if the private key doesn't exist, | 140 // success, |private_key| is non-null, but if the private key doesn't exist, |
| 140 // |private_key->key()| may be null. | 141 // |private_key->key()| may be null. |
| 141 void ReloadKeypairImpl(const base::Callback< | 142 void ReloadKeypairImpl(const base::Callback< |
| 142 void(const scoped_refptr<ownership::PublicKey>& public_key, | 143 void(const scoped_refptr<ownership::PublicKey>& public_key, |
| 143 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback) | 144 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 // Report status to observers and tries to continue storing pending chages to | 162 // Report status to observers and tries to continue storing pending chages to |
| 162 // device settings. | 163 // device settings. |
| 163 void ReportStatusAndContinueStoring(bool success); | 164 void ReportStatusAndContinueStoring(bool success); |
| 164 | 165 |
| 165 DeviceSettingsService* device_settings_service_; | 166 DeviceSettingsService* device_settings_service_; |
| 166 | 167 |
| 167 // Profile this service instance belongs to. | 168 // Profile this service instance belongs to. |
| 168 Profile* profile_; | 169 Profile* profile_; |
| 169 | 170 |
| 170 // User ID this service instance belongs to. | 171 // User ID this service instance belongs to. |
| 171 std::string user_id_; | 172 user_manager::UserID user_id_; |
| 172 | 173 |
| 173 // Whether profile still needs to be initialized. | 174 // Whether profile still needs to be initialized. |
| 174 bool waiting_for_profile_creation_; | 175 bool waiting_for_profile_creation_; |
| 175 | 176 |
| 176 // Whether TPM token still needs to be initialized. | 177 // Whether TPM token still needs to be initialized. |
| 177 bool waiting_for_tpm_token_; | 178 bool waiting_for_tpm_token_; |
| 178 | 179 |
| 179 // True if local-owner policy fixups are still pending. | 180 // True if local-owner policy fixups are still pending. |
| 180 bool has_pending_fixups_; | 181 bool has_pending_fixups_; |
| 181 | 182 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 202 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; | 203 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; |
| 203 | 204 |
| 204 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; | 205 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_; |
| 205 | 206 |
| 206 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); | 207 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); |
| 207 }; | 208 }; |
| 208 | 209 |
| 209 } // namespace chromeos | 210 } // namespace chromeos |
| 210 | 211 |
| 211 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ | 212 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| OLD | NEW |