OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native_backend_kwallet_x.h" | 5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/stringprintf.h" |
13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
14 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 | 16 |
17 using std::string; | 17 using std::string; |
18 using std::vector; | 18 using std::vector; |
19 using webkit_glue::PasswordForm; | 19 using webkit_glue::PasswordForm; |
20 | 20 |
21 // We could localize this string, but then changing your locale would cause | 21 // We could localize this string, but then changing your locale would cause |
22 // you to lose access to all your stored passwords. Maybe best not to do that. | 22 // you to lose access to all your stored passwords. Maybe best not to do that. |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // Successful initialization. Try migration if necessary. | 643 // Successful initialization. Try migration if necessary. |
644 if (!migrate_tried_) | 644 if (!migrate_tried_) |
645 MigrateToProfileSpecificLogins(); | 645 MigrateToProfileSpecificLogins(); |
646 | 646 |
647 return handle; | 647 return handle; |
648 } | 648 } |
649 | 649 |
650 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { | 650 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { |
651 // Originally, the folder name was always just "Chrome Form Data". | 651 // Originally, the folder name was always just "Chrome Form Data". |
652 // Now we use it to distinguish passwords for different profiles. | 652 // Now we use it to distinguish passwords for different profiles. |
653 return StringPrintf("%s (%d)", kKWalletFolder, profile_id_); | 653 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); |
654 } | 654 } |
655 | 655 |
656 void NativeBackendKWallet::MigrateToProfileSpecificLogins() { | 656 void NativeBackendKWallet::MigrateToProfileSpecificLogins() { |
657 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 657 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
658 | 658 |
659 DCHECK(!migrate_tried_); | 659 DCHECK(!migrate_tried_); |
660 DCHECK_EQ(folder_name_, kKWalletFolder); | 660 DCHECK_EQ(folder_name_, kKWalletFolder); |
661 | 661 |
662 // Record the fact that we've attempted migration already right away, so that | 662 // Record the fact that we've attempted migration already right away, so that |
663 // we don't get recursive calls back to MigrateToProfileSpecificLogins(). | 663 // we don't get recursive calls back to MigrateToProfileSpecificLogins(). |
(...skipping 29 matching lines...) Expand all Loading... |
693 // Each other profile must be able to migrate the shared data as well, | 693 // Each other profile must be able to migrate the shared data as well, |
694 // so we must leave it alone. After a few releases, we'll add code to | 694 // so we must leave it alone. After a few releases, we'll add code to |
695 // delete them, and eventually remove this migration code. | 695 // delete them, and eventually remove this migration code. |
696 // TODO(mdm): follow through with the plan above. | 696 // TODO(mdm): follow through with the plan above. |
697 PasswordStoreX::SetPasswordsUseLocalProfileId(prefs_); | 697 PasswordStoreX::SetPasswordsUseLocalProfileId(prefs_); |
698 } else { | 698 } else { |
699 // We failed to migrate for some reason. Use the old folder name. | 699 // We failed to migrate for some reason. Use the old folder name. |
700 folder_name_ = kKWalletFolder; | 700 folder_name_ = kKWalletFolder; |
701 } | 701 } |
702 } | 702 } |
OLD | NEW |