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

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

Issue 640063008: Revert of Implemented OwnerSettingsService::Set() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 <deque>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" 14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
15 #include "chromeos/dbus/session_manager_client.h" 15 #include "chromeos/dbus/session_manager_client.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/ownership/owner_key_util.h" 17 #include "components/ownership/owner_key_util.h"
18 #include "components/ownership/owner_settings_service.h" 18 #include "components/ownership/owner_settings_service.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 21
22 class Profile; 22 class Profile;
23 23
24 namespace ownership { 24 namespace ownership {
25 class OwnerKeyUtil; 25 class OwnerKeyUtil;
26 } 26 }
27 27
28 namespace chromeos { 28 namespace chromeos {
29 29
30 class SessionManagerOperation;
31
30 // The class is a profile-keyed service which holds public/private 32 // The class is a profile-keyed service which holds public/private
31 // keypair corresponds to a profile. The keypair is reloaded automatically when 33 // keypair corresponds to a profile. The keypair is reloaded automatically when
32 // 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
33 // key can be loaded only for the owner. 35 // key can be loaded only for the owner.
34 // 36 //
35 // TODO (ygorshenin@): move write path for device settings here 37 // TODO (ygorshenin@): move write path for device settings here
36 // (crbug.com/230018). 38 // (crbug.com/230018).
37 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, 39 class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
38 public content::NotificationObserver, 40 public content::NotificationObserver,
39 public SessionManagerClient::Observer, 41 public SessionManagerClient::Observer {
40 public DeviceSettingsService::Observer {
41 public: 42 public:
42 virtual ~OwnerSettingsServiceChromeOS(); 43 virtual ~OwnerSettingsServiceChromeOS();
43 44
44 void OnTPMTokenReady(bool tpm_token_enabled); 45 void OnTPMTokenReady(bool tpm_token_enabled);
45 46
46 // ownership::OwnerSettingsService implementation: 47 // ownership::OwnerSettingsService implementation:
47 virtual bool HandlesSetting(const std::string& setting) override; 48 virtual void SignAndStorePolicyAsync(
48 virtual bool Set(const std::string& setting, 49 scoped_ptr<enterprise_management::PolicyData> policy,
49 const base::Value& value) override; 50 const base::Closure& callback) override;
50 virtual bool CommitTentativeDeviceSettings(
51 scoped_ptr<enterprise_management::PolicyData> policy) override;
52 51
53 // NotificationObserver implementation: 52 // NotificationObserver implementation:
54 virtual void Observe(int type, 53 virtual void Observe(int type,
55 const content::NotificationSource& source, 54 const content::NotificationSource& source,
56 const content::NotificationDetails& details) override; 55 const content::NotificationDetails& details) override;
57 56
58 // SessionManagerClient::Observer: 57 // SessionManagerClient::Observer:
59 virtual void OwnerKeySet(bool success) override; 58 virtual void OwnerKeySet(bool success) override;
60 59
61 // DeviceSettingsService::Observer:
62 virtual void OwnershipStatusChanged() override;
63 virtual void DeviceSettingsUpdated() override;
64
65 // Checks if the user is the device owner, without the user profile having to 60 // Checks if the user is the device owner, without the user profile having to
66 // been initialized. Should be used only if login state is in safe mode. 61 // been initialized. Should be used only if login state is in safe mode.
67 static void IsOwnerForSafeModeAsync( 62 static void IsOwnerForSafeModeAsync(
68 const std::string& user_hash, 63 const std::string& user_hash,
69 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, 64 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util,
70 const IsOwnerCallback& callback); 65 const IsOwnerCallback& callback);
71 66
72 // Assembles PolicyData based on |settings|, |policy_data| and 67 static void SetDeviceSettingsServiceForTesting(
73 // |user_id|. 68 DeviceSettingsService* device_settings_service);
74 static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy(
75 const std::string& user_id,
76 const enterprise_management::PolicyData* policy_data,
77 const enterprise_management::ChromeDeviceSettingsProto* settings);
78
79 // Updates device |settings|.
80 static void UpdateDeviceSettings(
81 const std::string& path,
82 const base::Value& value,
83 enterprise_management::ChromeDeviceSettingsProto& settings);
84
85 bool has_pending_changes() const { return has_pending_changes_; }
86 69
87 private: 70 private:
88 friend class OwnerSettingsServiceChromeOSFactory; 71 friend class OwnerSettingsServiceChromeOSFactory;
89 72
90 OwnerSettingsServiceChromeOS( 73 OwnerSettingsServiceChromeOS(
91 DeviceSettingsService* device_settings_service,
92 Profile* profile, 74 Profile* profile,
93 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util); 75 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util);
94 76
95 // OwnerSettingsService protected interface overrides: 77 // OwnerSettingsService protected interface overrides:
96 78
97 // Reloads private key from profile's NSS slots, responds via |callback|. 79 // Reloads private key from profile's NSS slots, responds via |callback|.
98 virtual void ReloadKeypairImpl(const base::Callback< 80 virtual void ReloadKeypairImpl(const base::Callback<
99 void(const scoped_refptr<ownership::PublicKey>& public_key, 81 void(const scoped_refptr<ownership::PublicKey>& public_key,
100 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback) 82 const scoped_refptr<ownership::PrivateKey>& private_key)>& callback)
101 override; 83 override;
102 84
103 // Possibly notifies DeviceSettingsService that owner's keypair is loaded. 85 // Possibly notifies DeviceSettingsService that owner's keypair is loaded.
104 virtual void OnPostKeypairLoadedActions() override; 86 virtual void OnPostKeypairLoadedActions() override;
105 87
106 // Tries to sign store current device settings if there're pending 88 // Performs next operation in the queue.
107 // changes in device settings and no active previous call to 89 void StartNextOperation();
108 // DeviceSettingsService::Store().
109 void StoreDeviceSettings();
110 90
111 // Called when current device settings are successfully signed. 91 // Called when sign-and-store operation completes it's work.
112 // Sends signed settings for storage. 92 void HandleCompletedOperation(const base::Closure& callback,
113 void OnPolicyAssembledAndSigned( 93 SessionManagerOperation* operation,
114 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response); 94 DeviceSettingsService::Status status);
115
116 // Called by DeviceSettingsService when modified and signed device
117 // settings are stored. Notifies observers and tries to store device
118 // settings again.
119 void OnSignedPolicyStored(bool success);
120
121 // Fetches device settings from DeviceSettingsService and merges
122 // them with local device settings.
123 bool UpdateFromService();
124
125 DeviceSettingsService* device_settings_service_;
126 95
127 // Profile this service instance belongs to. 96 // Profile this service instance belongs to.
128 Profile* profile_; 97 Profile* profile_;
129 98
130 // User ID this service instance belongs to. 99 // User ID this service instance belongs to.
131 std::string user_id_; 100 std::string user_id_;
132 101
133 // Whether profile still needs to be initialized. 102 // Whether profile still needs to be initialized.
134 bool waiting_for_profile_creation_; 103 bool waiting_for_profile_creation_;
135 104
136 // Whether TPM token still needs to be initialized. 105 // Whether TPM token still needs to be initialized.
137 bool waiting_for_tpm_token_; 106 bool waiting_for_tpm_token_;
138 107
139 // The device settings. This may be different from the actual 108 // The queue of pending sign-and-store operations. The first operation on the
140 // current device settings (which can be obtained from 109 // queue is currently active; it gets removed and destroyed once it completes.
141 // DeviceSettingsService) in case the device does not have an owner 110 std::deque<SessionManagerOperation*> pending_operations_;
142 // yet or there are pending changes that have not yet been written
143 // to session_manager.
144 enterprise_management::ChromeDeviceSettingsProto device_settings_;
145
146 // True if some settings were changed but not stored.
147 bool has_pending_changes_;
148 111
149 content::NotificationRegistrar registrar_; 112 content::NotificationRegistrar registrar_;
150 113
151 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; 114 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_;
152 115
153 base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_;
154
155 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); 116 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS);
156 }; 117 };
157 118
158 } // namespace chromeos 119 } // namespace chromeos
159 120
160 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ 121 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698