Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / public / provider / chrome / browser / signin / signin_error_provider.h
blobcf44c881b31c9e5561761809ff1fef3bdb6ee7b0
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"
10 @class NSError;
11 @class NSString;
13 namespace ios {
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
20 // taken.
21 enum class SigninErrorCategory {
22 UNKNOWN_ERROR,
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 {
40 public:
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);
60 private:
61 DISALLOW_COPY_AND_ASSIGN(SigninErrorProvider);
64 } // namespace ios
66 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_PROVIDER_H_