| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/password_manager/password_store_x.h" | 5 #include "chrome/browser/password_manager/password_store_x.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 DeleteAndRecreateDatabaseFile(); | 263 DeleteAndRecreateDatabaseFile(); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 ssize_t result = ok ? forms.size() : -1; | 266 ssize_t result = ok ? forms.size() : -1; |
| 267 STLDeleteElements(&forms); | 267 STLDeleteElements(&forms); |
| 268 return result; | 268 return result; |
| 269 } | 269 } |
| 270 | 270 |
| 271 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 271 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
| 272 // static | 272 // static |
| 273 void PasswordStoreX::RegisterUserPrefs(PrefService* prefs) { | 273 void PasswordStoreX::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
| 274 // Normally we should be on the UI thread here, but in tests we might not. | 274 // Normally we should be on the UI thread here, but in tests we might not. |
| 275 prefs->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId, | 275 prefs->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId, |
| 276 false, // default: passwords don't use local ids | 276 false, // default: passwords don't use local ids |
| 277 PrefService::UNSYNCABLE_PREF); | 277 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // static | 280 // static |
| 281 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) { | 281 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) { |
| 282 // Normally we should be on the UI thread here, but in tests we might not. | 282 // Normally we should be on the UI thread here, but in tests we might not. |
| 283 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId); | 283 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId); |
| 284 } | 284 } |
| 285 | 285 |
| 286 namespace { | 286 namespace { |
| 287 // This function is a hack to do something not entirely thread safe: the pref | 287 // This function is a hack to do something not entirely thread safe: the pref |
| 288 // service comes from the UI thread, but it's not ref counted. We keep a pointer | 288 // service comes from the UI thread, but it's not ref counted. We keep a pointer |
| 289 // to it on the DB thread, and need to invoke a method on the UI thread. This | 289 // to it on the DB thread, and need to invoke a method on the UI thread. This |
| 290 // function does that for us without requiring ref counting the pref service. | 290 // function does that for us without requiring ref counting the pref service. |
| 291 // TODO(mdm): Fix this if it becomes a problem. Given that this function will | 291 // TODO(mdm): Fix this if it becomes a problem. Given that this function will |
| 292 // be called once ever per profile, it probably will not cause a problem... | 292 // be called once ever per profile, it probably will not cause a problem... |
| 293 void UISetPasswordsUseLocalProfileId(PrefService* prefs) { | 293 void UISetPasswordsUseLocalProfileId(PrefService* prefs) { |
| 294 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); | 294 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); |
| 295 } | 295 } |
| 296 } // anonymous namespace | 296 } // anonymous namespace |
| 297 | 297 |
| 298 // static | 298 // static |
| 299 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { | 299 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { |
| 300 // This method should work on any thread, but we expect the DB thread. | 300 // This method should work on any thread, but we expect the DB thread. |
| 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 303 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); | 303 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); |
| 304 } | 304 } |
| 305 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 305 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
| OLD | NEW |