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

Side by Side Diff: chromeos/dbus/session_manager_client.cc

Issue 2714493002: Load DeviceLocalAccount policy and DeviceSettings immediately on restore after Chrome crash. (Closed)
Patch Set: add flag to correctly process LoadImmediately() call Created 3 years, 10 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
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 #include "chromeos/dbus/session_manager_client.h" 5 #include "chromeos/dbus/session_manager_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 login_manager::kSessionManagerRetrievePolicy); 201 login_manager::kSessionManagerRetrievePolicy);
202 session_manager_proxy_->CallMethod( 202 session_manager_proxy_->CallMethod(
203 &method_call, 203 &method_call,
204 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 204 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
205 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy, 205 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy,
206 weak_ptr_factory_.GetWeakPtr(), 206 weak_ptr_factory_.GetWeakPtr(),
207 login_manager::kSessionManagerRetrievePolicy, 207 login_manager::kSessionManagerRetrievePolicy,
208 callback)); 208 callback));
209 } 209 }
210 210
211 std::string BlockingRetrieveDevicePolicy() override {
212 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
213 login_manager::kSessionManagerRetrievePolicy);
214 std::unique_ptr<dbus::Response> response =
215 blocking_method_caller_->CallMethodAndBlock(&method_call);
216 std::string policy;
217 ExtractString(login_manager::kSessionManagerRetrievePolicy, response.get(),
218 &policy);
219 return policy;
220 }
221
211 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id, 222 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
212 const RetrievePolicyCallback& callback) override { 223 const RetrievePolicyCallback& callback) override {
213 CallRetrievePolicyByUsername( 224 CallRetrievePolicyByUsername(
214 login_manager::kSessionManagerRetrievePolicyForUser, cryptohome_id.id(), 225 login_manager::kSessionManagerRetrievePolicyForUser, cryptohome_id.id(),
215 callback); 226 callback);
216 } 227 }
217 228
218 std::string BlockingRetrievePolicyForUser( 229 std::string BlockingRetrievePolicyForUser(
219 const cryptohome::Identification& cryptohome_id) override { 230 const cryptohome::Identification& cryptohome_id) override {
220 dbus::MethodCall method_call( 231 dbus::MethodCall method_call(
(...skipping 12 matching lines...) Expand all
233 244
234 void RetrieveDeviceLocalAccountPolicy( 245 void RetrieveDeviceLocalAccountPolicy(
235 const std::string& account_name, 246 const std::string& account_name,
236 const RetrievePolicyCallback& callback) override { 247 const RetrievePolicyCallback& callback) override {
237 CallRetrievePolicyByUsername( 248 CallRetrievePolicyByUsername(
238 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, 249 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy,
239 account_name, 250 account_name,
240 callback); 251 callback);
241 } 252 }
242 253
254 std::string BlockingRetrieveDeviceLocalAccountPolicy(
255 const std::string& account_name) override {
256 dbus::MethodCall method_call(
257 login_manager::kSessionManagerInterface,
258 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy);
259 dbus::MessageWriter writer(&method_call);
260 writer.AppendString(account_name);
261 std::unique_ptr<dbus::Response> response =
262 blocking_method_caller_->CallMethodAndBlock(&method_call);
263 std::string policy;
264 ExtractString(
265 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy,
266 response.get(), &policy);
267 return policy;
268 }
269
243 void StoreDevicePolicy(const std::string& policy_blob, 270 void StoreDevicePolicy(const std::string& policy_blob,
244 const StorePolicyCallback& callback) override { 271 const StorePolicyCallback& callback) override {
245 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, 272 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
246 login_manager::kSessionManagerStorePolicy); 273 login_manager::kSessionManagerStorePolicy);
247 dbus::MessageWriter writer(&method_call); 274 dbus::MessageWriter writer(&method_call);
248 // static_cast does not work due to signedness. 275 // static_cast does not work due to signedness.
249 writer.AppendArrayOfBytes( 276 writer.AppendArrayOfBytes(
250 reinterpret_cast<const uint8_t*>(policy_blob.data()), 277 reinterpret_cast<const uint8_t*>(policy_blob.data()),
251 policy_blob.size()); 278 policy_blob.size());
252 session_manager_proxy_->CallMethod( 279 session_manager_proxy_->CallMethod(
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 863 }
837 base::FilePath device_policy_path = 864 base::FilePath device_policy_path =
838 owner_key_path.DirName().AppendASCII("stub_device_policy"); 865 owner_key_path.DirName().AppendASCII("stub_device_policy");
839 base::PostTaskWithTraitsAndReplyWithResult( 866 base::PostTaskWithTraitsAndReplyWithResult(
840 FROM_HERE, base::TaskTraits() 867 FROM_HERE, base::TaskTraits()
841 .WithShutdownBehavior( 868 .WithShutdownBehavior(
842 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) 869 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
843 .MayBlock(), 870 .MayBlock(),
844 base::Bind(&GetFileContent, device_policy_path), callback); 871 base::Bind(&GetFileContent, device_policy_path), callback);
845 } 872 }
873 std::string BlockingRetrieveDevicePolicy() override {
874 base::FilePath owner_key_path;
875 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) {
876 return "";
877 }
878 base::FilePath device_policy_path =
879 owner_key_path.DirName().AppendASCII("stub_device_policy");
emaxx 2017/02/22 17:24:34 nit: Maybe define a constant for this string? Or e
Sergey Poromov 2017/02/28 14:01:17 Done.
880 return GetFileContent(device_policy_path);
881 }
846 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id, 882 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
847 const RetrievePolicyCallback& callback) override { 883 const RetrievePolicyCallback& callback) override {
848 base::PostTaskWithTraitsAndReplyWithResult( 884 base::PostTaskWithTraitsAndReplyWithResult(
849 FROM_HERE, base::TaskTraits() 885 FROM_HERE, base::TaskTraits()
850 .WithShutdownBehavior( 886 .WithShutdownBehavior(
851 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) 887 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
852 .MayBlock(), 888 .MayBlock(),
853 base::Bind(&GetFileContent, 889 base::Bind(&GetFileContent,
854 GetUserFilePath(cryptohome_id, "stub_policy")), 890 GetUserFilePath(cryptohome_id, "stub_policy")),
855 callback); 891 callback);
856 } 892 }
857 std::string BlockingRetrievePolicyForUser( 893 std::string BlockingRetrievePolicyForUser(
858 const cryptohome::Identification& cryptohome_id) override { 894 const cryptohome::Identification& cryptohome_id) override {
859 return GetFileContent(GetUserFilePath(cryptohome_id, "stub_policy")); 895 return GetFileContent(GetUserFilePath(cryptohome_id, "stub_policy"));
860 } 896 }
861 void RetrieveDeviceLocalAccountPolicy( 897 void RetrieveDeviceLocalAccountPolicy(
862 const std::string& account_id, 898 const std::string& account_id,
863 const RetrievePolicyCallback& callback) override { 899 const RetrievePolicyCallback& callback) override {
864 RetrievePolicyForUser(cryptohome::Identification::FromString(account_id), 900 RetrievePolicyForUser(cryptohome::Identification::FromString(account_id),
865 callback); 901 callback);
866 } 902 }
903 std::string BlockingRetrieveDeviceLocalAccountPolicy(
904 const std::string& account_id) override {
905 return BlockingRetrievePolicyForUser(
906 cryptohome::Identification::FromString(account_id));
907 }
867 void StoreDevicePolicy(const std::string& policy_blob, 908 void StoreDevicePolicy(const std::string& policy_blob,
868 const StorePolicyCallback& callback) override { 909 const StorePolicyCallback& callback) override {
869 enterprise_management::PolicyFetchResponse response; 910 enterprise_management::PolicyFetchResponse response;
870 base::FilePath owner_key_path; 911 base::FilePath owner_key_path;
871 if (!response.ParseFromString(policy_blob) || 912 if (!response.ParseFromString(policy_blob) ||
872 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { 913 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) {
873 callback.Run(false); 914 callback.Run(false);
874 return; 915 return;
875 } 916 }
876 917
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1049
1009 SessionManagerClient* SessionManagerClient::Create( 1050 SessionManagerClient* SessionManagerClient::Create(
1010 DBusClientImplementationType type) { 1051 DBusClientImplementationType type) {
1011 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 1052 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
1012 return new SessionManagerClientImpl(); 1053 return new SessionManagerClientImpl();
1013 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); 1054 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
1014 return new SessionManagerClientStubImpl(); 1055 return new SessionManagerClientStubImpl();
1015 } 1056 }
1016 1057
1017 } // namespace chromeos 1058 } // namespace chromeos
OLDNEW
« chromeos/dbus/session_manager_client.h ('K') | « chromeos/dbus/session_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698