Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / signin / signin_global_error.h
blobb68b1be8e237b1373b49180ede55044740d522fa
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_
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"
14 class Profile;
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 GlobalErrorWithStandardBubble {
22 public:
23 class AuthStatusProvider {
24 public:
25 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
40 // auth status.
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);
71 private:
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.
82 Profile* profile_;
85 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_GLOBAL_ERROR_H_