| 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/native_backend_kwallet_x.h" | 5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/pickle.h" | 15 #include "base/pickle.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 LogDeserializationWarning(version, signon_realm, false); | 216 LogDeserializationWarning(version, signon_realm, false); |
| 217 return false; | 217 return false; |
| 218 } | 218 } |
| 219 if (read_success) { | 219 if (read_success) { |
| 220 form->generation_upload_status = | 220 form->generation_upload_status = |
| 221 static_cast<PasswordForm::GenerationUploadStatus>( | 221 static_cast<PasswordForm::GenerationUploadStatus>( |
| 222 generation_upload_status); | 222 generation_upload_status); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 converted_forms.push_back(form.Pass()); | 226 converted_forms.push_back(std::move(form)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 forms->swap(converted_forms); | 229 forms->swap(converted_forms); |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Serializes a list of PasswordForms to be stored in the wallet. | 233 // Serializes a list of PasswordForms to be stored in the wallet. |
| 234 void SerializeValue(const std::vector<autofill::PasswordForm*>& forms, | 234 void SerializeValue(const std::vector<autofill::PasswordForm*>& forms, |
| 235 base::Pickle* pickle) { | 235 base::Pickle* pickle) { |
| 236 pickle->WriteInt(kPickleVersion); | 236 pickle->WriteInt(kPickleVersion); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 return ScopedVector<autofill::PasswordForm>(); | 935 return ScopedVector<autofill::PasswordForm>(); |
| 936 } | 936 } |
| 937 | 937 |
| 938 ScopedVector<autofill::PasswordForm> forms; | 938 ScopedVector<autofill::PasswordForm> forms; |
| 939 bool success = true; | 939 bool success = true; |
| 940 if (version > 0) { | 940 if (version > 0) { |
| 941 // In current pickles, we expect 64-bit sizes. Failure is an error. | 941 // In current pickles, we expect 64-bit sizes. Failure is an error. |
| 942 success = DeserializeValueSize( | 942 success = DeserializeValueSize( |
| 943 signon_realm, iter, version, false, false, &forms); | 943 signon_realm, iter, version, false, false, &forms); |
| 944 UMALogDeserializationStatus(success); | 944 UMALogDeserializationStatus(success); |
| 945 return forms.Pass(); | 945 return forms; |
| 946 } | 946 } |
| 947 | 947 |
| 948 const bool size_32 = sizeof(size_t) == sizeof(uint32_t); | 948 const bool size_32 = sizeof(size_t) == sizeof(uint32_t); |
| 949 if (!DeserializeValueSize( | 949 if (!DeserializeValueSize( |
| 950 signon_realm, iter, version, size_32, true, &forms)) { | 950 signon_realm, iter, version, size_32, true, &forms)) { |
| 951 // We failed to read the pickle using the native architecture of the system. | 951 // We failed to read the pickle using the native architecture of the system. |
| 952 // Try again with the opposite architecture. Note that we do this even on | 952 // Try again with the opposite architecture. Note that we do this even on |
| 953 // 32-bit machines, in case we're reading a 64-bit pickle. (Probably rare, | 953 // 32-bit machines, in case we're reading a 64-bit pickle. (Probably rare, |
| 954 // since mostly we expect upgrades, not downgrades, but both are possible.) | 954 // since mostly we expect upgrades, not downgrades, but both are possible.) |
| 955 success = DeserializeValueSize( | 955 success = DeserializeValueSize( |
| 956 signon_realm, iter, version, !size_32, false, &forms); | 956 signon_realm, iter, version, !size_32, false, &forms); |
| 957 } | 957 } |
| 958 UMALogDeserializationStatus(success); | 958 UMALogDeserializationStatus(success); |
| 959 return forms.Pass(); | 959 return forms; |
| 960 } | 960 } |
| 961 | 961 |
| 962 int NativeBackendKWallet::WalletHandle() { | 962 int NativeBackendKWallet::WalletHandle() { |
| 963 DCHECK_CURRENTLY_ON(BrowserThread::DB); | 963 DCHECK_CURRENTLY_ON(BrowserThread::DB); |
| 964 | 964 |
| 965 // Open the wallet. | 965 // Open the wallet. |
| 966 // TODO(mdm): Are we leaking these handles? Find out. | 966 // TODO(mdm): Are we leaking these handles? Find out. |
| 967 int32_t handle = kInvalidKWalletHandle; | 967 int32_t handle = kInvalidKWalletHandle; |
| 968 { | 968 { |
| 969 dbus::MethodCall method_call(kKWalletInterface, "open"); | 969 dbus::MethodCall method_call(kKWalletInterface, "open"); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 return handle; | 1044 return handle; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { | 1047 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { |
| 1048 // Originally, the folder name was always just "Chrome Form Data". | 1048 // Originally, the folder name was always just "Chrome Form Data". |
| 1049 // Now we use it to distinguish passwords for different profiles. | 1049 // Now we use it to distinguish passwords for different profiles. |
| 1050 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); | 1050 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); |
| 1051 } | 1051 } |
| OLD | NEW |