OLD | NEW |
---|---|
(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. |observer| must | |
36 // be non-null. | |
37 SigninTracker(Profile* profile, Observer* observer); | |
38 virtual ~SigninTracker(); | |
39 | |
40 // content::NotificationObserver implementation. | |
41 virtual void Observe(int type, | |
42 const content::NotificationSource& source, | |
43 const content::NotificationDetails& details) OVERRIDE; | |
44 | |
45 // ProfileSyncServiceObserver implementation. | |
46 virtual void OnStateChanged() OVERRIDE; | |
47 | |
48 // Returns true if the various authenticated services are properly signed in | |
49 // (no auth errors, etc). | |
50 static bool AreServicesSignedIn(Profile* profile); | |
51 | |
52 private: | |
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_; | |
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.
| |
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_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(SigninTracker); | |
76 }; | |
77 | |
78 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_TRACKER_H_ | |
79 | |
OLD | NEW |