| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chromeos/dbus/auth_policy_client.h" | 4 #include "chromeos/dbus/auth_policy_client.h" |
| 5 | 5 |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "components/signin/core/account_id/account_id.h" | 8 #include "components/signin/core/account_id/account_id.h" |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
| 11 #include "dbus/object_proxy.h" | 11 #include "dbus/object_proxy.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // The first device policy fetch after joining Active Directory can be very slow |
| 18 // because machine credentials need to propagate through the AD deployment. |
| 19 const int kRefreshDevicePolicyTimeoutMilliseconds = 90000; |
| 20 |
| 17 authpolicy::ErrorType GetErrorFromReader(dbus::MessageReader* reader) { | 21 authpolicy::ErrorType GetErrorFromReader(dbus::MessageReader* reader) { |
| 18 int32_t int_error; | 22 int32_t int_error; |
| 19 if (!reader->PopInt32(&int_error)) { | 23 if (!reader->PopInt32(&int_error)) { |
| 20 DLOG(ERROR) << "AuthPolicyClient: Failed to get an error from the response"; | 24 DLOG(ERROR) << "AuthPolicyClient: Failed to get an error from the response"; |
| 21 return authpolicy::ERROR_DBUS_FAILURE; | 25 return authpolicy::ERROR_DBUS_FAILURE; |
| 22 } | 26 } |
| 23 if (int_error < 0 || int_error >= authpolicy::ERROR_COUNT) | 27 if (int_error < 0 || int_error >= authpolicy::ERROR_COUNT) |
| 24 return authpolicy::ERROR_UNKNOWN; | 28 return authpolicy::ERROR_UNKNOWN; |
| 25 return static_cast<authpolicy::ErrorType>(int_error); | 29 return static_cast<authpolicy::ErrorType>(int_error); |
| 26 } | 30 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 57 writer.AppendFileDescriptor(password_fd); | 61 writer.AppendFileDescriptor(password_fd); |
| 58 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 62 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 59 base::Bind(&AuthPolicyClientImpl::HandleAuthCallback, | 63 base::Bind(&AuthPolicyClientImpl::HandleAuthCallback, |
| 60 weak_ptr_factory_.GetWeakPtr(), callback)); | 64 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 61 } | 65 } |
| 62 | 66 |
| 63 void RefreshDevicePolicy(const RefreshPolicyCallback& callback) override { | 67 void RefreshDevicePolicy(const RefreshPolicyCallback& callback) override { |
| 64 dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, | 68 dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, |
| 65 authpolicy::kAuthPolicyRefreshDevicePolicy); | 69 authpolicy::kAuthPolicyRefreshDevicePolicy); |
| 66 proxy_->CallMethod( | 70 proxy_->CallMethod( |
| 67 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 71 &method_call, kRefreshDevicePolicyTimeoutMilliseconds, |
| 68 base::Bind(&AuthPolicyClientImpl::HandleRefreshPolicyCallback, | 72 base::Bind(&AuthPolicyClientImpl::HandleRefreshPolicyCallback, |
| 69 weak_ptr_factory_.GetWeakPtr(), callback)); | 73 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void RefreshUserPolicy(const AccountId& account_id, | 76 void RefreshUserPolicy(const AccountId& account_id, |
| 73 const RefreshPolicyCallback& callback) override { | 77 const RefreshPolicyCallback& callback) override { |
| 74 DCHECK(account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY); | 78 DCHECK(account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY); |
| 75 dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, | 79 dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, |
| 76 authpolicy::kAuthPolicyRefreshUserPolicy); | 80 authpolicy::kAuthPolicyRefreshUserPolicy); |
| 77 dbus::MessageWriter writer(&method_call); | 81 dbus::MessageWriter writer(&method_call); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 AuthPolicyClient::AuthPolicyClient() {} | 147 AuthPolicyClient::AuthPolicyClient() {} |
| 144 | 148 |
| 145 AuthPolicyClient::~AuthPolicyClient() {} | 149 AuthPolicyClient::~AuthPolicyClient() {} |
| 146 | 150 |
| 147 // static | 151 // static |
| 148 AuthPolicyClient* AuthPolicyClient::Create() { | 152 AuthPolicyClient* AuthPolicyClient::Create() { |
| 149 return new AuthPolicyClientImpl(); | 153 return new AuthPolicyClientImpl(); |
| 150 } | 154 } |
| 151 | 155 |
| 152 } // namespace chromeos | 156 } // namespace chromeos |
| OLD | NEW |