OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_libsecret.h" | 5 #include "chrome/browser/password_manager/native_backend_libsecret.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <list> | 10 #include <list> |
| 11 #include <utility> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 19 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
19 #include "components/password_manager/core/browser/password_manager_util.h" | 20 #include "components/password_manager/core/browser/password_manager_util.h" |
20 | 21 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 base::StringPiece encoded_form_data = | 197 base::StringPiece encoded_form_data = |
197 GetStringFromAttributes(attrs, "form_data"); | 198 GetStringFromAttributes(attrs, "form_data"); |
198 if (!encoded_form_data.empty()) { | 199 if (!encoded_form_data.empty()) { |
199 bool success = DeserializeFormDataFromBase64String(encoded_form_data, | 200 bool success = DeserializeFormDataFromBase64String(encoded_form_data, |
200 &form->form_data); | 201 &form->form_data); |
201 password_manager::metrics_util::FormDeserializationStatus status = | 202 password_manager::metrics_util::FormDeserializationStatus status = |
202 success ? password_manager::metrics_util::GNOME_SUCCESS | 203 success ? password_manager::metrics_util::GNOME_SUCCESS |
203 : password_manager::metrics_util::GNOME_FAILURE; | 204 : password_manager::metrics_util::GNOME_FAILURE; |
204 LogFormDataDeserializationStatus(status); | 205 LogFormDataDeserializationStatus(status); |
205 } | 206 } |
206 return form.Pass(); | 207 return form; |
207 } | 208 } |
208 | 209 |
209 class LibsecretAttributesBuilder { | 210 class LibsecretAttributesBuilder { |
210 public: | 211 public: |
211 LibsecretAttributesBuilder(); | 212 LibsecretAttributesBuilder(); |
212 ~LibsecretAttributesBuilder(); | 213 ~LibsecretAttributesBuilder(); |
213 void Append(const std::string& name, const std::string& value); | 214 void Append(const std::string& name, const std::string& value); |
214 void Append(const std::string& name, int64_t value); | 215 void Append(const std::string& name, int64_t value); |
215 // GHashTable, its keys and values returned from Get() are destroyed in | 216 // GHashTable, its keys and values returned from Get() are destroyed in |
216 // |LibsecretAttributesBuilder| desctructor. | 217 // |LibsecretAttributesBuilder| desctructor. |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; | 619 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; |
619 form->is_public_suffix_match = true; | 620 form->is_public_suffix_match = true; |
620 } | 621 } |
621 SecretValue* secretValue = secret_item_get_secret(secretItem); | 622 SecretValue* secretValue = secret_item_get_secret(secretItem); |
622 if (secretValue) { | 623 if (secretValue) { |
623 form->password_value = UTF8ToUTF16(secret_value_get_text(secretValue)); | 624 form->password_value = UTF8ToUTF16(secret_value_get_text(secretValue)); |
624 secret_value_unref(secretValue); | 625 secret_value_unref(secretValue); |
625 } else { | 626 } else { |
626 LOG(WARNING) << "Unable to access password from list element!"; | 627 LOG(WARNING) << "Unable to access password from list element!"; |
627 } | 628 } |
628 forms.push_back(form.Pass()); | 629 forms.push_back(std::move(form)); |
629 } else { | 630 } else { |
630 VLOG(1) << "Could not initialize PasswordForm from attributes!"; | 631 VLOG(1) << "Could not initialize PasswordForm from attributes!"; |
631 } | 632 } |
632 } | 633 } |
633 | 634 |
634 if (lookup_form) { | 635 if (lookup_form) { |
635 const GURL signon_realm(lookup_form->signon_realm); | 636 const GURL signon_realm(lookup_form->signon_realm); |
636 std::string registered_domain = | 637 std::string registered_domain = |
637 password_manager::GetRegistryControlledDomain(signon_realm); | 638 password_manager::GetRegistryControlledDomain(signon_realm); |
638 UMA_HISTOGRAM_ENUMERATION( | 639 UMA_HISTOGRAM_ENUMERATION( |
639 "PasswordManager.PslDomainMatchTriggering", | 640 "PasswordManager.PslDomainMatchTriggering", |
640 password_manager::ShouldPSLDomainMatchingApply(registered_domain) | 641 password_manager::ShouldPSLDomainMatchingApply(registered_domain) |
641 ? psl_domain_match_metric | 642 ? psl_domain_match_metric |
642 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, | 643 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, |
643 password_manager::PSL_DOMAIN_MATCH_COUNT); | 644 password_manager::PSL_DOMAIN_MATCH_COUNT); |
644 } | 645 } |
645 g_list_free(found); | 646 g_list_free(found); |
646 return forms.Pass(); | 647 return forms; |
647 } | 648 } |
OLD | NEW |