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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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) 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_gnome_x.h" 5 #include "chrome/browser/password_manager/native_backend_gnome_x.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gnome-keyring.h> 8 #include <gnome-keyring.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11
12 #include <map> 11 #include <map>
13 #include <string> 12 #include <string>
13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.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/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 form->skip_zero_click = uint_attr_map["skip_zero_click"]; 161 form->skip_zero_click = uint_attr_map["skip_zero_click"];
162 form->generation_upload_status = 162 form->generation_upload_status =
163 static_cast<PasswordForm::GenerationUploadStatus>( 163 static_cast<PasswordForm::GenerationUploadStatus>(
164 uint_attr_map["generation_upload_status"]); 164 uint_attr_map["generation_upload_status"]);
165 if (!string_attr_map["form_data"].empty()) { 165 if (!string_attr_map["form_data"].empty()) {
166 bool success = DeserializeFormDataFromBase64String( 166 bool success = DeserializeFormDataFromBase64String(
167 string_attr_map["form_data"], &form->form_data); 167 string_attr_map["form_data"], &form->form_data);
168 FormDeserializationStatus status = success ? GNOME_SUCCESS : GNOME_FAILURE; 168 FormDeserializationStatus status = success ? GNOME_SUCCESS : GNOME_FAILURE;
169 LogFormDataDeserializationStatus(status); 169 LogFormDataDeserializationStatus(status);
170 } 170 }
171 return form.Pass(); 171 return form;
172 } 172 }
173 173
174 // Converts native credentials in |found| to PasswordForms. If not NULL, 174 // Converts native credentials in |found| to PasswordForms. If not NULL,
175 // |lookup_form| is used to filter out results -- only credentials with signon 175 // |lookup_form| is used to filter out results -- only credentials with signon
176 // realms passing the PSL matching against |lookup_form->signon_realm| will be 176 // realms passing the PSL matching against |lookup_form->signon_realm| will be
177 // kept. PSL matched results get their signon_realm, origin, and action 177 // kept. PSL matched results get their signon_realm, origin, and action
178 // rewritten to those of |lookup_form_|, with the original signon_realm saved 178 // rewritten to those of |lookup_form_|, with the original signon_realm saved
179 // into the result's original_signon_realm data member. 179 // into the result's original_signon_realm data member.
180 ScopedVector<PasswordForm> ConvertFormList(GList* found, 180 ScopedVector<PasswordForm> ConvertFormList(GList* found,
181 const PasswordForm* lookup_form) { 181 const PasswordForm* lookup_form) {
(...skipping 16 matching lines...) Expand all
198 continue; 198 continue;
199 } 199 }
200 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND; 200 psl_domain_match_metric = password_manager::PSL_DOMAIN_MATCH_FOUND;
201 form->is_public_suffix_match = true; 201 form->is_public_suffix_match = true;
202 } 202 }
203 if (data->secret) { 203 if (data->secret) {
204 form->password_value = UTF8ToUTF16(data->secret); 204 form->password_value = UTF8ToUTF16(data->secret);
205 } else { 205 } else {
206 LOG(WARNING) << "Unable to access password from list element!"; 206 LOG(WARNING) << "Unable to access password from list element!";
207 } 207 }
208 forms.push_back(form.Pass()); 208 forms.push_back(std::move(form));
209 } else { 209 } else {
210 LOG(WARNING) << "Could not initialize PasswordForm from attributes!"; 210 LOG(WARNING) << "Could not initialize PasswordForm from attributes!";
211 } 211 }
212 } 212 }
213 if (lookup_form) { 213 if (lookup_form) {
214 const GURL signon_realm(lookup_form->signon_realm); 214 const GURL signon_realm(lookup_form->signon_realm);
215 std::string registered_domain = 215 std::string registered_domain =
216 password_manager::GetRegistryControlledDomain(signon_realm); 216 password_manager::GetRegistryControlledDomain(signon_realm);
217 UMA_HISTOGRAM_ENUMERATION( 217 UMA_HISTOGRAM_ENUMERATION(
218 "PasswordManager.PslDomainMatchTriggering", 218 "PasswordManager.PslDomainMatchTriggering",
219 password_manager::ShouldPSLDomainMatchingApply(registered_domain) 219 password_manager::ShouldPSLDomainMatchingApply(registered_domain)
220 ? psl_domain_match_metric 220 ? psl_domain_match_metric
221 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, 221 : password_manager::PSL_DOMAIN_MATCH_NOT_USED,
222 password_manager::PSL_DOMAIN_MATCH_COUNT); 222 password_manager::PSL_DOMAIN_MATCH_COUNT);
223 } 223 }
224 return forms.Pass(); 224 return forms;
225 } 225 }
226 226
227 // Schema is analagous to the fields in PasswordForm. 227 // Schema is analagous to the fields in PasswordForm.
228 const GnomeKeyringPasswordSchema kGnomeSchema = { 228 const GnomeKeyringPasswordSchema kGnomeSchema = {
229 GNOME_KEYRING_ITEM_GENERIC_SECRET, { 229 GNOME_KEYRING_ITEM_GENERIC_SECRET, {
230 { "origin_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 230 { "origin_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
231 { "action_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 231 { "action_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
232 { "username_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 232 { "username_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
233 { "username_value", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 233 { "username_value", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
234 { "password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 234 { "password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 GnomeKeyringResult GKRMethod::WaitResult() { 463 GnomeKeyringResult GKRMethod::WaitResult() {
464 DCHECK_CURRENTLY_ON(BrowserThread::DB); 464 DCHECK_CURRENTLY_ON(BrowserThread::DB);
465 event_.Wait(); 465 event_.Wait();
466 return result_; 466 return result_;
467 } 467 }
468 468
469 GnomeKeyringResult GKRMethod::WaitResult(ScopedVector<PasswordForm>* forms) { 469 GnomeKeyringResult GKRMethod::WaitResult(ScopedVector<PasswordForm>* forms) {
470 DCHECK_CURRENTLY_ON(BrowserThread::DB); 470 DCHECK_CURRENTLY_ON(BrowserThread::DB);
471 event_.Wait(); 471 event_.Wait();
472 *forms = forms_.Pass(); 472 *forms = std::move(forms_);
473 return result_; 473 return result_;
474 } 474 }
475 475
476 // static 476 // static
477 void GKRMethod::AppendString(GKRMethod::ScopedAttributeList* list, 477 void GKRMethod::AppendString(GKRMethod::ScopedAttributeList* list,
478 const char* name, 478 const char* name,
479 const char* value) { 479 const char* value) {
480 gnome_keyring_attribute_list_append_string(list->get(), name, value); 480 gnome_keyring_attribute_list_append_string(list->get(), name, value);
481 } 481 }
482 482
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 ScopedVector<PasswordForm> forms; 802 ScopedVector<PasswordForm> forms;
803 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) 803 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms))
804 return false; 804 return false;
805 805
806 for (size_t i = 0; i < forms.size(); ++i) { 806 for (size_t i = 0; i < forms.size(); ++i) {
807 if (!RemoveLogin(*forms[i], changes)) 807 if (!RemoveLogin(*forms[i], changes))
808 return false; 808 return false;
809 } 809 }
810 return true; 810 return true;
811 } 811 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698