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

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

Issue 270663002: Implemented profile-aware owner key loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed DeviceOAuth2TokenServiceTest.* unit_tests. Created 6 years, 7 months 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 | Annotate | Revision Log
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 "crypto/scoped_nss_types.h"
14 15
15 namespace enterprise_management { 16 namespace enterprise_management {
16 class ChromeDeviceSettingsProto; 17 class ChromeDeviceSettingsProto;
17 class PolicyData; 18 class PolicyData;
18 class PolicyFetchResponse; 19 class PolicyFetchResponse;
19 } 20 }
20 21
21 namespace chromeos { 22 namespace chromeos {
22 23
23 class OwnerKeyUtil; 24 class OwnerKeyUtil;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 60
60 // Whether the load operation is underway. 61 // Whether the load operation is underway.
61 bool is_loading() const { 62 bool is_loading() const {
62 return is_loading_; 63 return is_loading_;
63 } 64 }
64 65
65 void set_force_key_load(bool force_key_load) { 66 void set_force_key_load(bool force_key_load) {
66 force_key_load_ = force_key_load; 67 force_key_load_ = force_key_load;
67 } 68 }
68 69
70 void set_username(const std::string& username) { username_ = username; }
71
69 protected: 72 protected:
70 // Runs the operation. The result is reported through |callback_|. 73 // Runs the operation. The result is reported through |callback_|.
71 virtual void Run() = 0; 74 virtual void Run() = 0;
72 75
73 // Ensures the owner key is loaded. 76 // Ensures the owner key is loaded.
74 void EnsureOwnerKey(const base::Closure& callback); 77 void EnsureOwnerKey(const base::Closure& callback);
75 78
76 // Starts a load operation. 79 // Starts a load operation.
77 void StartLoading(); 80 void StartLoading();
78 81
79 // Reports the result status of the operation. Once this gets called, the 82 // Reports the result status of the operation. Once this gets called, the
80 // operation should not perform further processing or trigger callbacks. 83 // operation should not perform further processing or trigger callbacks.
81 void ReportResult(DeviceSettingsService::Status status); 84 void ReportResult(DeviceSettingsService::Status status);
82 85
83 SessionManagerClient* session_manager_client() { 86 SessionManagerClient* session_manager_client() {
84 return session_manager_client_; 87 return session_manager_client_;
85 } 88 }
86 89
87 private: 90 private:
91 // Calls LoadOwnerKey() on blocking pool and passes the result to
92 // StoreOwnerKey().
93 static void LoadAndStoreOwnerKey(
94 base::WeakPtr<SessionManagerOperation> weak_ptr,
95 scoped_refptr<OwnerKeyUtil> util,
96 scoped_refptr<OwnerKey> current_key,
97 const base::Closure& callback,
98 crypto::ScopedPK11Slot slot);
99
88 // Loads the owner key from disk. Must be run on a thread that can do I/O. 100 // Loads the owner key from disk. Must be run on a thread that can do I/O.
89 static scoped_refptr<OwnerKey> LoadOwnerKey( 101 static scoped_refptr<OwnerKey> LoadOwnerKey(
90 scoped_refptr<OwnerKeyUtil> util, 102 scoped_refptr<OwnerKeyUtil> util,
91 scoped_refptr<OwnerKey> current_key); 103 scoped_refptr<OwnerKey> current_key,
104 crypto::ScopedPK11Slot slot);
92 105
93 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. 106 // Stores the owner key loaded by LoadOwnerKey and calls |callback|.
94 void StoreOwnerKey(const base::Closure& callback, 107 void StoreOwnerKey(const base::Closure& callback,
95 scoped_refptr<OwnerKey> new_key); 108 scoped_refptr<OwnerKey> new_key);
96 109
97 // Triggers a device settings load. 110 // Triggers a device settings load.
98 void RetrieveDeviceSettings(); 111 void RetrieveDeviceSettings();
99 112
100 // Validates device settings after retrieval from session_manager. 113 // Validates device settings after retrieval from session_manager.
101 void ValidateDeviceSettings(const std::string& policy_blob); 114 void ValidateDeviceSettings(const std::string& policy_blob);
102 115
103 // Extracts status and device settings from the validator and reports them. 116 // Extracts status and device settings from the validator and reports them.
104 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); 117 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator);
105 118
106 SessionManagerClient* session_manager_client_; 119 SessionManagerClient* session_manager_client_;
107 scoped_refptr<OwnerKeyUtil> owner_key_util_; 120 scoped_refptr<OwnerKeyUtil> owner_key_util_;
108 121
109 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; 122 base::WeakPtrFactory<SessionManagerOperation> weak_factory_;
110 123
111 Callback callback_; 124 Callback callback_;
112 125
113 scoped_refptr<OwnerKey> owner_key_; 126 scoped_refptr<OwnerKey> owner_key_;
114 bool force_key_load_; 127 bool force_key_load_;
128 std::string username_;
115 129
116 bool is_loading_; 130 bool is_loading_;
117 scoped_ptr<enterprise_management::PolicyData> policy_data_; 131 scoped_ptr<enterprise_management::PolicyData> policy_data_;
118 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; 132 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_;
119 133
120 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); 134 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation);
121 }; 135 };
122 136
123 // This operation loads the public owner key from disk if appropriate, fetches 137 // This operation loads the public owner key from disk if appropriate, fetches
124 // the policy blob from session manager, and validates the loaded policy blob. 138 // the policy blob from session manager, and validates the loaded policy blob.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 scoped_ptr<enterprise_management::PolicyData> new_policy_; 205 scoped_ptr<enterprise_management::PolicyData> new_policy_;
192 206
193 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_; 207 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_;
194 208
195 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation); 209 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation);
196 }; 210 };
197 211
198 } // namespace chromeos 212 } // namespace chromeos
199 213
200 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ 214 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698