Chromium Code Reviews| 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" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 void HandleAuthCallback(const AuthCallback& callback, | 124 void HandleAuthCallback(const AuthCallback& callback, |
| 125 dbus::Response* response) { | 125 dbus::Response* response) { |
| 126 authpolicy::ActiveDirectoryAccountData account_data; | 126 authpolicy::ActiveDirectoryAccountData account_data; |
| 127 if (!response) { | 127 if (!response) { |
| 128 DLOG(ERROR) << "Auth: Failed to call to authpolicy"; | 128 DLOG(ERROR) << "Auth: Failed to call to authpolicy"; |
| 129 callback.Run(authpolicy::ERROR_DBUS_FAILURE, account_data); | 129 callback.Run(authpolicy::ERROR_DBUS_FAILURE, account_data); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 dbus::MessageReader reader(response); | 132 dbus::MessageReader reader(response); |
| 133 const authpolicy::ErrorType error(GetErrorFromReader(&reader)); | 133 const authpolicy::ErrorType error(GetErrorFromReader(&reader)); |
| 134 if (reader.PopArrayOfBytesAsProto(&account_data)) { | 134 if (!reader.PopArrayOfBytesAsProto(&account_data)) { |
| 135 callback.Run(error, account_data); | 135 DLOG(ERROR) << "Failed to parse protobuf."; |
|
Thiemo Nagel
2017/03/21 13:30:01
Nit: Why not use LOG(ERROR)?
Roman Sorokin (ftl)
2017/03/21 13:43:00
Just not to bloat the binary. Should probably dele
Thiemo Nagel
2017/03/21 13:45:37
Sounds good.
| |
| 136 callback.Run(authpolicy::ErrorType::ERROR_DBUS_FAILURE, account_data); | |
| 136 return; | 137 return; |
| 137 } | 138 } |
| 138 DLOG(WARNING) << "Failed to parse protobuf. Fallback to string"; | |
| 139 // TODO(rsorokin): Remove once both ChromiumOS and Chromium use protobuf. | |
| 140 std::string account_id; | |
| 141 if (!reader.PopString(&account_id)) | |
| 142 DLOG(ERROR) << "Auth: Failed to get user_id from the response"; | |
| 143 account_data.set_account_id(account_id); | |
| 144 callback.Run(error, account_data); | 139 callback.Run(error, account_data); |
| 145 } | 140 } |
| 146 | 141 |
| 147 dbus::Bus* bus_ = nullptr; | 142 dbus::Bus* bus_ = nullptr; |
| 148 dbus::ObjectProxy* proxy_ = nullptr; | 143 dbus::ObjectProxy* proxy_ = nullptr; |
| 149 | 144 |
| 150 // Note: This should remain the last member so it'll be destroyed and | 145 // Note: This should remain the last member so it'll be destroyed and |
| 151 // invalidate its weak pointers before any other members are destroyed. | 146 // invalidate its weak pointers before any other members are destroyed. |
| 152 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_; | 147 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_; |
| 153 | 148 |
| 154 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl); | 149 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl); |
| 155 }; | 150 }; |
| 156 | 151 |
| 157 } // namespace | 152 } // namespace |
| 158 | 153 |
| 159 AuthPolicyClient::AuthPolicyClient() {} | 154 AuthPolicyClient::AuthPolicyClient() {} |
| 160 | 155 |
| 161 AuthPolicyClient::~AuthPolicyClient() {} | 156 AuthPolicyClient::~AuthPolicyClient() {} |
| 162 | 157 |
| 163 // static | 158 // static |
| 164 AuthPolicyClient* AuthPolicyClient::Create() { | 159 AuthPolicyClient* AuthPolicyClient::Create() { |
| 165 return new AuthPolicyClientImpl(); | 160 return new AuthPolicyClientImpl(); |
| 166 } | 161 } |
| 167 | 162 |
| 168 } // namespace chromeos | 163 } // namespace chromeos |
| OLD | NEW |