| 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_UTILITY_H_ | 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_ |
| 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_ | 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/timer/timer.h" | |
| 17 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 16 #include "chrome/browser/managed_mode/managed_user_sync_service.h" |
| 18 #include "chrome/browser/managed_mode/managed_user_sync_service_observer.h" | 17 #include "chrome/browser/managed_mode/managed_user_sync_service_observer.h" |
| 19 #include "chrome/browser/managed_mode/managed_users.h" | 18 #include "chrome/browser/managed_mode/managed_users.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 20 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 22 | 21 |
| 23 class GoogleServiceAuthError; | 22 class GoogleServiceAuthError; |
| 24 class ManagedUserRefreshTokenFetcher; | 23 class ManagedUserRefreshTokenFetcher; |
| 25 class ManagedUserRegistrationUtilityTest; | 24 class ManagedUserRegistrationUtilityTest; |
| 26 class PrefService; | 25 class PrefService; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // unique ID for the new managed user. If its value is the same as that of | 60 // unique ID for the new managed user. If its value is the same as that of |
| 62 // of one of the existing managed users, then the same user will be created | 61 // of one of the existing managed users, then the same user will be created |
| 63 // on this machine. |info| contains necessary information like the display | 62 // on this machine. |info| contains necessary information like the display |
| 64 // name of the the user. |callback| is called with the result of the | 63 // name of the the user. |callback| is called with the result of the |
| 65 // registration. We use the info here and not the profile, because on | 64 // registration. We use the info here and not the profile, because on |
| 66 // Chrome OS the profile of the managed user does not yet exist. | 65 // Chrome OS the profile of the managed user does not yet exist. |
| 67 void Register(const std::string& managed_user_id, | 66 void Register(const std::string& managed_user_id, |
| 68 const ManagedUserRegistrationInfo& info, | 67 const ManagedUserRegistrationInfo& info, |
| 69 const RegistrationCallback& callback); | 68 const RegistrationCallback& callback); |
| 70 | 69 |
| 71 void StartRegistrationTimer(); | |
| 72 | |
| 73 // ManagedUserSyncServiceObserver: | 70 // ManagedUserSyncServiceObserver: |
| 74 virtual void OnManagedUserAcknowledged(const std::string& managed_user_id) | 71 virtual void OnManagedUserAcknowledged(const std::string& managed_user_id) |
| 75 OVERRIDE; | 72 OVERRIDE; |
| 76 virtual void OnManagedUsersSyncingStopped() OVERRIDE; | 73 virtual void OnManagedUsersSyncingStopped() OVERRIDE; |
| 77 | 74 |
| 78 private: | 75 private: |
| 79 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, Register); | 76 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, Register); |
| 80 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, | 77 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, |
| 81 RegisterBeforeInitialSync); | 78 RegisterBeforeInitialSync); |
| 82 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, | 79 FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // callback or reporting an error. | 112 // callback or reporting an error. |
| 116 void CancelPendingRegistration(); | 113 void CancelPendingRegistration(); |
| 117 | 114 |
| 118 base::WeakPtrFactory<ManagedUserRegistrationUtility> weak_ptr_factory_; | 115 base::WeakPtrFactory<ManagedUserRegistrationUtility> weak_ptr_factory_; |
| 119 PrefService* prefs_; | 116 PrefService* prefs_; |
| 120 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_; | 117 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_; |
| 121 | 118 |
| 122 // A |BrowserContextKeyedService| owned by the custodian profile. | 119 // A |BrowserContextKeyedService| owned by the custodian profile. |
| 123 ManagedUserSyncService* managed_user_sync_service_; | 120 ManagedUserSyncService* managed_user_sync_service_; |
| 124 | 121 |
| 125 // Provides a timeout during profile creation. | |
| 126 base::OneShotTimer<ManagedUserRegistrationUtility> registration_timer_; | |
| 127 | |
| 128 std::string pending_managed_user_id_; | 122 std::string pending_managed_user_id_; |
| 129 std::string pending_managed_user_token_; | 123 std::string pending_managed_user_token_; |
| 130 bool pending_managed_user_acknowledged_; | 124 bool pending_managed_user_acknowledged_; |
| 131 bool is_existing_managed_user_; | 125 bool is_existing_managed_user_; |
| 132 RegistrationCallback callback_; | 126 RegistrationCallback callback_; |
| 133 | 127 |
| 134 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtility); | 128 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtility); |
| 135 }; | 129 }; |
| 136 | 130 |
| 137 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_ | 131 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_ |
| OLD | NEW |