Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5082)

Unified Diff: chrome/browser/ui/webui/signin/signin_tracker.h

Issue 9295044: Start moving signin code out of browser/sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..34f0ba7e90c22a20e7607bd6855e1d18df440699
--- /dev/null
+++ b/chrome/browser/ui/webui/signin/signin_tracker.h
@@ -0,0 +1,77 @@
+// 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.
James Hawkins 2012/02/10 23:08:01 |observer| must not be NULL.
Andrew T Wilson (Slow) 2012/02/11 01:50:45 Done.
+ 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:
+
James Hawkins 2012/02/10 23:08:01 nit: Remove extra blank line.
Andrew T Wilson (Slow) 2012/02/11 01:50:45 Done.
+ // 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_;
+
+ // Set to true when SigninManager has validated our credentials.
+ bool credentials_valid_;
+
+ // Used to listen to notifications from the SigninManager.
+ content::NotificationRegistrar registrar_;
James Hawkins 2012/02/10 23:08:01 DISALLOW_COPY_AND_ASSIGN?
Andrew T Wilson (Slow) 2012/02/11 01:50:45 Good catch. Added to LoginUIService[Factory] as we
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_
+

Powered by Google App Engine
This is Rietveld 408576698