| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } else { | 97 } else { |
| 98 LOG(ERROR) << "Failed to deserialize version " << version | 98 LOG(ERROR) << "Failed to deserialize version " << version |
| 99 << " KWallet entry (realm: " << signon_realm << ")"; | 99 << " KWallet entry (realm: " << signon_realm << ")"; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace | 103 } // namespace |
| 104 | 104 |
| 105 NativeBackendKWallet::NativeBackendKWallet(LocalProfileId id) | 105 NativeBackendKWallet::NativeBackendKWallet(LocalProfileId id) |
| 106 : profile_id_(id), | 106 : profile_id_(id), |
| 107 kwallet_proxy_(NULL), | 107 kwallet_proxy_(nullptr), |
| 108 app_name_(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)) { | 108 app_name_(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)) { |
| 109 folder_name_ = GetProfileSpecificFolderName(); | 109 folder_name_ = GetProfileSpecificFolderName(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 NativeBackendKWallet::~NativeBackendKWallet() { | 112 NativeBackendKWallet::~NativeBackendKWallet() { |
| 113 // This destructor is called on the thread that is destroying the Profile | 113 // This destructor is called on the thread that is destroying the Profile |
| 114 // containing the PasswordStore that owns this NativeBackend. Generally that | 114 // containing the PasswordStore that owns this NativeBackend. Generally that |
| 115 // won't be the DB thread; it will be the UI thread. So we post a message to | 115 // won't be the DB thread; it will be the UI thread. So we post a message to |
| 116 // shut it down on the DB thread, and it will be destructed afterward when the | 116 // shut it down on the DB thread, and it will be destructed afterward when the |
| 117 // scoped_refptr<dbus::Bus> goes out of scope. The NativeBackend will be | 117 // scoped_refptr<dbus::Bus> goes out of scope. The NativeBackend will be |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 builder.AppendString(signon_realm); // key | 433 builder.AppendString(signon_realm); // key |
| 434 builder.AppendString(app_name_); // appid | 434 builder.AppendString(app_name_); // appid |
| 435 scoped_ptr<dbus::Response> response( | 435 scoped_ptr<dbus::Response> response( |
| 436 kwallet_proxy_->CallMethodAndBlock( | 436 kwallet_proxy_->CallMethodAndBlock( |
| 437 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 437 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
| 438 if (!response.get()) { | 438 if (!response.get()) { |
| 439 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; | 439 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; |
| 440 return false; | 440 return false; |
| 441 } | 441 } |
| 442 dbus::MessageReader reader(response.get()); | 442 dbus::MessageReader reader(response.get()); |
| 443 const uint8_t* bytes = NULL; | 443 const uint8_t* bytes = nullptr; |
| 444 size_t length = 0; | 444 size_t length = 0; |
| 445 if (!reader.PopArrayOfBytes(&bytes, &length)) { | 445 if (!reader.PopArrayOfBytes(&bytes, &length)) { |
| 446 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " | 446 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " |
| 447 << response->ToString(); | 447 << response->ToString(); |
| 448 return false; | 448 return false; |
| 449 } | 449 } |
| 450 if (!bytes) | 450 if (!bytes) |
| 451 return false; | 451 return false; |
| 452 if (!CheckSerializedValue(bytes, length, signon_realm)) { | 452 if (!CheckSerializedValue(bytes, length, signon_realm)) { |
| 453 // This is weird, but we choose not to call it an error. There is an | 453 // This is weird, but we choose not to call it an error. There is an |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 builder.AppendString(signon_realm); // key | 520 builder.AppendString(signon_realm); // key |
| 521 builder.AppendString(app_name_); // appid | 521 builder.AppendString(app_name_); // appid |
| 522 scoped_ptr<dbus::Response> response( | 522 scoped_ptr<dbus::Response> response( |
| 523 kwallet_proxy_->CallMethodAndBlock( | 523 kwallet_proxy_->CallMethodAndBlock( |
| 524 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 524 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
| 525 if (!response.get()) { | 525 if (!response.get()) { |
| 526 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; | 526 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; |
| 527 return false; | 527 return false; |
| 528 } | 528 } |
| 529 dbus::MessageReader reader(response.get()); | 529 dbus::MessageReader reader(response.get()); |
| 530 const uint8_t* bytes = NULL; | 530 const uint8_t* bytes = nullptr; |
| 531 size_t length = 0; | 531 size_t length = 0; |
| 532 if (!reader.PopArrayOfBytes(&bytes, &length)) { | 532 if (!reader.PopArrayOfBytes(&bytes, &length)) { |
| 533 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " | 533 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " |
| 534 << response->ToString(); | 534 << response->ToString(); |
| 535 return false; | 535 return false; |
| 536 } | 536 } |
| 537 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) | 537 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) |
| 538 continue; | 538 continue; |
| 539 | 539 |
| 540 // Can't we all just agree on whether bytes are signed or not? Please? | 540 // Can't we all just agree on whether bytes are signed or not? Please? |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 builder.AppendString(folder_name_); // folder | 657 builder.AppendString(folder_name_); // folder |
| 658 builder.AppendString(signon_realm); // key | 658 builder.AppendString(signon_realm); // key |
| 659 builder.AppendString(app_name_); // appid | 659 builder.AppendString(app_name_); // appid |
| 660 scoped_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock( | 660 scoped_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock( |
| 661 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 661 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
| 662 if (!response.get()) { | 662 if (!response.get()) { |
| 663 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; | 663 LOG(ERROR) << "Error contacting kwalletd (readEntry)"; |
| 664 continue; | 664 continue; |
| 665 } | 665 } |
| 666 dbus::MessageReader reader(response.get()); | 666 dbus::MessageReader reader(response.get()); |
| 667 const uint8_t* bytes = NULL; | 667 const uint8_t* bytes = nullptr; |
| 668 size_t length = 0; | 668 size_t length = 0; |
| 669 if (!reader.PopArrayOfBytes(&bytes, &length)) { | 669 if (!reader.PopArrayOfBytes(&bytes, &length)) { |
| 670 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " | 670 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " |
| 671 << response->ToString(); | 671 << response->ToString(); |
| 672 continue; | 672 continue; |
| 673 } | 673 } |
| 674 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) | 674 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) |
| 675 continue; | 675 continue; |
| 676 | 676 |
| 677 // Can't we all just agree on whether bytes are signed or not? Please? | 677 // Can't we all just agree on whether bytes are signed or not? Please? |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 } | 970 } |
| 971 | 971 |
| 972 return handle; | 972 return handle; |
| 973 } | 973 } |
| 974 | 974 |
| 975 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { | 975 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { |
| 976 // Originally, the folder name was always just "Chrome Form Data". | 976 // Originally, the folder name was always just "Chrome Form Data". |
| 977 // Now we use it to distinguish passwords for different profiles. | 977 // Now we use it to distinguish passwords for different profiles. |
| 978 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); | 978 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); |
| 979 } | 979 } |
| OLD | NEW |