| Index: ios/public/provider/chrome/browser/signin/signin_error_provider.h
|
| diff --git a/ios/public/provider/chrome/browser/signin/signin_error_provider.h b/ios/public/provider/chrome/browser/signin/signin_error_provider.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cf44c881b31c9e5561761809ff1fef3bdb6ee7b0
|
| --- /dev/null
|
| +++ b/ios/public/provider/chrome/browser/signin/signin_error_provider.h
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_
|
| +#define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_
|
| +
|
| +#include "base/macros.h"
|
| +
|
| +@class NSError;
|
| +@class NSString;
|
| +
|
| +namespace ios {
|
| +
|
| +class SigninErrorProvider;
|
| +
|
| +// Signin error categories.
|
| +// Can be used to figure out whether the error is because the user has their
|
| +// credentials revoked, deleted or disabled so the appropriate action can be
|
| +// taken.
|
| +enum class SigninErrorCategory {
|
| + UNKNOWN_ERROR,
|
| + AUTHORIZATION_ERROR, // Should be handled by signing out the user.
|
| + NETWORK_ERROR, // Should be treated as transient/offline errors.
|
| + USER_CANCELLATION_ERROR // Should be treated as a no-op.
|
| +};
|
| +
|
| +enum class SigninError {
|
| + CANCELED, // Operation canceled.
|
| + MISSING_IDENTITY, // Request is missing identity.
|
| + HANDLED_INTERNALLY // Has been displayed to the user already.
|
| +};
|
| +
|
| +// Registers and returns the global SigninErrorProvider.
|
| +void SetSigninErrorProvider(SigninErrorProvider* provider);
|
| +SigninErrorProvider* GetSigninErrorProvider();
|
| +
|
| +// Provides utility methods and constants for interpreting signin errors.
|
| +class SigninErrorProvider {
|
| + public:
|
| + SigninErrorProvider();
|
| + virtual ~SigninErrorProvider();
|
| +
|
| + // Returns what family an error belongs to.
|
| + virtual SigninErrorCategory GetErrorCategory(NSError* error);
|
| +
|
| + // Tests if an NSError is user cancellation error.
|
| + virtual bool IsCanceled(NSError* error);
|
| +
|
| + // Constant in JSON error responses to server requests indicating that
|
| + // the authentication was revoked by the server.
|
| + virtual NSString* GetInvalidGrantJsonErrorKey();
|
| +
|
| + // Gets the signin error domain.
|
| + virtual NSString* GetSigninErrorDomain();
|
| +
|
| + // Gets the error code corresponding to |error|.
|
| + virtual int GetCode(SigninError error);
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(SigninErrorProvider);
|
| +};
|
| +
|
| +} // namespace ios
|
| +
|
| +#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_
|
|
|