OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Returns hash for active user ID which is used to identify that user profile | 98 // Returns hash for active user ID which is used to identify that user profile |
99 // on Chrome OS. | 99 // on Chrome OS. |
100 std::string active_user_id_hash() { return active_user_id_hash_; } | 100 std::string active_user_id_hash() { return active_user_id_hash_; } |
101 | 101 |
102 // Clears site data (cookies, history, etc) for signin profile. | 102 // Clears site data (cookies, history, etc) for signin profile. |
103 // Callback can be empty. Not thread-safe. | 103 // Callback can be empty. Not thread-safe. |
104 void ClearSigninProfile(const base::Closure& on_clear_callback); | 104 void ClearSigninProfile(const base::Closure& on_clear_callback); |
105 | 105 |
106 // Returns NULL if profile for user is not found or is not fully loaded. | 106 // Returns NULL if profile for user is not found or is not fully loaded. |
107 Profile* GetProfileByUser(const User* user); | 107 Profile* GetProfileByUser(const user_manager::User* user); |
108 | 108 |
109 // Returns NULL if User is not created. | 109 // Returns NULL if User is not created. |
110 User* GetUserByProfile(Profile* profile); | 110 user_manager::User* GetUserByProfile(Profile* profile); |
111 | 111 |
112 private: | 112 private: |
113 friend class DeviceSettingsTestBase; | 113 friend class DeviceSettingsTestBase; |
114 friend class extensions::ExtensionGarbageCollectorChromeOSUnitTest; | 114 friend class extensions::ExtensionGarbageCollectorChromeOSUnitTest; |
115 friend class FakeUserManager; | 115 friend class FakeUserManager; |
116 friend class KioskTest; | 116 friend class KioskTest; |
117 friend class MockUserManager; | 117 friend class MockUserManager; |
118 friend class MultiProfileUserControllerTest; | 118 friend class MultiProfileUserControllerTest; |
119 friend class ParallelAuthenticatorTest; | 119 friend class ParallelAuthenticatorTest; |
120 friend class ProfileHelperTest; | 120 friend class ProfileHelperTest; |
121 friend class ProfileListChromeOSTest; | 121 friend class ProfileListChromeOSTest; |
122 | 122 |
123 // BrowsingDataRemover::Observer implementation: | 123 // BrowsingDataRemover::Observer implementation: |
124 virtual void OnBrowsingDataRemoverDone() OVERRIDE; | 124 virtual void OnBrowsingDataRemoverDone() OVERRIDE; |
125 | 125 |
126 // UserManager::Observer overrides. | 126 // UserManager::Observer overrides. |
127 virtual void OnSessionRestoreStateChanged( | 127 virtual void OnSessionRestoreStateChanged( |
128 Profile* user_profile, | 128 Profile* user_profile, |
129 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; | 129 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; |
130 | 130 |
131 // UserManager::UserSessionStateObserver implementation: | 131 // UserManager::UserSessionStateObserver implementation: |
132 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE; | 132 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE; |
133 | 133 |
134 // Associates |user| with profile with the same user_id, | 134 // Associates |user| with profile with the same user_id, |
135 // for GetUserByProfile() testing. | 135 // for GetUserByProfile() testing. |
136 void SetProfileToUserMappingForTesting(User* user); | 136 void SetProfileToUserMappingForTesting(user_manager::User* user); |
137 | 137 |
138 // Enables/disables testing code path in GetUserByProfile() like | 138 // Enables/disables testing code path in GetUserByProfile() like |
139 // always return primary user (when always_return_primary_user_for_testing is | 139 // always return primary user (when always_return_primary_user_for_testing is |
140 // set). | 140 // set). |
141 static void SetProfileToUserForTestingEnabled(bool enabled); | 141 static void SetProfileToUserForTestingEnabled(bool enabled); |
142 | 142 |
143 // Enables/disables testing GetUserByProfile() by always returning | 143 // Enables/disables testing GetUserByProfile() by always returning |
144 // primary user. | 144 // primary user. |
145 static void SetAlwaysReturnPrimaryUserForTesting(bool value); | 145 static void SetAlwaysReturnPrimaryUserForTesting(bool value); |
146 | 146 |
147 // Associates |profile| with |user|, for GetProfileByUser() testing. | 147 // Associates |profile| with |user|, for GetProfileByUser() testing. |
148 void SetUserToProfileMappingForTesting(const User* user, Profile* profile); | 148 void SetUserToProfileMappingForTesting(const user_manager::User* user, |
| 149 Profile* profile); |
149 | 150 |
150 // Identifies path to active user profile on Chrome OS. | 151 // Identifies path to active user profile on Chrome OS. |
151 std::string active_user_id_hash_; | 152 std::string active_user_id_hash_; |
152 | 153 |
153 // True if signin profile clearing now. | 154 // True if signin profile clearing now. |
154 bool signin_profile_clear_requested_; | 155 bool signin_profile_clear_requested_; |
155 | 156 |
156 // List of callbacks called after signin profile clearance. | 157 // List of callbacks called after signin profile clearance. |
157 std::vector<base::Closure> on_clear_callbacks_; | 158 std::vector<base::Closure> on_clear_callbacks_; |
158 | 159 |
159 // Used for testing by unit tests and FakeUserManager/MockUserManager. | 160 // Used for testing by unit tests and FakeUserManager/MockUserManager. |
160 std::map<const User*, Profile*> user_to_profile_for_testing_; | 161 std::map<const user_manager::User*, Profile*> user_to_profile_for_testing_; |
161 | 162 |
162 // When this list is not empty GetUserByProfile() will find user that has | 163 // When this list is not empty GetUserByProfile() will find user that has |
163 // the same user_id as |profile|->GetProfileName(). | 164 // the same user_id as |profile|->GetProfileName(). |
164 UserList user_list_for_testing_; | 165 user_manager::UserList user_list_for_testing_; |
165 | 166 |
166 // If true testing code path is used in GetUserByProfile() even if | 167 // If true testing code path is used in GetUserByProfile() even if |
167 // user_list_for_testing_ list is empty. In that case primary user will always | 168 // user_list_for_testing_ list is empty. In that case primary user will always |
168 // be returned. | 169 // be returned. |
169 static bool enable_profile_to_user_testing; | 170 static bool enable_profile_to_user_testing; |
170 | 171 |
171 // If true and enable_profile_to_user_testing is true then primary user will | 172 // If true and enable_profile_to_user_testing is true then primary user will |
172 // always be returned by GetUserByProfile(). | 173 // always be returned by GetUserByProfile(). |
173 static bool always_return_primary_user_for_testing; | 174 static bool always_return_primary_user_for_testing; |
174 | 175 |
175 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); | 176 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); |
176 }; | 177 }; |
177 | 178 |
178 } // namespace chromeos | 179 } // namespace chromeos |
179 | 180 |
180 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
OLD | NEW |