Commit 3b9a4290 authored by sdefresne's avatar sdefresne Committed by Commit bot

Access SigninErrorProvider through ChromeBrowserProvider.

BUG=475439

Review-Url: https://codereview.chromium.org/2442563002
Cr-Commit-Position: refs/heads/master@{#427054}
parent d64eb513
......@@ -80,24 +80,23 @@ ProfileOAuth2TokenServiceIOSProviderImpl::GetAuthenticationErrorCategory(
return kAuthenticationErrorCategoryAuthorizationErrors;
}
ios::SigninErrorCategory error_category =
ios::GetSigninErrorProvider()->GetErrorCategory(error);
switch (error_category) {
ios::SigninErrorProvider* provider =
ios::GetChromeBrowserProvider()->GetSigninErrorProvider();
switch (provider->GetErrorCategory(error)) {
case ios::SigninErrorCategory::UNKNOWN_ERROR: {
// Google's OAuth 2 implementation returns a 400 with JSON body
// containing error key "invalid_grant" to indicate the refresh token
// is invalid or has been revoked by the user.
// Check that the underlying library does not categorize these errors as
// unknown.
NSString* json_error_key =
ios::GetSigninErrorProvider()->GetInvalidGrantJsonErrorKey();
DCHECK(!ios::GetSigninErrorProvider()->IsBadRequest(error) ||
NSString* json_error_key = provider->GetInvalidGrantJsonErrorKey();
DCHECK(!provider->IsBadRequest(error) ||
![[[error userInfo] valueForKeyPath:@"json.error"]
isEqual:json_error_key]);
return kAuthenticationErrorCategoryUnknownErrors;
}
case ios::SigninErrorCategory::AUTHORIZATION_ERROR:
if (ios::GetSigninErrorProvider()->IsForbidden(error)) {
if (provider->IsForbidden(error)) {
return kAuthenticationErrorCategoryAuthorizationForbiddenErrors;
}
return kAuthenticationErrorCategoryAuthorizationErrors;
......
......@@ -6,6 +6,7 @@
#include "base/strings/sys_string_conversions.h"
#include "google_apis/gaia/gaia_auth_util.h"
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
#include "ios/public/provider/chrome/browser/signin/signin_error_provider.h"
......@@ -26,7 +27,8 @@ std::string GetCanonicalizedEmailForIdentity(ChromeIdentity* identity) {
}
bool ShouldHandleSigninError(NSError* error) {
ios::SigninErrorProvider* provider = ios::GetSigninErrorProvider();
ios::SigninErrorProvider* provider =
ios::GetChromeBrowserProvider()->GetSigninErrorProvider();
return ![provider->GetSigninErrorDomain() isEqualToString:error.domain] ||
(error.code != provider->GetCode(ios::SigninError::CANCELED) &&
error.code !=
......
......@@ -6,6 +6,7 @@
#include "base/mac/scoped_block.h"
#include "base/mac/scoped_nsobject.h"
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
#include "ios/public/provider/chrome/browser/signin/signin_error_provider.h"
......@@ -161,7 +162,8 @@
}
- (NSError*)canceledError {
ios::SigninErrorProvider* provider = ios::GetSigninErrorProvider();
ios::SigninErrorProvider* provider =
ios::GetChromeBrowserProvider()->GetSigninErrorProvider();
return [NSError errorWithDomain:provider->GetSigninErrorDomain()
code:provider->GetCode(ios::SigninError::CANCELED)
userInfo:nil];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment