OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_im
pl.h" | 5 #include "ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_im
pl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "ios/chrome/browser/signin/constants.h" | 9 #include "ios/chrome/browser/signin/constants.h" |
10 #include "ios/chrome/browser/signin/signin_util.h" | 10 #include "ios/chrome/browser/signin/signin_util.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return kAuthenticationErrorCategoryUnknownIdentityErrors; | 73 return kAuthenticationErrorCategoryUnknownIdentityErrors; |
74 } | 74 } |
75 | 75 |
76 ios::ChromeIdentityService* identity_service = | 76 ios::ChromeIdentityService* identity_service = |
77 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); | 77 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); |
78 if (identity_service->IsMDMError( | 78 if (identity_service->IsMDMError( |
79 identity_service->GetIdentityWithGaiaID(gaia_id), error)) { | 79 identity_service->GetIdentityWithGaiaID(gaia_id), error)) { |
80 return kAuthenticationErrorCategoryAuthorizationErrors; | 80 return kAuthenticationErrorCategoryAuthorizationErrors; |
81 } | 81 } |
82 | 82 |
83 ios::SigninErrorCategory error_category = | 83 ios::SigninErrorProvider* provider = |
84 ios::GetSigninErrorProvider()->GetErrorCategory(error); | 84 ios::GetChromeBrowserProvider()->GetSigninErrorProvider(); |
85 switch (error_category) { | 85 switch (provider->GetErrorCategory(error)) { |
86 case ios::SigninErrorCategory::UNKNOWN_ERROR: { | 86 case ios::SigninErrorCategory::UNKNOWN_ERROR: { |
87 // Google's OAuth 2 implementation returns a 400 with JSON body | 87 // Google's OAuth 2 implementation returns a 400 with JSON body |
88 // containing error key "invalid_grant" to indicate the refresh token | 88 // containing error key "invalid_grant" to indicate the refresh token |
89 // is invalid or has been revoked by the user. | 89 // is invalid or has been revoked by the user. |
90 // Check that the underlying library does not categorize these errors as | 90 // Check that the underlying library does not categorize these errors as |
91 // unknown. | 91 // unknown. |
92 NSString* json_error_key = | 92 NSString* json_error_key = provider->GetInvalidGrantJsonErrorKey(); |
93 ios::GetSigninErrorProvider()->GetInvalidGrantJsonErrorKey(); | 93 DCHECK(!provider->IsBadRequest(error) || |
94 DCHECK(!ios::GetSigninErrorProvider()->IsBadRequest(error) || | |
95 ![[[error userInfo] valueForKeyPath:@"json.error"] | 94 ![[[error userInfo] valueForKeyPath:@"json.error"] |
96 isEqual:json_error_key]); | 95 isEqual:json_error_key]); |
97 return kAuthenticationErrorCategoryUnknownErrors; | 96 return kAuthenticationErrorCategoryUnknownErrors; |
98 } | 97 } |
99 case ios::SigninErrorCategory::AUTHORIZATION_ERROR: | 98 case ios::SigninErrorCategory::AUTHORIZATION_ERROR: |
100 if (ios::GetSigninErrorProvider()->IsForbidden(error)) { | 99 if (provider->IsForbidden(error)) { |
101 return kAuthenticationErrorCategoryAuthorizationForbiddenErrors; | 100 return kAuthenticationErrorCategoryAuthorizationForbiddenErrors; |
102 } | 101 } |
103 return kAuthenticationErrorCategoryAuthorizationErrors; | 102 return kAuthenticationErrorCategoryAuthorizationErrors; |
104 case ios::SigninErrorCategory::NETWORK_ERROR: | 103 case ios::SigninErrorCategory::NETWORK_ERROR: |
105 return kAuthenticationErrorCategoryNetworkServerErrors; | 104 return kAuthenticationErrorCategoryNetworkServerErrors; |
106 case ios::SigninErrorCategory::USER_CANCELLATION_ERROR: | 105 case ios::SigninErrorCategory::USER_CANCELLATION_ERROR: |
107 return kAuthenticationErrorCategoryUserCancellationErrors; | 106 return kAuthenticationErrorCategoryUserCancellationErrors; |
108 } | 107 } |
109 } | 108 } |
OLD | NEW |