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

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

Issue 2685793004: Chromad: Wire up displayName and givenName (Closed)
Patch Set: Combine SetDisplayName and SetGivenName into SetDisplayAndGiveName 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
« no previous file with comments | « chromeos/dbus/auth_policy_client.h ('k') | chromeos/dbus/fake_auth_policy_client.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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 callback.Run(authpolicy::ERROR_DBUS_FAILURE); 116 callback.Run(authpolicy::ERROR_DBUS_FAILURE);
117 return; 117 return;
118 } 118 }
119 119
120 dbus::MessageReader reader(response); 120 dbus::MessageReader reader(response);
121 callback.Run(GetErrorFromReader(&reader)); 121 callback.Run(GetErrorFromReader(&reader));
122 } 122 }
123 123
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 if (!response) { 127 if (!response) {
127 DLOG(ERROR) << "Auth: Failed to call to authpolicy"; 128 DLOG(ERROR) << "Auth: Failed to call to authpolicy";
128 callback.Run(authpolicy::ERROR_DBUS_FAILURE, std::string()); 129 callback.Run(authpolicy::ERROR_DBUS_FAILURE, account_data);
129 return; 130 return;
130 } 131 }
131 dbus::MessageReader reader(response); 132 dbus::MessageReader reader(response);
132 const authpolicy::ErrorType error(GetErrorFromReader(&reader)); 133 const authpolicy::ErrorType error(GetErrorFromReader(&reader));
133 std::string user_id; 134 if (reader.PopArrayOfBytesAsProto(&account_data)) {
134 if (!reader.PopString(&user_id)) 135 callback.Run(error, account_data);
136 return;
137 }
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))
135 DLOG(ERROR) << "Auth: Failed to get user_id from the response"; 142 DLOG(ERROR) << "Auth: Failed to get user_id from the response";
136 callback.Run(error, user_id); 143 account_data.set_account_id(account_id);
144 callback.Run(error, account_data);
137 } 145 }
138 146
139 dbus::Bus* bus_ = nullptr; 147 dbus::Bus* bus_ = nullptr;
140 dbus::ObjectProxy* proxy_ = nullptr; 148 dbus::ObjectProxy* proxy_ = nullptr;
141 149
142 // Note: This should remain the last member so it'll be destroyed and 150 // Note: This should remain the last member so it'll be destroyed and
143 // invalidate its weak pointers before any other members are destroyed. 151 // invalidate its weak pointers before any other members are destroyed.
144 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_; 152 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_;
145 153
146 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl); 154 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl);
147 }; 155 };
148 156
149 } // namespace 157 } // namespace
150 158
151 AuthPolicyClient::AuthPolicyClient() {} 159 AuthPolicyClient::AuthPolicyClient() {}
152 160
153 AuthPolicyClient::~AuthPolicyClient() {} 161 AuthPolicyClient::~AuthPolicyClient() {}
154 162
155 // static 163 // static
156 AuthPolicyClient* AuthPolicyClient::Create() { 164 AuthPolicyClient* AuthPolicyClient::Create() {
157 return new AuthPolicyClientImpl(); 165 return new AuthPolicyClientImpl();
158 } 166 }
159 167
160 } // namespace chromeos 168 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/auth_policy_client.h ('k') | chromeos/dbus/fake_auth_policy_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698