Index: chrome/browser/ui/webui/signin/signin_tracker.h |
diff --git a/chrome/browser/ui/webui/signin/signin_tracker.h b/chrome/browser/ui/webui/signin/signin_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b65816ddc98e5fd23d88e34800f0b20b11f04cdb |
--- /dev/null |
+++ b/chrome/browser/ui/webui/signin/signin_tracker.h |
@@ -0,0 +1,79 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_ |
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_ |
+ |
+#include "chrome/browser/sync/profile_sync_service_observer.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
+#include "content/public/browser/notification_types.h" |
+ |
+class Profile; |
+ |
+// This class listens to notifications from various services (SigninManager, |
+// ProfileSyncService, etc) and coalesces them into notifications for the UI |
+// layer. |
+class SigninTracker : public ProfileSyncServiceObserver, |
+ public content::NotificationObserver { |
+ public: |
+ class Observer { |
+ public: |
+ // The GAIA credentials entered by the user have been validated. |
+ virtual void GaiaCredentialsValid() = 0; |
+ |
+ // The signin attempt failed. If this is called after GaiaCredentialsValid() |
+ // then it means there was an error launching one of the dependent services. |
+ virtual void SigninFailed() = 0; |
+ |
+ // The signin attempt succeeded. |
+ virtual void SigninSuccess() = 0; |
+ }; |
+ |
+ // Creates a SigninTracker that tracks the signin status on the passed |
+ // |profile|, and notifies the |observer| on status changes. |observer| must |
+ // be non-null. |
+ SigninTracker(Profile* profile, Observer* observer); |
+ virtual ~SigninTracker(); |
+ |
+ // content::NotificationObserver implementation. |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ // ProfileSyncServiceObserver implementation. |
+ virtual void OnStateChanged() OVERRIDE; |
+ |
+ // Returns true if the various authenticated services are properly signed in |
+ // (no auth errors, etc). |
+ static bool AreServicesSignedIn(Profile* profile); |
+ |
+ private: |
+ // The various states the login process can be in. |
+ enum LoginState { |
+ WAITING_FOR_GAIA_VALIDATION, |
+ SERVICES_INITIALIZING, |
+ SIGNIN_COMPLETE |
+ }; |
+ |
+ // The current state of the login process. |
+ LoginState state_; |
+ |
+ // The profile whose signin status we are tracking. |
+ Profile* profile_; |
+ |
+ // Observer we call when the signin state changes. |
+ Observer* observer_; |
tim (not reviewing)
2012/02/14 17:22:29
Brief comment that we require this to live beyond
Andrew T Wilson (Slow)
2012/02/14 20:52:36
Done.
|
+ |
+ // Set to true when SigninManager has validated our credentials. |
+ bool credentials_valid_; |
+ |
+ // Used to listen to notifications from the SigninManager. |
+ content::NotificationRegistrar registrar_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SigninTracker); |
+}; |
+ |
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_ |
+ |