OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 library authentication_mojom; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:mojo/bindings.dart' as bindings; |
| 10 import 'package:mojo/core.dart' as core; |
| 11 |
| 12 |
| 13 |
| 14 class AuthenticationServiceSelectAccountParams extends bindings.Struct { |
| 15 static const List<bindings.StructDataHeader> kVersions = const [ |
| 16 const bindings.StructDataHeader(16, 0) |
| 17 ]; |
| 18 bool returnLastSelected = false; |
| 19 |
| 20 AuthenticationServiceSelectAccountParams() : super(kVersions.last.size); |
| 21 |
| 22 static AuthenticationServiceSelectAccountParams deserialize(bindings.Message m
essage) { |
| 23 var decoder = new bindings.Decoder(message); |
| 24 var result = decode(decoder); |
| 25 if (decoder.excessHandles != null) { |
| 26 decoder.excessHandles.forEach((h) => h.close()); |
| 27 } |
| 28 return result; |
| 29 } |
| 30 |
| 31 static AuthenticationServiceSelectAccountParams decode(bindings.Decoder decode
r0) { |
| 32 if (decoder0 == null) { |
| 33 return null; |
| 34 } |
| 35 AuthenticationServiceSelectAccountParams result = new AuthenticationServiceS
electAccountParams(); |
| 36 |
| 37 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 38 if (mainDataHeader.version <= kVersions.last.version) { |
| 39 // Scan in reverse order to optimize for more recent versions. |
| 40 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 41 if (mainDataHeader.version >= kVersions[i].version) { |
| 42 if (mainDataHeader.size == kVersions[i].size) { |
| 43 // Found a match. |
| 44 break; |
| 45 } |
| 46 throw new bindings.MojoCodecError( |
| 47 'Header size doesn\'t correspond to known version size.'); |
| 48 } |
| 49 } |
| 50 } else if (mainDataHeader.size < kVersions.last.size) { |
| 51 throw new bindings.MojoCodecError( |
| 52 'Message newer than the last known version cannot be shorter than ' |
| 53 'required by the last known version.'); |
| 54 } |
| 55 if (mainDataHeader.version >= 0) { |
| 56 |
| 57 result.returnLastSelected = decoder0.decodeBool(8, 0); |
| 58 } |
| 59 return result; |
| 60 } |
| 61 |
| 62 void encode(bindings.Encoder encoder) { |
| 63 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 64 |
| 65 encoder0.encodeBool(returnLastSelected, 8, 0); |
| 66 } |
| 67 |
| 68 String toString() { |
| 69 return "AuthenticationServiceSelectAccountParams(" |
| 70 "returnLastSelected: $returnLastSelected" ")"; |
| 71 } |
| 72 |
| 73 Map toJson() { |
| 74 Map map = new Map(); |
| 75 map["returnLastSelected"] = returnLastSelected; |
| 76 return map; |
| 77 } |
| 78 } |
| 79 |
| 80 |
| 81 class AuthenticationServiceSelectAccountResponseParams extends bindings.Struct { |
| 82 static const List<bindings.StructDataHeader> kVersions = const [ |
| 83 const bindings.StructDataHeader(24, 0) |
| 84 ]; |
| 85 String username = null; |
| 86 String error = null; |
| 87 |
| 88 AuthenticationServiceSelectAccountResponseParams() : super(kVersions.last.size
); |
| 89 |
| 90 static AuthenticationServiceSelectAccountResponseParams deserialize(bindings.M
essage message) { |
| 91 var decoder = new bindings.Decoder(message); |
| 92 var result = decode(decoder); |
| 93 if (decoder.excessHandles != null) { |
| 94 decoder.excessHandles.forEach((h) => h.close()); |
| 95 } |
| 96 return result; |
| 97 } |
| 98 |
| 99 static AuthenticationServiceSelectAccountResponseParams decode(bindings.Decode
r decoder0) { |
| 100 if (decoder0 == null) { |
| 101 return null; |
| 102 } |
| 103 AuthenticationServiceSelectAccountResponseParams result = new Authentication
ServiceSelectAccountResponseParams(); |
| 104 |
| 105 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 106 if (mainDataHeader.version <= kVersions.last.version) { |
| 107 // Scan in reverse order to optimize for more recent versions. |
| 108 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 109 if (mainDataHeader.version >= kVersions[i].version) { |
| 110 if (mainDataHeader.size == kVersions[i].size) { |
| 111 // Found a match. |
| 112 break; |
| 113 } |
| 114 throw new bindings.MojoCodecError( |
| 115 'Header size doesn\'t correspond to known version size.'); |
| 116 } |
| 117 } |
| 118 } else if (mainDataHeader.size < kVersions.last.size) { |
| 119 throw new bindings.MojoCodecError( |
| 120 'Message newer than the last known version cannot be shorter than ' |
| 121 'required by the last known version.'); |
| 122 } |
| 123 if (mainDataHeader.version >= 0) { |
| 124 |
| 125 result.username = decoder0.decodeString(8, true); |
| 126 } |
| 127 if (mainDataHeader.version >= 0) { |
| 128 |
| 129 result.error = decoder0.decodeString(16, true); |
| 130 } |
| 131 return result; |
| 132 } |
| 133 |
| 134 void encode(bindings.Encoder encoder) { |
| 135 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 136 |
| 137 encoder0.encodeString(username, 8, true); |
| 138 |
| 139 encoder0.encodeString(error, 16, true); |
| 140 } |
| 141 |
| 142 String toString() { |
| 143 return "AuthenticationServiceSelectAccountResponseParams(" |
| 144 "username: $username" ", " |
| 145 "error: $error" ")"; |
| 146 } |
| 147 |
| 148 Map toJson() { |
| 149 Map map = new Map(); |
| 150 map["username"] = username; |
| 151 map["error"] = error; |
| 152 return map; |
| 153 } |
| 154 } |
| 155 |
| 156 |
| 157 class AuthenticationServiceGetOAuth2TokenParams extends bindings.Struct { |
| 158 static const List<bindings.StructDataHeader> kVersions = const [ |
| 159 const bindings.StructDataHeader(24, 0) |
| 160 ]; |
| 161 String username = null; |
| 162 List<String> scopes = null; |
| 163 |
| 164 AuthenticationServiceGetOAuth2TokenParams() : super(kVersions.last.size); |
| 165 |
| 166 static AuthenticationServiceGetOAuth2TokenParams deserialize(bindings.Message
message) { |
| 167 var decoder = new bindings.Decoder(message); |
| 168 var result = decode(decoder); |
| 169 if (decoder.excessHandles != null) { |
| 170 decoder.excessHandles.forEach((h) => h.close()); |
| 171 } |
| 172 return result; |
| 173 } |
| 174 |
| 175 static AuthenticationServiceGetOAuth2TokenParams decode(bindings.Decoder decod
er0) { |
| 176 if (decoder0 == null) { |
| 177 return null; |
| 178 } |
| 179 AuthenticationServiceGetOAuth2TokenParams result = new AuthenticationService
GetOAuth2TokenParams(); |
| 180 |
| 181 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 182 if (mainDataHeader.version <= kVersions.last.version) { |
| 183 // Scan in reverse order to optimize for more recent versions. |
| 184 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 185 if (mainDataHeader.version >= kVersions[i].version) { |
| 186 if (mainDataHeader.size == kVersions[i].size) { |
| 187 // Found a match. |
| 188 break; |
| 189 } |
| 190 throw new bindings.MojoCodecError( |
| 191 'Header size doesn\'t correspond to known version size.'); |
| 192 } |
| 193 } |
| 194 } else if (mainDataHeader.size < kVersions.last.size) { |
| 195 throw new bindings.MojoCodecError( |
| 196 'Message newer than the last known version cannot be shorter than ' |
| 197 'required by the last known version.'); |
| 198 } |
| 199 if (mainDataHeader.version >= 0) { |
| 200 |
| 201 result.username = decoder0.decodeString(8, false); |
| 202 } |
| 203 if (mainDataHeader.version >= 0) { |
| 204 |
| 205 var decoder1 = decoder0.decodePointer(16, false); |
| 206 { |
| 207 var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecified
ArrayLength); |
| 208 result.scopes = new List<String>(si1.numElements); |
| 209 for (int i1 = 0; i1 < si1.numElements; ++i1) { |
| 210 |
| 211 result.scopes[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHe
aderSize + bindings.kPointerSize * i1, false); |
| 212 } |
| 213 } |
| 214 } |
| 215 return result; |
| 216 } |
| 217 |
| 218 void encode(bindings.Encoder encoder) { |
| 219 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 220 |
| 221 encoder0.encodeString(username, 8, false); |
| 222 |
| 223 if (scopes == null) { |
| 224 encoder0.encodeNullPointer(16, false); |
| 225 } else { |
| 226 var encoder1 = encoder0.encodePointerArray(scopes.length, 16, bindings.kUn
specifiedArrayLength); |
| 227 for (int i0 = 0; i0 < scopes.length; ++i0) { |
| 228 |
| 229 encoder1.encodeString(scopes[i0], bindings.ArrayDataHeader.kHeaderSize +
bindings.kPointerSize * i0, false); |
| 230 } |
| 231 } |
| 232 } |
| 233 |
| 234 String toString() { |
| 235 return "AuthenticationServiceGetOAuth2TokenParams(" |
| 236 "username: $username" ", " |
| 237 "scopes: $scopes" ")"; |
| 238 } |
| 239 |
| 240 Map toJson() { |
| 241 Map map = new Map(); |
| 242 map["username"] = username; |
| 243 map["scopes"] = scopes; |
| 244 return map; |
| 245 } |
| 246 } |
| 247 |
| 248 |
| 249 class AuthenticationServiceGetOAuth2TokenResponseParams extends bindings.Struct
{ |
| 250 static const List<bindings.StructDataHeader> kVersions = const [ |
| 251 const bindings.StructDataHeader(24, 0) |
| 252 ]; |
| 253 String token = null; |
| 254 String error = null; |
| 255 |
| 256 AuthenticationServiceGetOAuth2TokenResponseParams() : super(kVersions.last.siz
e); |
| 257 |
| 258 static AuthenticationServiceGetOAuth2TokenResponseParams deserialize(bindings.
Message message) { |
| 259 var decoder = new bindings.Decoder(message); |
| 260 var result = decode(decoder); |
| 261 if (decoder.excessHandles != null) { |
| 262 decoder.excessHandles.forEach((h) => h.close()); |
| 263 } |
| 264 return result; |
| 265 } |
| 266 |
| 267 static AuthenticationServiceGetOAuth2TokenResponseParams decode(bindings.Decod
er decoder0) { |
| 268 if (decoder0 == null) { |
| 269 return null; |
| 270 } |
| 271 AuthenticationServiceGetOAuth2TokenResponseParams result = new Authenticatio
nServiceGetOAuth2TokenResponseParams(); |
| 272 |
| 273 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 274 if (mainDataHeader.version <= kVersions.last.version) { |
| 275 // Scan in reverse order to optimize for more recent versions. |
| 276 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 277 if (mainDataHeader.version >= kVersions[i].version) { |
| 278 if (mainDataHeader.size == kVersions[i].size) { |
| 279 // Found a match. |
| 280 break; |
| 281 } |
| 282 throw new bindings.MojoCodecError( |
| 283 'Header size doesn\'t correspond to known version size.'); |
| 284 } |
| 285 } |
| 286 } else if (mainDataHeader.size < kVersions.last.size) { |
| 287 throw new bindings.MojoCodecError( |
| 288 'Message newer than the last known version cannot be shorter than ' |
| 289 'required by the last known version.'); |
| 290 } |
| 291 if (mainDataHeader.version >= 0) { |
| 292 |
| 293 result.token = decoder0.decodeString(8, true); |
| 294 } |
| 295 if (mainDataHeader.version >= 0) { |
| 296 |
| 297 result.error = decoder0.decodeString(16, true); |
| 298 } |
| 299 return result; |
| 300 } |
| 301 |
| 302 void encode(bindings.Encoder encoder) { |
| 303 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 304 |
| 305 encoder0.encodeString(token, 8, true); |
| 306 |
| 307 encoder0.encodeString(error, 16, true); |
| 308 } |
| 309 |
| 310 String toString() { |
| 311 return "AuthenticationServiceGetOAuth2TokenResponseParams(" |
| 312 "token: $token" ", " |
| 313 "error: $error" ")"; |
| 314 } |
| 315 |
| 316 Map toJson() { |
| 317 Map map = new Map(); |
| 318 map["token"] = token; |
| 319 map["error"] = error; |
| 320 return map; |
| 321 } |
| 322 } |
| 323 |
| 324 |
| 325 class AuthenticationServiceClearOAuth2TokenParams extends bindings.Struct { |
| 326 static const List<bindings.StructDataHeader> kVersions = const [ |
| 327 const bindings.StructDataHeader(16, 0) |
| 328 ]; |
| 329 String token = null; |
| 330 |
| 331 AuthenticationServiceClearOAuth2TokenParams() : super(kVersions.last.size); |
| 332 |
| 333 static AuthenticationServiceClearOAuth2TokenParams deserialize(bindings.Messag
e message) { |
| 334 var decoder = new bindings.Decoder(message); |
| 335 var result = decode(decoder); |
| 336 if (decoder.excessHandles != null) { |
| 337 decoder.excessHandles.forEach((h) => h.close()); |
| 338 } |
| 339 return result; |
| 340 } |
| 341 |
| 342 static AuthenticationServiceClearOAuth2TokenParams decode(bindings.Decoder dec
oder0) { |
| 343 if (decoder0 == null) { |
| 344 return null; |
| 345 } |
| 346 AuthenticationServiceClearOAuth2TokenParams result = new AuthenticationServi
ceClearOAuth2TokenParams(); |
| 347 |
| 348 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 349 if (mainDataHeader.version <= kVersions.last.version) { |
| 350 // Scan in reverse order to optimize for more recent versions. |
| 351 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 352 if (mainDataHeader.version >= kVersions[i].version) { |
| 353 if (mainDataHeader.size == kVersions[i].size) { |
| 354 // Found a match. |
| 355 break; |
| 356 } |
| 357 throw new bindings.MojoCodecError( |
| 358 'Header size doesn\'t correspond to known version size.'); |
| 359 } |
| 360 } |
| 361 } else if (mainDataHeader.size < kVersions.last.size) { |
| 362 throw new bindings.MojoCodecError( |
| 363 'Message newer than the last known version cannot be shorter than ' |
| 364 'required by the last known version.'); |
| 365 } |
| 366 if (mainDataHeader.version >= 0) { |
| 367 |
| 368 result.token = decoder0.decodeString(8, false); |
| 369 } |
| 370 return result; |
| 371 } |
| 372 |
| 373 void encode(bindings.Encoder encoder) { |
| 374 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 375 |
| 376 encoder0.encodeString(token, 8, false); |
| 377 } |
| 378 |
| 379 String toString() { |
| 380 return "AuthenticationServiceClearOAuth2TokenParams(" |
| 381 "token: $token" ")"; |
| 382 } |
| 383 |
| 384 Map toJson() { |
| 385 Map map = new Map(); |
| 386 map["token"] = token; |
| 387 return map; |
| 388 } |
| 389 } |
| 390 |
| 391 const int kAuthenticationService_selectAccount_name = 0; |
| 392 const int kAuthenticationService_getOAuth2Token_name = 1; |
| 393 const int kAuthenticationService_clearOAuth2Token_name = 2; |
| 394 |
| 395 const String AuthenticationServiceName = |
| 396 'authentication::AuthenticationService'; |
| 397 |
| 398 abstract class AuthenticationService { |
| 399 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null
]); |
| 400 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF
actory = null]); |
| 401 void clearOAuth2Token(String token); |
| 402 |
| 403 } |
| 404 |
| 405 |
| 406 class AuthenticationServiceProxyImpl extends bindings.Proxy { |
| 407 AuthenticationServiceProxyImpl.fromEndpoint( |
| 408 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 409 |
| 410 AuthenticationServiceProxyImpl.fromHandle(core.MojoHandle handle) : |
| 411 super.fromHandle(handle); |
| 412 |
| 413 AuthenticationServiceProxyImpl.unbound() : super.unbound(); |
| 414 |
| 415 static AuthenticationServiceProxyImpl newFromEndpoint( |
| 416 core.MojoMessagePipeEndpoint endpoint) { |
| 417 assert(endpoint.setDescription("For AuthenticationServiceProxyImpl")); |
| 418 return new AuthenticationServiceProxyImpl.fromEndpoint(endpoint); |
| 419 } |
| 420 |
| 421 String get name => AuthenticationServiceName; |
| 422 |
| 423 void handleResponse(bindings.ServiceMessage message) { |
| 424 switch (message.header.type) { |
| 425 case kAuthenticationService_selectAccount_name: |
| 426 var r = AuthenticationServiceSelectAccountResponseParams.deserialize( |
| 427 message.payload); |
| 428 if (!message.header.hasRequestId) { |
| 429 proxyError("Expected a message with a valid request Id."); |
| 430 return; |
| 431 } |
| 432 Completer c = completerMap[message.header.requestId]; |
| 433 if (c == null) { |
| 434 proxyError( |
| 435 "Message had unknown request Id: ${message.header.requestId}"); |
| 436 return; |
| 437 } |
| 438 completerMap.remove(message.header.requestId); |
| 439 if (c.isCompleted) { |
| 440 proxyError("Response completer already completed"); |
| 441 return; |
| 442 } |
| 443 c.complete(r); |
| 444 break; |
| 445 case kAuthenticationService_getOAuth2Token_name: |
| 446 var r = AuthenticationServiceGetOAuth2TokenResponseParams.deserialize( |
| 447 message.payload); |
| 448 if (!message.header.hasRequestId) { |
| 449 proxyError("Expected a message with a valid request Id."); |
| 450 return; |
| 451 } |
| 452 Completer c = completerMap[message.header.requestId]; |
| 453 if (c == null) { |
| 454 proxyError( |
| 455 "Message had unknown request Id: ${message.header.requestId}"); |
| 456 return; |
| 457 } |
| 458 completerMap.remove(message.header.requestId); |
| 459 if (c.isCompleted) { |
| 460 proxyError("Response completer already completed"); |
| 461 return; |
| 462 } |
| 463 c.complete(r); |
| 464 break; |
| 465 default: |
| 466 proxyError("Unexpected message type: ${message.header.type}"); |
| 467 close(immediate: true); |
| 468 break; |
| 469 } |
| 470 } |
| 471 |
| 472 String toString() { |
| 473 var superString = super.toString(); |
| 474 return "AuthenticationServiceProxyImpl($superString)"; |
| 475 } |
| 476 } |
| 477 |
| 478 |
| 479 class _AuthenticationServiceProxyCalls implements AuthenticationService { |
| 480 AuthenticationServiceProxyImpl _proxyImpl; |
| 481 |
| 482 _AuthenticationServiceProxyCalls(this._proxyImpl); |
| 483 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = nu
ll]) { |
| 484 var params = new AuthenticationServiceSelectAccountParams(); |
| 485 params.returnLastSelected = returnLastSelected; |
| 486 return _proxyImpl.sendMessageWithRequestId( |
| 487 params, |
| 488 kAuthenticationService_selectAccount_name, |
| 489 -1, |
| 490 bindings.MessageHeader.kMessageExpectsResponse); |
| 491 } |
| 492 dynamic getOAuth2Token(String username,List<String> scopes,[Function respons
eFactory = null]) { |
| 493 var params = new AuthenticationServiceGetOAuth2TokenParams(); |
| 494 params.username = username; |
| 495 params.scopes = scopes; |
| 496 return _proxyImpl.sendMessageWithRequestId( |
| 497 params, |
| 498 kAuthenticationService_getOAuth2Token_name, |
| 499 -1, |
| 500 bindings.MessageHeader.kMessageExpectsResponse); |
| 501 } |
| 502 void clearOAuth2Token(String token) { |
| 503 if (!_proxyImpl.isBound) { |
| 504 _proxyImpl.proxyError("The Proxy is closed."); |
| 505 return; |
| 506 } |
| 507 var params = new AuthenticationServiceClearOAuth2TokenParams(); |
| 508 params.token = token; |
| 509 _proxyImpl.sendMessage(params, kAuthenticationService_clearOAuth2Token_nam
e); |
| 510 } |
| 511 |
| 512 } |
| 513 |
| 514 |
| 515 class AuthenticationServiceProxy implements bindings.ProxyBase { |
| 516 final bindings.Proxy impl; |
| 517 AuthenticationService ptr; |
| 518 final String name = AuthenticationServiceName; |
| 519 |
| 520 AuthenticationServiceProxy(AuthenticationServiceProxyImpl proxyImpl) : |
| 521 impl = proxyImpl, |
| 522 ptr = new _AuthenticationServiceProxyCalls(proxyImpl); |
| 523 |
| 524 AuthenticationServiceProxy.fromEndpoint( |
| 525 core.MojoMessagePipeEndpoint endpoint) : |
| 526 impl = new AuthenticationServiceProxyImpl.fromEndpoint(endpoint) { |
| 527 ptr = new _AuthenticationServiceProxyCalls(impl); |
| 528 } |
| 529 |
| 530 AuthenticationServiceProxy.fromHandle(core.MojoHandle handle) : |
| 531 impl = new AuthenticationServiceProxyImpl.fromHandle(handle) { |
| 532 ptr = new _AuthenticationServiceProxyCalls(impl); |
| 533 } |
| 534 |
| 535 AuthenticationServiceProxy.unbound() : |
| 536 impl = new AuthenticationServiceProxyImpl.unbound() { |
| 537 ptr = new _AuthenticationServiceProxyCalls(impl); |
| 538 } |
| 539 |
| 540 factory AuthenticationServiceProxy.connectToService( |
| 541 bindings.ServiceConnector s, String url) { |
| 542 AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound(); |
| 543 s.connectToService(url, p); |
| 544 return p; |
| 545 } |
| 546 |
| 547 static AuthenticationServiceProxy newFromEndpoint( |
| 548 core.MojoMessagePipeEndpoint endpoint) { |
| 549 assert(endpoint.setDescription("For AuthenticationServiceProxy")); |
| 550 return new AuthenticationServiceProxy.fromEndpoint(endpoint); |
| 551 } |
| 552 |
| 553 Future close({bool immediate: false}) => impl.close(immediate: immediate); |
| 554 |
| 555 Future responseOrError(Future f) => impl.responseOrError(f); |
| 556 |
| 557 Future get errorFuture => impl.errorFuture; |
| 558 |
| 559 int get version => impl.version; |
| 560 |
| 561 Future<int> queryVersion() => impl.queryVersion(); |
| 562 |
| 563 void requireVersion(int requiredVersion) { |
| 564 impl.requireVersion(requiredVersion); |
| 565 } |
| 566 |
| 567 String toString() { |
| 568 return "AuthenticationServiceProxy($impl)"; |
| 569 } |
| 570 } |
| 571 |
| 572 |
| 573 class AuthenticationServiceStub extends bindings.Stub { |
| 574 AuthenticationService _impl = null; |
| 575 |
| 576 AuthenticationServiceStub.fromEndpoint( |
| 577 core.MojoMessagePipeEndpoint endpoint, [this._impl]) |
| 578 : super.fromEndpoint(endpoint); |
| 579 |
| 580 AuthenticationServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) |
| 581 : super.fromHandle(handle); |
| 582 |
| 583 AuthenticationServiceStub.unbound() : super.unbound(); |
| 584 |
| 585 static AuthenticationServiceStub newFromEndpoint( |
| 586 core.MojoMessagePipeEndpoint endpoint) { |
| 587 assert(endpoint.setDescription("For AuthenticationServiceStub")); |
| 588 return new AuthenticationServiceStub.fromEndpoint(endpoint); |
| 589 } |
| 590 |
| 591 static const String name = AuthenticationServiceName; |
| 592 |
| 593 |
| 594 AuthenticationServiceSelectAccountResponseParams _AuthenticationServiceSelectA
ccountResponseParamsFactory(String username, String error) { |
| 595 var result = new AuthenticationServiceSelectAccountResponseParams(); |
| 596 result.username = username; |
| 597 result.error = error; |
| 598 return result; |
| 599 } |
| 600 AuthenticationServiceGetOAuth2TokenResponseParams _AuthenticationServiceGetOAu
th2TokenResponseParamsFactory(String token, String error) { |
| 601 var result = new AuthenticationServiceGetOAuth2TokenResponseParams(); |
| 602 result.token = token; |
| 603 result.error = error; |
| 604 return result; |
| 605 } |
| 606 |
| 607 dynamic handleMessage(bindings.ServiceMessage message) { |
| 608 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 609 return bindings.ControlMessageHandler.handleMessage(this, |
| 610 0, |
| 611 message); |
| 612 } |
| 613 assert(_impl != null); |
| 614 switch (message.header.type) { |
| 615 case kAuthenticationService_selectAccount_name: |
| 616 var params = AuthenticationServiceSelectAccountParams.deserialize( |
| 617 message.payload); |
| 618 var response = _impl.selectAccount(params.returnLastSelected,_Authentica
tionServiceSelectAccountResponseParamsFactory); |
| 619 if (response is Future) { |
| 620 return response.then((response) { |
| 621 if (response != null) { |
| 622 return buildResponseWithId( |
| 623 response, |
| 624 kAuthenticationService_selectAccount_name, |
| 625 message.header.requestId, |
| 626 bindings.MessageHeader.kMessageIsResponse); |
| 627 } |
| 628 }); |
| 629 } else if (response != null) { |
| 630 return buildResponseWithId( |
| 631 response, |
| 632 kAuthenticationService_selectAccount_name, |
| 633 message.header.requestId, |
| 634 bindings.MessageHeader.kMessageIsResponse); |
| 635 } |
| 636 break; |
| 637 case kAuthenticationService_getOAuth2Token_name: |
| 638 var params = AuthenticationServiceGetOAuth2TokenParams.deserialize( |
| 639 message.payload); |
| 640 var response = _impl.getOAuth2Token(params.username,params.scopes,_Authe
nticationServiceGetOAuth2TokenResponseParamsFactory); |
| 641 if (response is Future) { |
| 642 return response.then((response) { |
| 643 if (response != null) { |
| 644 return buildResponseWithId( |
| 645 response, |
| 646 kAuthenticationService_getOAuth2Token_name, |
| 647 message.header.requestId, |
| 648 bindings.MessageHeader.kMessageIsResponse); |
| 649 } |
| 650 }); |
| 651 } else if (response != null) { |
| 652 return buildResponseWithId( |
| 653 response, |
| 654 kAuthenticationService_getOAuth2Token_name, |
| 655 message.header.requestId, |
| 656 bindings.MessageHeader.kMessageIsResponse); |
| 657 } |
| 658 break; |
| 659 case kAuthenticationService_clearOAuth2Token_name: |
| 660 var params = AuthenticationServiceClearOAuth2TokenParams.deserialize( |
| 661 message.payload); |
| 662 _impl.clearOAuth2Token(params.token); |
| 663 break; |
| 664 default: |
| 665 throw new bindings.MojoCodecError("Unexpected message name"); |
| 666 break; |
| 667 } |
| 668 return null; |
| 669 } |
| 670 |
| 671 AuthenticationService get impl => _impl; |
| 672 set impl(AuthenticationService d) { |
| 673 assert(_impl == null); |
| 674 _impl = d; |
| 675 } |
| 676 |
| 677 String toString() { |
| 678 var superString = super.toString(); |
| 679 return "AuthenticationServiceStub($superString)"; |
| 680 } |
| 681 |
| 682 int get version => 0; |
| 683 } |
| 684 |
| 685 |
OLD | NEW |