Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/password_manager/password_store_x.cc

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again; base::File changes conflicted. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "chrome/browser/password_manager/password_store_change.h" 14 #include "chrome/browser/password_manager/password_store_change.h"
15 #include "chrome/browser/prefs/pref_registry_syncable.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 using std::vector; 23 using std::vector;
23 using content::PasswordForm; 24 using content::PasswordForm;
24 25
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 DeleteAndRecreateDatabaseFile(); 264 DeleteAndRecreateDatabaseFile();
264 } 265 }
265 } 266 }
266 ssize_t result = ok ? forms.size() : -1; 267 ssize_t result = ok ? forms.size() : -1;
267 STLDeleteElements(&forms); 268 STLDeleteElements(&forms);
268 return result; 269 return result;
269 } 270 }
270 271
271 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 272 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
272 // static 273 // static
273 void PasswordStoreX::RegisterUserPrefs(PrefServiceSyncable* prefs) { 274 void PasswordStoreX::RegisterUserPrefs(PrefRegistrySyncable* registry) {
274 // Normally we should be on the UI thread here, but in tests we might not. 275 // Normally we should be on the UI thread here, but in tests we might not.
275 prefs->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId, 276 registry->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId,
276 false, // default: passwords don't use local ids 277 // default: passwords don't use local ids
277 PrefServiceSyncable::UNSYNCABLE_PREF); 278 false,
279 PrefRegistrySyncable::UNSYNCABLE_PREF);
278 } 280 }
279 281
280 // static 282 // static
281 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) { 283 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) {
282 // Normally we should be on the UI thread here, but in tests we might not. 284 // Normally we should be on the UI thread here, but in tests we might not.
283 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId); 285 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId);
284 } 286 }
285 287
286 namespace { 288 namespace {
287 // This function is a hack to do something not entirely thread safe: the pref 289 // 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 290 // 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 291 // 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. 292 // 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 293 // 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... 294 // be called once ever per profile, it probably will not cause a problem...
293 void UISetPasswordsUseLocalProfileId(PrefService* prefs) { 295 void UISetPasswordsUseLocalProfileId(PrefService* prefs) {
294 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 296 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
295 } 297 }
296 } // anonymous namespace 298 } // anonymous namespace
297 299
298 // static 300 // static
299 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { 301 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) {
300 // This method should work on any thread, but we expect the DB thread. 302 // This method should work on any thread, but we expect the DB thread.
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 304 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
303 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); 305 base::Bind(&UISetPasswordsUseLocalProfileId, prefs));
304 } 306 }
305 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 307 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x.h ('k') | chrome/browser/pepper_flash_settings_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698