OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ |
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "chrome/browser/ui/global_error/global_error.h" | 11 #include "chrome/browser/ui/global_error/global_error.h" |
12 #include "google_apis/gaia/google_service_auth_error.h" | 12 #include "google_apis/gaia/google_service_auth_error.h" |
13 | 13 |
14 class Profile; | 14 class Profile; |
| 15 class SigninManager; |
15 | 16 |
16 // Shows auth errors on the wrench menu using a bubble view and a | 17 // Shows auth errors on the wrench menu using a bubble view and a |
17 // menu item. Services that wish to expose auth errors to the user should | 18 // menu item. Services that wish to expose auth errors to the user should |
18 // register an AuthStatusProvider to report their current authentication state, | 19 // register an AuthStatusProvider to report their current authentication state, |
19 // and should invoke AuthStatusChanged() when their authentication state may | 20 // and should invoke AuthStatusChanged() when their authentication state may |
20 // have changed. | 21 // have changed. |
21 class SigninGlobalError : public GlobalError { | 22 class SigninGlobalError : public GlobalError { |
22 public: | 23 public: |
23 class AuthStatusProvider { | 24 class AuthStatusProvider { |
24 public: | 25 public: |
25 AuthStatusProvider(); | 26 AuthStatusProvider(); |
26 virtual ~AuthStatusProvider(); | 27 virtual ~AuthStatusProvider(); |
27 | 28 |
28 // API invoked by SigninGlobalError to get the current auth status of | 29 // API invoked by SigninGlobalError to get the current auth status of |
29 // the various signed in services. | 30 // the various signed in services. |
30 virtual GoogleServiceAuthError GetAuthStatus() const = 0; | 31 virtual GoogleServiceAuthError GetAuthStatus() const = 0; |
31 }; | 32 }; |
32 | 33 |
33 explicit SigninGlobalError(Profile* profile); | 34 SigninGlobalError(SigninManager* signin_manager, Profile* profile); |
34 virtual ~SigninGlobalError(); | 35 virtual ~SigninGlobalError(); |
35 | 36 |
36 // Adds a provider which the SigninGlobalError object will start querying for | 37 // Adds a provider which the SigninGlobalError object will start querying for |
37 // auth status. | 38 // auth status. |
38 void AddProvider(const AuthStatusProvider* provider); | 39 void AddProvider(const AuthStatusProvider* provider); |
39 | 40 |
40 // Removes a provider previously added by SigninGlobalError (generally only | 41 // Removes a provider previously added by SigninGlobalError (generally only |
41 // called in preparation for shutdown). | 42 // called in preparation for shutdown). |
42 void RemoveProvider(const AuthStatusProvider* provider); | 43 void RemoveProvider(const AuthStatusProvider* provider); |
43 | 44 |
44 // Invoked when the auth status of an AuthStatusProvider has changed. | 45 // Invoked when the auth status of an AuthStatusProvider has changed. |
45 void AuthStatusChanged(); | 46 void AuthStatusChanged(); |
46 | 47 |
| 48 GoogleServiceAuthError GetLastAuthError() const { return auth_error_; } |
| 49 |
47 // GlobalError implementation. | 50 // GlobalError implementation. |
48 virtual bool HasBadge() OVERRIDE; | 51 virtual bool HasBadge() OVERRIDE; |
49 virtual bool HasMenuItem() OVERRIDE; | 52 virtual bool HasMenuItem() OVERRIDE; |
50 virtual int MenuItemCommandID() OVERRIDE; | 53 virtual int MenuItemCommandID() OVERRIDE; |
51 virtual string16 MenuItemLabel() OVERRIDE; | 54 virtual string16 MenuItemLabel() OVERRIDE; |
52 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 55 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
53 virtual bool HasBubbleView() OVERRIDE; | 56 virtual bool HasBubbleView() OVERRIDE; |
54 virtual string16 GetBubbleViewTitle() OVERRIDE; | 57 virtual string16 GetBubbleViewTitle() OVERRIDE; |
55 virtual string16 GetBubbleViewMessage() OVERRIDE; | 58 virtual string16 GetBubbleViewMessage() OVERRIDE; |
56 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 59 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
57 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 60 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; |
58 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | 61 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; |
59 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | 62 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; |
60 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | 63 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; |
61 | 64 |
62 private: | 65 private: |
63 std::set<const AuthStatusProvider*> provider_set_; | 66 std::set<const AuthStatusProvider*> provider_set_; |
64 | 67 |
65 // The auth error detected the last time AuthStatusChanged() was invoked (or | 68 // The auth error detected the last time AuthStatusChanged() was invoked (or |
66 // NONE if AuthStatusChanged() has never been invoked). | 69 // NONE if AuthStatusChanged() has never been invoked). |
67 GoogleServiceAuthError auth_error_; | 70 GoogleServiceAuthError auth_error_; |
68 | 71 |
| 72 // The SigninManager that owns this object. |
| 73 SigninManager* signin_manager_; |
| 74 |
69 // The Profile this object belongs to. | 75 // The Profile this object belongs to. |
70 Profile* profile_; | 76 Profile* profile_; |
71 }; | 77 }; |
72 | 78 |
73 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ | 79 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_ |
OLD | NEW |