OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 library authentication_mojom; | 5 library authentication_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
10 | 10 |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 abstract class AuthenticationService { | 805 abstract class AuthenticationService { |
806 static const String serviceName = "authentication::AuthenticationService"; | 806 static const String serviceName = "authentication::AuthenticationService"; |
807 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null
]); | 807 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null
]); |
808 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF
actory = null]); | 808 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF
actory = null]); |
809 void clearOAuth2Token(String token); | 809 void clearOAuth2Token(String token); |
810 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu
ll]); | 810 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu
ll]); |
811 dynamic addAccount(String deviceCode,[Function responseFactory = null]); | 811 dynamic addAccount(String deviceCode,[Function responseFactory = null]); |
812 } | 812 } |
813 | 813 |
814 | 814 |
815 class _AuthenticationServiceProxyImpl extends bindings.Proxy { | 815 class _AuthenticationServiceProxyControl extends bindings.ProxyMessageHandler |
816 _AuthenticationServiceProxyImpl.fromEndpoint( | 816 implements bindings.ProxyControl { |
| 817 _AuthenticationServiceProxyControl.fromEndpoint( |
817 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 818 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
818 | 819 |
819 _AuthenticationServiceProxyImpl.fromHandle(core.MojoHandle handle) : | 820 _AuthenticationServiceProxyControl.fromHandle( |
820 super.fromHandle(handle); | 821 core.MojoHandle handle) : super.fromHandle(handle); |
821 | 822 |
822 _AuthenticationServiceProxyImpl.unbound() : super.unbound(); | 823 _AuthenticationServiceProxyControl.unbound() : super.unbound(); |
823 | |
824 static _AuthenticationServiceProxyImpl newFromEndpoint( | |
825 core.MojoMessagePipeEndpoint endpoint) { | |
826 assert(endpoint.setDescription("For _AuthenticationServiceProxyImpl")); | |
827 return new _AuthenticationServiceProxyImpl.fromEndpoint(endpoint); | |
828 } | |
829 | 824 |
830 service_describer.ServiceDescription get serviceDescription => | 825 service_describer.ServiceDescription get serviceDescription => |
831 new _AuthenticationServiceServiceDescription(); | 826 new _AuthenticationServiceServiceDescription(); |
832 | 827 |
| 828 String get serviceName => AuthenticationService.serviceName; |
| 829 |
| 830 @override |
833 void handleResponse(bindings.ServiceMessage message) { | 831 void handleResponse(bindings.ServiceMessage message) { |
834 switch (message.header.type) { | 832 switch (message.header.type) { |
835 case _authenticationServiceMethodSelectAccountName: | 833 case _authenticationServiceMethodSelectAccountName: |
836 var r = AuthenticationServiceSelectAccountResponseParams.deserialize( | 834 var r = AuthenticationServiceSelectAccountResponseParams.deserialize( |
837 message.payload); | 835 message.payload); |
838 if (!message.header.hasRequestId) { | 836 if (!message.header.hasRequestId) { |
839 proxyError("Expected a message with a valid request Id."); | 837 proxyError("Expected a message with a valid request Id."); |
840 return; | 838 return; |
841 } | 839 } |
842 Completer c = completerMap[message.header.requestId]; | 840 Completer c = completerMap[message.header.requestId]; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 } | 910 } |
913 c.complete(r); | 911 c.complete(r); |
914 break; | 912 break; |
915 default: | 913 default: |
916 proxyError("Unexpected message type: ${message.header.type}"); | 914 proxyError("Unexpected message type: ${message.header.type}"); |
917 close(immediate: true); | 915 close(immediate: true); |
918 break; | 916 break; |
919 } | 917 } |
920 } | 918 } |
921 | 919 |
| 920 @override |
922 String toString() { | 921 String toString() { |
923 var superString = super.toString(); | 922 var superString = super.toString(); |
924 return "_AuthenticationServiceProxyImpl($superString)"; | 923 return "_AuthenticationServiceProxyControl($superString)"; |
925 } | 924 } |
926 } | 925 } |
927 | 926 |
928 | 927 |
929 class _AuthenticationServiceProxyCalls implements AuthenticationService { | 928 class AuthenticationServiceProxy extends bindings.Proxy |
930 _AuthenticationServiceProxyImpl _proxyImpl; | 929 implements AuthenticationService { |
| 930 AuthenticationServiceProxy.fromEndpoint( |
| 931 core.MojoMessagePipeEndpoint endpoint) |
| 932 : super(new _AuthenticationServiceProxyControl.fromEndpoint(endpoint)); |
931 | 933 |
932 _AuthenticationServiceProxyCalls(this._proxyImpl); | 934 AuthenticationServiceProxy.fromHandle(core.MojoHandle handle) |
933 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = nu
ll]) { | 935 : super(new _AuthenticationServiceProxyControl.fromHandle(handle)); |
934 var params = new _AuthenticationServiceSelectAccountParams(); | |
935 params.returnLastSelected = returnLastSelected; | |
936 return _proxyImpl.sendMessageWithRequestId( | |
937 params, | |
938 _authenticationServiceMethodSelectAccountName, | |
939 -1, | |
940 bindings.MessageHeader.kMessageExpectsResponse); | |
941 } | |
942 dynamic getOAuth2Token(String username,List<String> scopes,[Function respons
eFactory = null]) { | |
943 var params = new _AuthenticationServiceGetOAuth2TokenParams(); | |
944 params.username = username; | |
945 params.scopes = scopes; | |
946 return _proxyImpl.sendMessageWithRequestId( | |
947 params, | |
948 _authenticationServiceMethodGetOAuth2TokenName, | |
949 -1, | |
950 bindings.MessageHeader.kMessageExpectsResponse); | |
951 } | |
952 void clearOAuth2Token(String token) { | |
953 if (!_proxyImpl.isBound) { | |
954 _proxyImpl.proxyError("The Proxy is closed."); | |
955 return; | |
956 } | |
957 var params = new _AuthenticationServiceClearOAuth2TokenParams(); | |
958 params.token = token; | |
959 _proxyImpl.sendMessage(params, _authenticationServiceMethodClearOAuth2Toke
nName); | |
960 } | |
961 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory =
null]) { | |
962 var params = new _AuthenticationServiceGetOAuth2DeviceCodeParams(); | |
963 params.scopes = scopes; | |
964 return _proxyImpl.sendMessageWithRequestId( | |
965 params, | |
966 _authenticationServiceMethodGetOAuth2DeviceCodeName, | |
967 -1, | |
968 bindings.MessageHeader.kMessageExpectsResponse); | |
969 } | |
970 dynamic addAccount(String deviceCode,[Function responseFactory = null]) { | |
971 var params = new _AuthenticationServiceAddAccountParams(); | |
972 params.deviceCode = deviceCode; | |
973 return _proxyImpl.sendMessageWithRequestId( | |
974 params, | |
975 _authenticationServiceMethodAddAccountName, | |
976 -1, | |
977 bindings.MessageHeader.kMessageExpectsResponse); | |
978 } | |
979 } | |
980 | 936 |
| 937 AuthenticationServiceProxy.unbound() |
| 938 : super(new _AuthenticationServiceProxyControl.unbound()); |
981 | 939 |
982 class AuthenticationServiceProxy implements bindings.ProxyBase { | 940 static AuthenticationServiceProxy newFromEndpoint( |
983 final bindings.Proxy impl; | 941 core.MojoMessagePipeEndpoint endpoint) { |
984 AuthenticationService ptr; | 942 assert(endpoint.setDescription("For AuthenticationServiceProxy")); |
985 | 943 return new AuthenticationServiceProxy.fromEndpoint(endpoint); |
986 AuthenticationServiceProxy(_AuthenticationServiceProxyImpl proxyImpl) : | |
987 impl = proxyImpl, | |
988 ptr = new _AuthenticationServiceProxyCalls(proxyImpl); | |
989 | |
990 AuthenticationServiceProxy.fromEndpoint( | |
991 core.MojoMessagePipeEndpoint endpoint) : | |
992 impl = new _AuthenticationServiceProxyImpl.fromEndpoint(endpoint) { | |
993 ptr = new _AuthenticationServiceProxyCalls(impl); | |
994 } | |
995 | |
996 AuthenticationServiceProxy.fromHandle(core.MojoHandle handle) : | |
997 impl = new _AuthenticationServiceProxyImpl.fromHandle(handle) { | |
998 ptr = new _AuthenticationServiceProxyCalls(impl); | |
999 } | |
1000 | |
1001 AuthenticationServiceProxy.unbound() : | |
1002 impl = new _AuthenticationServiceProxyImpl.unbound() { | |
1003 ptr = new _AuthenticationServiceProxyCalls(impl); | |
1004 } | 944 } |
1005 | 945 |
1006 factory AuthenticationServiceProxy.connectToService( | 946 factory AuthenticationServiceProxy.connectToService( |
1007 bindings.ServiceConnector s, String url, [String serviceName]) { | 947 bindings.ServiceConnector s, String url, [String serviceName]) { |
1008 AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound(); | 948 AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound(); |
1009 s.connectToService(url, p, serviceName); | 949 s.connectToService(url, p, serviceName); |
1010 return p; | 950 return p; |
1011 } | 951 } |
1012 | 952 |
1013 static AuthenticationServiceProxy newFromEndpoint( | 953 |
1014 core.MojoMessagePipeEndpoint endpoint) { | 954 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null
]) { |
1015 assert(endpoint.setDescription("For AuthenticationServiceProxy")); | 955 var params = new _AuthenticationServiceSelectAccountParams(); |
1016 return new AuthenticationServiceProxy.fromEndpoint(endpoint); | 956 params.returnLastSelected = returnLastSelected; |
| 957 return ctrl.sendMessageWithRequestId( |
| 958 params, |
| 959 _authenticationServiceMethodSelectAccountName, |
| 960 -1, |
| 961 bindings.MessageHeader.kMessageExpectsResponse); |
1017 } | 962 } |
1018 | 963 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF
actory = null]) { |
1019 String get serviceName => AuthenticationService.serviceName; | 964 var params = new _AuthenticationServiceGetOAuth2TokenParams(); |
1020 | 965 params.username = username; |
1021 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 966 params.scopes = scopes; |
1022 | 967 return ctrl.sendMessageWithRequestId( |
1023 Future responseOrError(Future f) => impl.responseOrError(f); | 968 params, |
1024 | 969 _authenticationServiceMethodGetOAuth2TokenName, |
1025 Future get errorFuture => impl.errorFuture; | 970 -1, |
1026 | 971 bindings.MessageHeader.kMessageExpectsResponse); |
1027 int get version => impl.version; | |
1028 | |
1029 Future<int> queryVersion() => impl.queryVersion(); | |
1030 | |
1031 void requireVersion(int requiredVersion) { | |
1032 impl.requireVersion(requiredVersion); | |
1033 } | 972 } |
1034 | 973 void clearOAuth2Token(String token) { |
1035 String toString() { | 974 if (!ctrl.isBound) { |
1036 return "AuthenticationServiceProxy($impl)"; | 975 ctrl.proxyError("The Proxy is closed."); |
| 976 return; |
| 977 } |
| 978 var params = new _AuthenticationServiceClearOAuth2TokenParams(); |
| 979 params.token = token; |
| 980 ctrl.sendMessage(params, |
| 981 _authenticationServiceMethodClearOAuth2TokenName); |
| 982 } |
| 983 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu
ll]) { |
| 984 var params = new _AuthenticationServiceGetOAuth2DeviceCodeParams(); |
| 985 params.scopes = scopes; |
| 986 return ctrl.sendMessageWithRequestId( |
| 987 params, |
| 988 _authenticationServiceMethodGetOAuth2DeviceCodeName, |
| 989 -1, |
| 990 bindings.MessageHeader.kMessageExpectsResponse); |
| 991 } |
| 992 dynamic addAccount(String deviceCode,[Function responseFactory = null]) { |
| 993 var params = new _AuthenticationServiceAddAccountParams(); |
| 994 params.deviceCode = deviceCode; |
| 995 return ctrl.sendMessageWithRequestId( |
| 996 params, |
| 997 _authenticationServiceMethodAddAccountName, |
| 998 -1, |
| 999 bindings.MessageHeader.kMessageExpectsResponse); |
1037 } | 1000 } |
1038 } | 1001 } |
1039 | 1002 |
1040 | 1003 |
1041 class AuthenticationServiceStub extends bindings.Stub { | 1004 class AuthenticationServiceStub extends bindings.Stub { |
1042 AuthenticationService _impl; | 1005 AuthenticationService _impl; |
1043 | 1006 |
1044 AuthenticationServiceStub.fromEndpoint( | 1007 AuthenticationServiceStub.fromEndpoint( |
1045 core.MojoMessagePipeEndpoint endpoint, [AuthenticationService impl]) | 1008 core.MojoMessagePipeEndpoint endpoint, [AuthenticationService impl]) |
1046 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1009 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 static service_describer.ServiceDescription get serviceDescription { | 1192 static service_describer.ServiceDescription get serviceDescription { |
1230 if (_cachedServiceDescription == null) { | 1193 if (_cachedServiceDescription == null) { |
1231 _cachedServiceDescription = new _AuthenticationServiceServiceDescription()
; | 1194 _cachedServiceDescription = new _AuthenticationServiceServiceDescription()
; |
1232 } | 1195 } |
1233 return _cachedServiceDescription; | 1196 return _cachedServiceDescription; |
1234 } | 1197 } |
1235 } | 1198 } |
1236 | 1199 |
1237 | 1200 |
1238 | 1201 |
OLD | NEW |