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.
5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_
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"
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
21 class SigninGlobalError
: public GlobalErrorWithStandardBubble
{
23 class AuthStatusProvider
{
26 virtual ~AuthStatusProvider();
28 // Returns the account id with the status specified by GetAuthStatus().
29 virtual std::string
GetAccountId() const = 0;
31 // API invoked by SigninGlobalError to get the current auth status of
32 // the various signed in services.
33 virtual GoogleServiceAuthError
GetAuthStatus() const = 0;
36 explicit SigninGlobalError(Profile
* profile
);
37 virtual ~SigninGlobalError();
39 // Adds a provider which the SigninGlobalError object will start querying for
41 void AddProvider(const AuthStatusProvider
* provider
);
43 // Removes a provider previously added by SigninGlobalError (generally only
44 // called in preparation for shutdown).
45 void RemoveProvider(const AuthStatusProvider
* provider
);
47 // Invoked when the auth status of an AuthStatusProvider has changed.
48 void AuthStatusChanged();
50 std::string
GetAccountIdOfLastAuthError() const { return account_id_
; }
52 GoogleServiceAuthError
GetLastAuthError() const { return auth_error_
; }
54 // GlobalError implementation.
55 virtual bool HasMenuItem() OVERRIDE
;
56 virtual int MenuItemCommandID() OVERRIDE
;
57 virtual base::string16
MenuItemLabel() OVERRIDE
;
58 virtual void ExecuteMenuItem(Browser
* browser
) OVERRIDE
;
59 virtual bool HasBubbleView() OVERRIDE
;
60 virtual base::string16
GetBubbleViewTitle() OVERRIDE
;
61 virtual std::vector
<base::string16
> GetBubbleViewMessages() OVERRIDE
;
62 virtual base::string16
GetBubbleViewAcceptButtonLabel() OVERRIDE
;
63 virtual base::string16
GetBubbleViewCancelButtonLabel() OVERRIDE
;
64 virtual void OnBubbleViewDidClose(Browser
* browser
) OVERRIDE
;
65 virtual void BubbleViewAcceptButtonPressed(Browser
* browser
) OVERRIDE
;
66 virtual void BubbleViewCancelButtonPressed(Browser
* browser
) OVERRIDE
;
68 // Returns the SigninGlobalError instance for the given profile.
69 static SigninGlobalError
* GetForProfile(Profile
* profile
);
72 std::set
<const AuthStatusProvider
*> provider_set_
;
74 // The account that generated the last auth error.
75 std::string account_id_
;
77 // The auth error detected the last time AuthStatusChanged() was invoked (or
78 // NONE if AuthStatusChanged() has never been invoked).
79 GoogleServiceAuthError auth_error_
;
81 // The Profile this object belongs to.
85 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_