1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_
6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_
8 #include "base/macros.h"
15 class SigninErrorProvider
;
17 // Signin error categories.
18 // Can be used to figure out whether the error is because the user has their
19 // credentials revoked, deleted or disabled so the appropriate action can be
21 enum class SigninErrorCategory
{
23 AUTHORIZATION_ERROR
, // Should be handled by signing out the user.
24 NETWORK_ERROR
, // Should be treated as transient/offline errors.
25 USER_CANCELLATION_ERROR
// Should be treated as a no-op.
28 enum class SigninError
{
29 CANCELED
, // Operation canceled.
30 MISSING_IDENTITY
, // Request is missing identity.
31 HANDLED_INTERNALLY
// Has been displayed to the user already.
34 // Registers and returns the global SigninErrorProvider.
35 void SetSigninErrorProvider(SigninErrorProvider
* provider
);
36 SigninErrorProvider
* GetSigninErrorProvider();
38 // Provides utility methods and constants for interpreting signin errors.
39 class SigninErrorProvider
{
41 SigninErrorProvider();
42 virtual ~SigninErrorProvider();
44 // Returns what family an error belongs to.
45 virtual SigninErrorCategory
GetErrorCategory(NSError
* error
);
47 // Tests if an NSError is user cancellation error.
48 virtual bool IsCanceled(NSError
* error
);
50 // Constant in JSON error responses to server requests indicating that
51 // the authentication was revoked by the server.
52 virtual NSString
* GetInvalidGrantJsonErrorKey();
54 // Gets the signin error domain.
55 virtual NSString
* GetSigninErrorDomain();
57 // Gets the error code corresponding to |error|.
58 virtual int GetCode(SigninError error
);
61 DISALLOW_COPY_AND_ASSIGN(SigninErrorProvider
);
66 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_