Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: chrome/browser/password_manager/native_backend_libsecret.cc

Issue 1858513002: chrome/browser/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows -- revert unwanted change Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10
11 #include <limits> 11 #include <limits>
12 #include <list> 12 #include <list>
13 #include <memory>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 22 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
23 #include "components/password_manager/core/browser/password_manager_util.h" 23 #include "components/password_manager/core/browser/password_manager_util.h"
24 #include "url/origin.h" 24 #include "url/origin.h"
25 25
26 using autofill::PasswordForm; 26 using autofill::PasswordForm;
27 using base::UTF8ToUTF16; 27 using base::UTF8ToUTF16;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return uint32_t(); 140 return uint32_t();
141 uint32_t result; 141 uint32_t result;
142 bool value_ok = base::StringToUint(static_cast<char*>(value), &result); 142 bool value_ok = base::StringToUint(static_cast<char*>(value), &result);
143 DCHECK(value_ok); 143 DCHECK(value_ok);
144 return result; 144 return result;
145 } 145 }
146 146
147 // Convert the attributes into a new PasswordForm. 147 // Convert the attributes into a new PasswordForm.
148 // Note: does *not* get the actual password, as that is not a key attribute! 148 // Note: does *not* get the actual password, as that is not a key attribute!
149 // Returns nullptr if the attributes are for the wrong application. 149 // Returns nullptr if the attributes are for the wrong application.
150 scoped_ptr<PasswordForm> FormOutOfAttributes(GHashTable* attrs) { 150 std::unique_ptr<PasswordForm> FormOutOfAttributes(GHashTable* attrs) {
151 base::StringPiece app_value = GetStringFromAttributes(attrs, "application"); 151 base::StringPiece app_value = GetStringFromAttributes(attrs, "application");
152 if (!app_value.starts_with(kLibsecretAppString)) 152 if (!app_value.starts_with(kLibsecretAppString))
153 return scoped_ptr<PasswordForm>(); 153 return std::unique_ptr<PasswordForm>();
154 154
155 scoped_ptr<PasswordForm> form(new PasswordForm()); 155 std::unique_ptr<PasswordForm> form(new PasswordForm());
156 form->origin = GURL(GetStringFromAttributes(attrs, "origin_url")); 156 form->origin = GURL(GetStringFromAttributes(attrs, "origin_url"));
157 form->action = GURL(GetStringFromAttributes(attrs, "action_url")); 157 form->action = GURL(GetStringFromAttributes(attrs, "action_url"));
158 form->username_element = 158 form->username_element =
159 UTF8ToUTF16(GetStringFromAttributes(attrs, "username_element")); 159 UTF8ToUTF16(GetStringFromAttributes(attrs, "username_element"));
160 form->username_value = 160 form->username_value =
161 UTF8ToUTF16(GetStringFromAttributes(attrs, "username_value")); 161 UTF8ToUTF16(GetStringFromAttributes(attrs, "username_value"));
162 form->password_element = 162 form->password_element =
163 UTF8ToUTF16(GetStringFromAttributes(attrs, "password_element")); 163 UTF8ToUTF16(GetStringFromAttributes(attrs, "password_element"));
164 form->submit_element = 164 form->submit_element =
165 UTF8ToUTF16(GetStringFromAttributes(attrs, "submit_element")); 165 UTF8ToUTF16(GetStringFromAttributes(attrs, "submit_element"));
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 element = g_list_next(element)) { 640 element = g_list_next(element)) {
641 SecretItem* secretItem = static_cast<SecretItem*>(element->data); 641 SecretItem* secretItem = static_cast<SecretItem*>(element->data);
642 LibsecretLoader::secret_item_load_secret_sync(secretItem, nullptr, &error); 642 LibsecretLoader::secret_item_load_secret_sync(secretItem, nullptr, &error);
643 if (error) { 643 if (error) {
644 LOG(ERROR) << "Unable to load secret item" << error->message; 644 LOG(ERROR) << "Unable to load secret item" << error->message;
645 g_error_free(error); 645 g_error_free(error);
646 error = nullptr; 646 error = nullptr;
647 continue; 647 continue;
648 } 648 }
649 GHashTable* attrs = secret_item_get_attributes(secretItem); 649 GHashTable* attrs = secret_item_get_attributes(secretItem);
650 scoped_ptr<PasswordForm> form(FormOutOfAttributes(attrs)); 650 std::unique_ptr<PasswordForm> form(FormOutOfAttributes(attrs));
651 g_hash_table_unref(attrs); 651 g_hash_table_unref(attrs);
652 if (form) { 652 if (form) {
653 if (lookup_form && form->signon_realm != lookup_form->signon_realm) { 653 if (lookup_form && form->signon_realm != lookup_form->signon_realm) {
654 if (lookup_form->scheme != PasswordForm::SCHEME_HTML || 654 if (lookup_form->scheme != PasswordForm::SCHEME_HTML ||
655 form->scheme != PasswordForm::SCHEME_HTML) 655 form->scheme != PasswordForm::SCHEME_HTML)
656 continue; 656 continue;
657 // This is not an exact match, we try PSL matching and federated match. 657 // This is not an exact match, we try PSL matching and federated match.
658 if (allow_psl_match && 658 if (allow_psl_match &&
659 password_manager::IsPublicSuffixDomainMatch( 659 password_manager::IsPublicSuffixDomainMatch(
660 form->signon_realm, lookup_form->signon_realm)) { 660 form->signon_realm, lookup_form->signon_realm)) {
(...skipping 22 matching lines...) Expand all
683 if (lookup_form) { 683 if (lookup_form) {
684 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 684 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
685 allow_psl_match 685 allow_psl_match
686 ? psl_domain_match_metric 686 ? psl_domain_match_metric
687 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, 687 : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
688 password_manager::PSL_DOMAIN_MATCH_COUNT); 688 password_manager::PSL_DOMAIN_MATCH_COUNT);
689 } 689 }
690 g_list_free(found); 690 g_list_free(found);
691 return forms; 691 return forms;
692 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698