GIDSignInInternalOptions.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
  15. #import "GoogleSignIn/Sources/GIDScopes.h"
  16. NS_ASSUME_NONNULL_BEGIN
  17. @implementation GIDSignInInternalOptions
  18. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  19. presentingViewController:(nullable UIViewController *)presentingViewController
  20. loginHint:(nullable NSString *)loginHint
  21. callback:(GIDSignInCallback)callback {
  22. GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
  23. if (options) {
  24. options->_interactive = YES;
  25. options->_continuation = NO;
  26. options->_configuration = configuration;
  27. options->_presentingViewController = presentingViewController;
  28. options->_loginHint = loginHint;
  29. options->_callback = callback;
  30. options->_scopes = [GIDScopes scopesWithBasicProfile:@[]];
  31. }
  32. return options;
  33. }
  34. + (instancetype)silentOptionsWithCallback:(GIDSignInCallback)callback {
  35. GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil
  36. presentingViewController:nil
  37. loginHint:nil
  38. callback:callback];
  39. if (options) {
  40. options->_interactive = NO;
  41. }
  42. return options;
  43. }
  44. - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
  45. forContinuation:(BOOL)continuation {
  46. GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
  47. if (options) {
  48. options->_interactive = _interactive;
  49. options->_continuation = continuation;
  50. options->_configuration = _configuration;
  51. options->_presentingViewController = _presentingViewController;
  52. options->_loginHint = _loginHint;
  53. options->_callback = _callback;
  54. options->_scopes = _scopes;
  55. options->_extraParams = [extraParams copy];
  56. }
  57. return options;
  58. }
  59. @end
  60. NS_ASSUME_NONNULL_END