OLD | NEW |
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> |
| 8 #include <stdint.h> |
7 #include <sys/socket.h> | 9 #include <sys/socket.h> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" |
14 #include "base/path_service.h" | 17 #include "base/path_service.h" |
15 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
17 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
18 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
19 #include "chromeos/chromeos_paths.h" | 22 #include "chromeos/chromeos_paths.h" |
20 #include "chromeos/dbus/blocking_method_caller.h" | 23 #include "chromeos/dbus/blocking_method_caller.h" |
21 #include "chromeos/dbus/cryptohome_client.h" | 24 #include "chromeos/dbus/cryptohome_client.h" |
22 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
23 #include "dbus/bus.h" | 26 #include "dbus/bus.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 callback); | 271 callback); |
269 } | 272 } |
270 | 273 |
271 void StoreDevicePolicy(const std::string& policy_blob, | 274 void StoreDevicePolicy(const std::string& policy_blob, |
272 const StorePolicyCallback& callback) override { | 275 const StorePolicyCallback& callback) override { |
273 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 276 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
274 login_manager::kSessionManagerStorePolicy); | 277 login_manager::kSessionManagerStorePolicy); |
275 dbus::MessageWriter writer(&method_call); | 278 dbus::MessageWriter writer(&method_call); |
276 // static_cast does not work due to signedness. | 279 // static_cast does not work due to signedness. |
277 writer.AppendArrayOfBytes( | 280 writer.AppendArrayOfBytes( |
278 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | 281 reinterpret_cast<const uint8_t*>(policy_blob.data()), |
| 282 policy_blob.size()); |
279 session_manager_proxy_->CallMethod( | 283 session_manager_proxy_->CallMethod( |
280 &method_call, | 284 &method_call, |
281 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 285 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
282 base::Bind(&SessionManagerClientImpl::OnStorePolicy, | 286 base::Bind(&SessionManagerClientImpl::OnStorePolicy, |
283 weak_ptr_factory_.GetWeakPtr(), | 287 weak_ptr_factory_.GetWeakPtr(), |
284 login_manager::kSessionManagerStorePolicy, | 288 login_manager::kSessionManagerStorePolicy, |
285 callback)); | 289 callback)); |
286 } | 290 } |
287 | 291 |
288 void StorePolicyForUser(const std::string& username, | 292 void StorePolicyForUser(const std::string& username, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 void CallStorePolicyByUsername(const std::string& method_name, | 442 void CallStorePolicyByUsername(const std::string& method_name, |
439 const std::string& username, | 443 const std::string& username, |
440 const std::string& policy_blob, | 444 const std::string& policy_blob, |
441 const StorePolicyCallback& callback) { | 445 const StorePolicyCallback& callback) { |
442 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 446 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
443 method_name); | 447 method_name); |
444 dbus::MessageWriter writer(&method_call); | 448 dbus::MessageWriter writer(&method_call); |
445 writer.AppendString(username); | 449 writer.AppendString(username); |
446 // static_cast does not work due to signedness. | 450 // static_cast does not work due to signedness. |
447 writer.AppendArrayOfBytes( | 451 writer.AppendArrayOfBytes( |
448 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | 452 reinterpret_cast<const uint8_t*>(policy_blob.data()), |
| 453 policy_blob.size()); |
449 session_manager_proxy_->CallMethod( | 454 session_manager_proxy_->CallMethod( |
450 &method_call, | 455 &method_call, |
451 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 456 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
452 base::Bind( | 457 base::Bind( |
453 &SessionManagerClientImpl::OnStorePolicy, | 458 &SessionManagerClientImpl::OnStorePolicy, |
454 weak_ptr_factory_.GetWeakPtr(), | 459 weak_ptr_factory_.GetWeakPtr(), |
455 method_name, | 460 method_name, |
456 callback)); | 461 callback)); |
457 } | 462 } |
458 | 463 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 553 } |
549 | 554 |
550 void ExtractString(const std::string& method_name, | 555 void ExtractString(const std::string& method_name, |
551 dbus::Response* response, | 556 dbus::Response* response, |
552 std::string* extracted) { | 557 std::string* extracted) { |
553 if (!response) { | 558 if (!response) { |
554 LOG(ERROR) << "Failed to call " << method_name; | 559 LOG(ERROR) << "Failed to call " << method_name; |
555 return; | 560 return; |
556 } | 561 } |
557 dbus::MessageReader reader(response); | 562 dbus::MessageReader reader(response); |
558 const uint8* values = NULL; | 563 const uint8_t* values = NULL; |
559 size_t length = 0; | 564 size_t length = 0; |
560 if (!reader.PopArrayOfBytes(&values, &length)) { | 565 if (!reader.PopArrayOfBytes(&values, &length)) { |
561 LOG(ERROR) << "Invalid response: " << response->ToString(); | 566 LOG(ERROR) << "Invalid response: " << response->ToString(); |
562 return; | 567 return; |
563 } | 568 } |
564 // static_cast does not work due to signedness. | 569 // static_cast does not work due to signedness. |
565 extracted->assign(reinterpret_cast<const char*>(values), length); | 570 extracted->assign(reinterpret_cast<const char*>(values), length); |
566 } | 571 } |
567 | 572 |
568 // Called when kSessionManagerRetrievePolicy or | 573 // Called when kSessionManagerRetrievePolicy or |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 LOG(ERROR) << "Failed to call " | 647 LOG(ERROR) << "Failed to call " |
643 << login_manager::kSessionManagerGetServerBackedStateKeys; | 648 << login_manager::kSessionManagerGetServerBackedStateKeys; |
644 } else { | 649 } else { |
645 dbus::MessageReader reader(response); | 650 dbus::MessageReader reader(response); |
646 dbus::MessageReader array_reader(NULL); | 651 dbus::MessageReader array_reader(NULL); |
647 | 652 |
648 if (!reader.PopArray(&array_reader)) { | 653 if (!reader.PopArray(&array_reader)) { |
649 LOG(ERROR) << "Bad response: " << response->ToString(); | 654 LOG(ERROR) << "Bad response: " << response->ToString(); |
650 } else { | 655 } else { |
651 while (array_reader.HasMoreData()) { | 656 while (array_reader.HasMoreData()) { |
652 const uint8* data = NULL; | 657 const uint8_t* data = NULL; |
653 size_t size = 0; | 658 size_t size = 0; |
654 if (!array_reader.PopArrayOfBytes(&data, &size)) { | 659 if (!array_reader.PopArrayOfBytes(&data, &size)) { |
655 LOG(ERROR) << "Bad response: " << response->ToString(); | 660 LOG(ERROR) << "Bad response: " << response->ToString(); |
656 state_keys.clear(); | 661 state_keys.clear(); |
657 break; | 662 break; |
658 } | 663 } |
659 state_keys.push_back( | 664 state_keys.push_back( |
660 std::string(reinterpret_cast<const char*>(data), size)); | 665 std::string(reinterpret_cast<const char*>(data), size)); |
661 } | 666 } |
662 } | 667 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 | 898 |
894 SessionManagerClient* SessionManagerClient::Create( | 899 SessionManagerClient* SessionManagerClient::Create( |
895 DBusClientImplementationType type) { | 900 DBusClientImplementationType type) { |
896 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 901 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
897 return new SessionManagerClientImpl(); | 902 return new SessionManagerClientImpl(); |
898 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 903 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
899 return new SessionManagerClientStubImpl(); | 904 return new SessionManagerClientStubImpl(); |
900 } | 905 } |
901 | 906 |
902 } // namespace chromeos | 907 } // namespace chromeos |
OLD | NEW |