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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_
7
8 #include "chrome/browser/sync/profile_sync_service_observer.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/notification_types.h"
12
13 class Profile;
14
15 // This class listens to notifications from various services (SigninManager,
16 // ProfileSyncService, etc) and coalesces them into notifications for the UI
17 // layer.
18 class SigninTracker : public ProfileSyncServiceObserver,
19 public content::NotificationObserver {
20 public:
21 class Observer {
22 public:
23 // The GAIA credentials entered by the user have been validated.
24 virtual void GaiaCredentialsValid() = 0;
25
26 // The signin attempt failed. If this is called after GaiaCredentialsValid()
27 // then it means there was an error launching one of the dependent services.
28 virtual void SigninFailed() = 0;
29
30 // The signin attempt succeeded.
31 virtual void SigninSuccess() = 0;
32 };
33
34 // Creates a SigninTracker that tracks the signin status on the passed
35 // |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.
36 SigninTracker(Profile* profile, Observer* observer);
37 virtual ~SigninTracker();
38
39 // content::NotificationObserver implementation.
40 virtual void Observe(int type,
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE;
43
44 // ProfileSyncServiceObserver implementation.
45 virtual void OnStateChanged() OVERRIDE;
46
47 // Returns true if the various authenticated services are properly signed in
48 // (no auth errors, etc).
49 static bool AreServicesSignedIn(Profile* profile);
50
51 private:
52
James Hawkins 2012/02/10 23:08:01 nit: Remove extra blank line.
Andrew T Wilson (Slow) 2012/02/11 01:50:45 Done.
53 // The various states the login process can be in.
54 enum LoginState {
55 WAITING_FOR_GAIA_VALIDATION,
56 SERVICES_INITIALIZING,
57 SIGNIN_COMPLETE
58 };
59
60 // The current state of the login process.
61 LoginState state_;
62
63 // The profile whose signin status we are tracking.
64 Profile* profile_;
65
66 // Observer we call when the signin state changes.
67 Observer* observer_;
68
69 // Set to true when SigninManager has validated our credentials.
70 bool credentials_valid_;
71
72 // Used to listen to notifications from the SigninManager.
73 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
74 };
75
76 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698