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