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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/password_manager/password_store_change.h" | 16 #include "chrome/browser/password_manager/password_store_change.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "components/user_prefs/pref_registry_syncable.h" | 18 #include "components/user_prefs/pref_registry_syncable.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 | 21 |
22 using autofill::PasswordForm; | 22 using autofill::PasswordForm; |
23 using content::BrowserThread; | 23 using content::BrowserThread; |
24 using std::vector; | 24 using std::vector; |
25 | 25 |
26 PasswordStoreX::PasswordStoreX(LoginDatabase* login_db, | 26 PasswordStoreX::PasswordStoreX( |
27 Profile* profile, | 27 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
28 NativeBackend* backend) | 28 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, |
29 : PasswordStoreDefault(login_db, profile), | 29 LoginDatabase* login_db, |
30 backend_(backend), migration_checked_(!backend), allow_fallback_(false) { | 30 Profile* profile, |
| 31 NativeBackend* backend) |
| 32 : PasswordStoreDefault( |
| 33 main_thread_runner, db_thread_runner, login_db, profile), |
| 34 backend_(backend), |
| 35 migration_checked_(!backend), |
| 36 allow_fallback_(false) { |
31 } | 37 } |
32 | 38 |
33 PasswordStoreX::~PasswordStoreX() {} | 39 PasswordStoreX::~PasswordStoreX() {} |
34 | 40 |
35 void PasswordStoreX::AddLoginImpl(const PasswordForm& form) { | 41 void PasswordStoreX::AddLoginImpl(const PasswordForm& form) { |
36 CheckMigration(); | 42 CheckMigration(); |
37 if (use_native_backend() && backend_->AddLogin(form)) { | 43 if (use_native_backend() && backend_->AddLogin(form)) { |
38 PasswordStoreChangeList changes; | 44 PasswordStoreChangeList changes; |
39 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | 45 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
40 content::NotificationService::current()->Notify( | 46 content::NotificationService::current()->Notify( |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } // anonymous namespace | 305 } // anonymous namespace |
300 | 306 |
301 // static | 307 // static |
302 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { | 308 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { |
303 // This method should work on any thread, but we expect the DB thread. | 309 // This method should work on any thread, but we expect the DB thread. |
304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
305 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 311 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
306 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); | 312 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); |
307 } | 313 } |
308 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 314 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
OLD | NEW |