| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/os_crypt/os_crypt.h" | 5 #include "components/os_crypt/os_crypt.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // static | 243 // static |
| 244 void OSCrypt::SetMainThreadRunner( | 244 void OSCrypt::SetMainThreadRunner( |
| 245 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner) { | 245 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner) { |
| 246 // Setting the task runner makes no sense after initializing. | 246 // Setting the task runner makes no sense after initializing. |
| 247 DCHECK(!g_cache.Get().is_key_storage_cached); | 247 DCHECK(!g_cache.Get().is_key_storage_cached); |
| 248 | 248 |
| 249 KeyStorageLinux::SetMainThreadRunner(main_thread_runner); | 249 KeyStorageLinux::SetMainThreadRunner(main_thread_runner); |
| 250 } | 250 } |
| 251 | 251 |
| 252 // static | 252 // static |
| 253 void OSCrypt::ShouldUsePreference(bool should_use_preference) { |
| 254 // Setting initialisation parameters makes no sense after initializing. |
| 255 DCHECK(!g_cache.Get().is_key_storage_cached); |
| 256 |
| 257 KeyStorageLinux::ShouldUsePreference(should_use_preference); |
| 258 } |
| 259 |
| 260 // static |
| 261 void OSCrypt::SetUserDataPath(const base::FilePath& path) { |
| 262 // Setting initialisation parameters makes no sense after initializing. |
| 263 DCHECK(!g_cache.Get().is_key_storage_cached); |
| 264 |
| 265 KeyStorageLinux::SetUserDataPath(path); |
| 266 } |
| 267 |
| 268 // static |
| 253 bool OSCrypt::IsEncryptionAvailable() { | 269 bool OSCrypt::IsEncryptionAvailable() { |
| 254 return g_get_password[Version::V11](); | 270 return g_get_password[Version::V11](); |
| 255 } | 271 } |
| 256 | 272 |
| 257 void ClearCacheForTesting() { | 273 void ClearCacheForTesting() { |
| 258 g_cache.Get().key_storage_cache.reset(); | 274 g_cache.Get().key_storage_cache.reset(); |
| 259 g_cache.Get().password_v10_cache.reset(); | 275 g_cache.Get().password_v10_cache.reset(); |
| 260 g_cache.Get().password_v11_cache.reset(); | 276 g_cache.Get().password_v11_cache.reset(); |
| 261 g_cache.Get().is_key_storage_cached = false; | 277 g_cache.Get().is_key_storage_cached = false; |
| 262 g_cache.Get().is_password_v11_cached = false; | 278 g_cache.Get().is_password_v11_cached = false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 281 // |KeyStorage| instance can be created. Enable V11 by returning the mock. | 297 // |KeyStorage| instance can be created. Enable V11 by returning the mock. |
| 282 if (get_key_storage_mock) | 298 if (get_key_storage_mock) |
| 283 g_key_storage_provider = get_key_storage_mock; | 299 g_key_storage_provider = get_key_storage_mock; |
| 284 } else { | 300 } else { |
| 285 // Restore real implementation | 301 // Restore real implementation |
| 286 std::copy(std::begin(get_password_save), std::end(get_password_save), | 302 std::copy(std::begin(get_password_save), std::end(get_password_save), |
| 287 std::begin(g_get_password)); | 303 std::begin(g_get_password)); |
| 288 g_key_storage_provider = &GetKeyStorage; | 304 g_key_storage_provider = &GetKeyStorage; |
| 289 } | 305 } |
| 290 } | 306 } |
| OLD | NEW |