Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation.h

Issue 769703003: SetManagementSettings() is moved to OwnerSettingsServiceChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Failing test fixed. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SETTINGS_SESSION_MANAGER_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h" 12 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h"
13 #include "chrome/browser/chromeos/settings/device_settings_service.h" 13 #include "chrome/browser/chromeos/settings/device_settings_service.h"
14 #include "components/ownership/owner_settings_service.h"
15 #include "net/cert/x509_util_nss.h" 14 #include "net/cert/x509_util_nss.h"
16 15
17 namespace enterprise_management { 16 namespace enterprise_management {
18 class ChromeDeviceSettingsProto; 17 class ChromeDeviceSettingsProto;
19 class PolicyData; 18 class PolicyData;
20 class PolicyFetchResponse; 19 class PolicyFetchResponse;
21 } 20 }
22 21
23 namespace ownership { 22 namespace ownership {
24 class OwnerKeyUtil; 23 class OwnerKeyUtil;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Public part of the owner key as configured/loaded from disk. 60 // Public part of the owner key as configured/loaded from disk.
62 scoped_refptr<ownership::PublicKey> public_key() { return public_key_; } 61 scoped_refptr<ownership::PublicKey> public_key() { return public_key_; }
63 62
64 // Whether the load operation is underway. 63 // Whether the load operation is underway.
65 bool is_loading() const { return is_loading_; } 64 bool is_loading() const { return is_loading_; }
66 65
67 void set_force_key_load(bool force_key_load) { 66 void set_force_key_load(bool force_key_load) {
68 force_key_load_ = force_key_load; 67 force_key_load_ = force_key_load;
69 } 68 }
70 69
71 void set_username(const std::string& username) { username_ = username; }
72
73 void set_owner_settings_service(const base::WeakPtr<
74 ownership::OwnerSettingsService>& owner_settings_service) {
75 owner_settings_service_ = owner_settings_service;
76 }
77
78 protected: 70 protected:
79 // Runs the operation. The result is reported through |callback_|. 71 // Runs the operation. The result is reported through |callback_|.
80 virtual void Run() = 0; 72 virtual void Run() = 0;
81 73
82 // Ensures the public key is loaded. 74 // Ensures the public key is loaded.
83 void EnsurePublicKey(const base::Closure& callback); 75 void EnsurePublicKey(const base::Closure& callback);
84 76
85 // Starts a load operation. 77 // Starts a load operation.
86 void StartLoading(); 78 void StartLoading();
87 79
88 // Reports the result status of the operation. Once this gets called, the 80 // Reports the result status of the operation. Once this gets called, the
89 // operation should not perform further processing or trigger callbacks. 81 // operation should not perform further processing or trigger callbacks.
90 void ReportResult(DeviceSettingsService::Status status); 82 void ReportResult(DeviceSettingsService::Status status);
91 83
92 SessionManagerClient* session_manager_client() { 84 SessionManagerClient* session_manager_client() {
93 return session_manager_client_; 85 return session_manager_client_;
94 } 86 }
95 87
96 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_;
97
98 private: 88 private:
99 // Loads the owner key from disk. Must be run on a thread that can do I/O. 89 // Loads the owner key from disk. Must be run on a thread that can do I/O.
100 static scoped_refptr<ownership::PublicKey> LoadPublicKey( 90 static scoped_refptr<ownership::PublicKey> LoadPublicKey(
101 scoped_refptr<ownership::OwnerKeyUtil> util, 91 scoped_refptr<ownership::OwnerKeyUtil> util,
102 scoped_refptr<ownership::PublicKey> current_key); 92 scoped_refptr<ownership::PublicKey> current_key);
103 93
104 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. 94 // Stores the owner key loaded by LoadOwnerKey and calls |callback|.
105 void StorePublicKey(const base::Closure& callback, 95 void StorePublicKey(const base::Closure& callback,
106 scoped_refptr<ownership::PublicKey> new_key); 96 scoped_refptr<ownership::PublicKey> new_key);
107 97
108 // Triggers a device settings load. 98 // Triggers a device settings load.
109 void RetrieveDeviceSettings(); 99 void RetrieveDeviceSettings();
110 100
111 // Validates device settings after retrieval from session_manager. 101 // Validates device settings after retrieval from session_manager.
112 void ValidateDeviceSettings(const std::string& policy_blob); 102 void ValidateDeviceSettings(const std::string& policy_blob);
113 103
114 // Extracts status and device settings from the validator and reports them. 104 // Extracts status and device settings from the validator and reports them.
115 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); 105 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator);
116 106
117 SessionManagerClient* session_manager_client_; 107 SessionManagerClient* session_manager_client_;
118 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; 108 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
119 109
120 Callback callback_; 110 Callback callback_;
121 111
122 scoped_refptr<ownership::PublicKey> public_key_; 112 scoped_refptr<ownership::PublicKey> public_key_;
123 bool force_key_load_; 113 bool force_key_load_;
124 std::string username_;
125 114
126 bool is_loading_; 115 bool is_loading_;
127 scoped_ptr<enterprise_management::PolicyData> policy_data_; 116 scoped_ptr<enterprise_management::PolicyData> policy_data_;
128 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; 117 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_;
129 118
130 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; 119 base::WeakPtrFactory<SessionManagerOperation> weak_factory_;
131 120
132 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); 121 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation);
133 }; 122 };
134 123
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Handles the result of the store operation and triggers the load. 155 // Handles the result of the store operation and triggers the load.
167 void HandleStoreResult(bool success); 156 void HandleStoreResult(bool success);
168 157
169 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_; 158 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_;
170 159
171 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_; 160 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_;
172 161
173 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation); 162 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation);
174 }; 163 };
175 164
176 // Signs device settings and stores the resulting blob to session_manager.
177 class SignAndStoreSettingsOperation : public SessionManagerOperation {
178 public:
179 // Creates a new sign-and-store operation.
180 SignAndStoreSettingsOperation(
181 const Callback& callback,
182 scoped_ptr<enterprise_management::PolicyData> new_policy);
183 virtual ~SignAndStoreSettingsOperation();
184
185 // SessionManagerOperation:
186 virtual void Run() override;
187
188 private:
189 void StartSigning(bool has_private_key);
190
191 // Stores the signed device settings blob.
192 void StoreDeviceSettings(
193 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response);
194
195 // Handles the result of the store operation and triggers the load.
196 void HandleStoreResult(bool success);
197
198 scoped_ptr<enterprise_management::PolicyData> new_policy_;
199
200 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_;
201
202 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation);
203 };
204
205 } // namespace chromeos 165 } // namespace chromeos
206 166
207 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ 167 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698