OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ | 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 explicit ManagedUserRegistrationService(PrefService* prefs); | 40 explicit ManagedUserRegistrationService(PrefService* prefs); |
41 virtual ~ManagedUserRegistrationService(); | 41 virtual ~ManagedUserRegistrationService(); |
42 | 42 |
43 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | 43 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
44 | 44 |
45 // Registers a new managed user with the server. |name| is the display name of | 45 // Registers a new managed user with the server. |name| is the display name of |
46 // the user. |callback| is called with the result of the registration. | 46 // the user. |callback| is called with the result of the registration. |
47 void Register(const string16& name, const RegistrationCallback& callback); | 47 void Register(const string16& name, const RegistrationCallback& callback); |
48 | 48 |
49 // Convenience method that registers a new managed user with the server and | |
50 // initializes it locally. The callback allows it to be run after a new | |
51 // profile has been created: | |
52 // ProfileManager::CreateMultiProfileAsync( | |
53 // name, icon, | |
54 // managed_user_registration_service->GetRegistrationAndInitCallback(), | |
55 // managed_user); | |
56 ProfileManager::CreateCallback GetRegistrationAndInitCallback(); | |
57 | |
58 // ProfileKeyedService implementation: | 49 // ProfileKeyedService implementation: |
59 virtual void Shutdown() OVERRIDE; | 50 virtual void Shutdown() OVERRIDE; |
60 | 51 |
61 // SyncableService implementation: | 52 // SyncableService implementation: |
62 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 53 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( |
63 syncer::ModelType type, | 54 syncer::ModelType type, |
64 const syncer::SyncDataList& initial_sync_data, | 55 const syncer::SyncDataList& initial_sync_data, |
65 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 56 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
66 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | 57 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; |
67 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 58 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
(...skipping 14 matching lines...) Expand all Loading... |
82 | 73 |
83 // Dispatches the callback if all the conditions have been met. | 74 // Dispatches the callback if all the conditions have been met. |
84 void DispatchCallbackIfReady(); | 75 void DispatchCallbackIfReady(); |
85 | 76 |
86 void CancelPendingRegistration(); | 77 void CancelPendingRegistration(); |
87 | 78 |
88 // Dispatches the callback with the saved token (which may be empty) and the | 79 // Dispatches the callback with the saved token (which may be empty) and the |
89 // given |error|. | 80 // given |error|. |
90 void DispatchCallback(const GoogleServiceAuthError& error); | 81 void DispatchCallback(const GoogleServiceAuthError& error); |
91 | 82 |
92 void OnProfileCreated(Profile* profile, Profile::CreateStatus status); | |
93 | |
94 base::WeakPtrFactory<ManagedUserRegistrationService> weak_ptr_factory_; | 83 base::WeakPtrFactory<ManagedUserRegistrationService> weak_ptr_factory_; |
95 PrefService* prefs_; | 84 PrefService* prefs_; |
96 PrefChangeRegistrar pref_change_registrar_; | 85 PrefChangeRegistrar pref_change_registrar_; |
97 | 86 |
98 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 87 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
99 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 88 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
100 | 89 |
101 std::string pending_managed_user_id_; | 90 std::string pending_managed_user_id_; |
102 std::string pending_managed_user_token_; | 91 std::string pending_managed_user_token_; |
103 bool pending_managed_user_acknowledged_; | 92 bool pending_managed_user_acknowledged_; |
104 RegistrationCallback callback_; | 93 RegistrationCallback callback_; |
105 | 94 |
106 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationService); | 95 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationService); |
107 }; | 96 }; |
108 | 97 |
109 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ | 98 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_SERVICE_H_ |
OLD | NEW |