GIDSignInInternalOptions.m 2.8 KB

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