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

Side by Side Diff: chrome/browser/chromeos/ownership/owner_settings_service.h

Issue 494093002: OwnerKeyUtil is moved to components/ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed GYP file. Created 6 years, 3 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 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_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/chromeos/settings/device_settings_service.h" 16 #include "chrome/browser/chromeos/settings/device_settings_service.h"
17 #include "chrome/browser/chromeos/settings/owner_key_util.h"
18 #include "chromeos/dbus/session_manager_client.h" 17 #include "chromeos/dbus/session_manager_client.h"
19 #include "chromeos/tpm_token_loader.h" 18 #include "chromeos/tpm_token_loader.h"
20 #include "components/keyed_service/core/keyed_service.h" 19 #include "components/keyed_service/core/keyed_service.h"
20 #include "components/ownership/owner_key_util.h"
21 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 23
24 class Profile; 24 class Profile;
25 25
26 namespace chromeos { 26 namespace chromeos {
27 27
28 class SessionManagerOperation; 28 class SessionManagerOperation;
29 29
30 // This class reloads owner key from profile NSS slots. 30 // This class reloads owner key from profile NSS slots.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // SessionManagerClient::Observer: 69 // SessionManagerClient::Observer:
70 virtual void OwnerKeySet(bool success) OVERRIDE; 70 virtual void OwnerKeySet(bool success) OVERRIDE;
71 71
72 // Checks if the user is the device owner, without the user profile having to 72 // Checks if the user is the device owner, without the user profile having to
73 // been initialized. Should be used only if login state is in safe mode. 73 // been initialized. Should be used only if login state is in safe mode.
74 static void IsOwnerForSafeModeAsync(const std::string& user_id, 74 static void IsOwnerForSafeModeAsync(const std::string& user_id,
75 const std::string& user_hash, 75 const std::string& user_hash,
76 const IsOwnerCallback& callback); 76 const IsOwnerCallback& callback);
77 77
78 static scoped_refptr<ownership::OwnerKeyUtil> MakeOwnerKeyUtil();
79
78 static void SetOwnerKeyUtilForTesting( 80 static void SetOwnerKeyUtilForTesting(
79 const scoped_refptr<OwnerKeyUtil>& owner_key_util); 81 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util);
80 82
81 static void SetDeviceSettingsServiceForTesting( 83 static void SetDeviceSettingsServiceForTesting(
82 DeviceSettingsService* device_settings_service); 84 DeviceSettingsService* device_settings_service);
83 85
84 private: 86 private:
85 friend class OwnerSettingsServiceFactory; 87 friend class OwnerSettingsServiceFactory;
86 88
87 explicit OwnerSettingsService(Profile* profile); 89 explicit OwnerSettingsService(Profile* profile);
88 90
89 // Reloads private key from profile's NSS slots. Responds via call 91 // Reloads private key from profile's NSS slots. Responds via call
90 // to OnPrivateKeyLoaded(). 92 // to OnPrivateKeyLoaded().
91 void ReloadPrivateKey(); 93 void ReloadPrivateKey();
92 94
93 // Called when ReloadPrivateKey() completes it's work. 95 // Called when ReloadPrivateKey() completes it's work.
94 void OnPrivateKeyLoaded(scoped_refptr<PublicKey> public_key, 96 void OnPrivateKeyLoaded(scoped_refptr<ownership::PublicKey> public_key,
95 scoped_refptr<PrivateKey> private_key); 97 scoped_refptr<ownership::PrivateKey> private_key);
96 98
97 // Puts request to perform sign-and-store operation in the queue. 99 // Puts request to perform sign-and-store operation in the queue.
98 void EnqueueSignAndStore(scoped_ptr<enterprise_management::PolicyData> policy, 100 void EnqueueSignAndStore(scoped_ptr<enterprise_management::PolicyData> policy,
99 const base::Closure& callback); 101 const base::Closure& callback);
100 102
101 // Performs next operation in the queue. 103 // Performs next operation in the queue.
102 void StartNextOperation(); 104 void StartNextOperation();
103 105
104 // Called when sign-and-store operation completes it's work. 106 // Called when sign-and-store operation completes it's work.
105 void HandleCompletedOperation(const base::Closure& callback, 107 void HandleCompletedOperation(const base::Closure& callback,
106 SessionManagerOperation* operation, 108 SessionManagerOperation* operation,
107 DeviceSettingsService::Status status); 109 DeviceSettingsService::Status status);
108 110
109 // Called when it's not possible to store settings. 111 // Called when it's not possible to store settings.
110 void HandleError(DeviceSettingsService::Status status, 112 void HandleError(DeviceSettingsService::Status status,
111 const base::Closure& callback); 113 const base::Closure& callback);
112 114
113 // Returns testing instance of OwnerKeyUtil when it's set, otherwise 115 // Returns testing instance of OwnerKeyUtil when it's set, otherwise
114 // returns |owner_key_util_|. 116 // returns |owner_key_util_|.
115 scoped_refptr<OwnerKeyUtil> GetOwnerKeyUtil(); 117 scoped_refptr<ownership::OwnerKeyUtil> GetOwnerKeyUtil();
116 118
117 // Returns testing instance of DeviceSettingsService when it's set, 119 // Returns testing instance of DeviceSettingsService when it's set,
118 // otherwise returns pointer to a singleton instance, when it's 120 // otherwise returns pointer to a singleton instance, when it's
119 // initialized. 121 // initialized.
120 DeviceSettingsService* GetDeviceSettingsService(); 122 DeviceSettingsService* GetDeviceSettingsService();
121 123
122 // Profile this service instance belongs to. 124 // Profile this service instance belongs to.
123 Profile* profile_; 125 Profile* profile_;
124 126
125 // User ID this service instance belongs to. 127 // User ID this service instance belongs to.
126 std::string user_id_; 128 std::string user_id_;
127 129
128 scoped_refptr<PublicKey> public_key_; 130 scoped_refptr<ownership::PublicKey> public_key_;
129 131
130 scoped_refptr<PrivateKey> private_key_; 132 scoped_refptr<ownership::PrivateKey> private_key_;
131 133
132 scoped_refptr<OwnerKeyUtil> owner_key_util_; 134 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
133 135
134 std::vector<IsOwnerCallback> pending_is_owner_callbacks_; 136 std::vector<IsOwnerCallback> pending_is_owner_callbacks_;
135 137
136 // Whether profile still needs to be initialized. 138 // Whether profile still needs to be initialized.
137 bool waiting_for_profile_creation_; 139 bool waiting_for_profile_creation_;
138 140
139 // Whether TPM token still needs to be initialized. 141 // Whether TPM token still needs to be initialized.
140 bool waiting_for_tpm_token_; 142 bool waiting_for_tpm_token_;
141 143
142 // The queue of pending sign-and-store operations. The first operation on the 144 // The queue of pending sign-and-store operations. The first operation on the
143 // queue is currently active; it gets removed and destroyed once it completes. 145 // queue is currently active; it gets removed and destroyed once it completes.
144 std::deque<SessionManagerOperation*> pending_operations_; 146 std::deque<SessionManagerOperation*> pending_operations_;
145 147
146 content::NotificationRegistrar registrar_; 148 content::NotificationRegistrar registrar_;
147 149
148 base::ThreadChecker thread_checker_; 150 base::ThreadChecker thread_checker_;
149 151
150 base::WeakPtrFactory<OwnerSettingsService> weak_factory_; 152 base::WeakPtrFactory<OwnerSettingsService> weak_factory_;
151 153
152 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService); 154 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService);
153 }; 155 };
154 156
155 } // namespace chromeos 157 } // namespace chromeos
156 158
157 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ 159 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698