GIDSignInInternalOptions.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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:
  20. (nullable UIViewController *)presentingViewController
  21. loginHint:(nullable NSString *)loginHint
  22. callback:(GIDSignInCallback)callback {
  23. GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
  24. if (options) {
  25. options->_interactive = YES;
  26. options->_continuation = NO;
  27. options->_configuration = configuration;
  28. options->_presentingViewController = presentingViewController;
  29. options->_loginHint = loginHint;
  30. options->_callback = callback;
  31. options->_scopes = [GIDScopes scopesWithBasicProfile:@[]];
  32. }
  33. return options;
  34. }
  35. + (instancetype)silentOptionsWithCallback:(GIDSignInCallback)callback {
  36. GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil
  37. presentingViewController:nil
  38. loginHint:nil
  39. callback:callback];
  40. if (options) {
  41. options->_interactive = NO;
  42. }
  43. return options;
  44. }
  45. - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
  46. forContinuation:(BOOL)continuation {
  47. GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
  48. if (options) {
  49. options->_interactive = _interactive;
  50. options->_continuation = continuation;
  51. options->_configuration = _configuration;
  52. options->_presentingViewController = _presentingViewController;
  53. options->_loginHint = _loginHint;
  54. options->_callback = _callback;
  55. options->_scopes = _scopes;
  56. options->_extraParams = [extraParams copy];
  57. }
  58. return options;
  59. }
  60. @end
  61. NS_ASSUME_NONNULL_END