| 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_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> |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return std::unique_ptr<PasswordForm>(); | 128 return std::unique_ptr<PasswordForm>(); |
| 129 | 129 |
| 130 std::unique_ptr<PasswordForm> form(new PasswordForm()); | 130 std::unique_ptr<PasswordForm> form(new PasswordForm()); |
| 131 form->origin = GURL(string_attr_map["origin_url"]); | 131 form->origin = GURL(string_attr_map["origin_url"]); |
| 132 form->action = GURL(string_attr_map["action_url"]); | 132 form->action = GURL(string_attr_map["action_url"]); |
| 133 form->username_element = UTF8ToUTF16(string_attr_map["username_element"]); | 133 form->username_element = UTF8ToUTF16(string_attr_map["username_element"]); |
| 134 form->username_value = UTF8ToUTF16(string_attr_map["username_value"]); | 134 form->username_value = UTF8ToUTF16(string_attr_map["username_value"]); |
| 135 form->password_element = UTF8ToUTF16(string_attr_map["password_element"]); | 135 form->password_element = UTF8ToUTF16(string_attr_map["password_element"]); |
| 136 form->submit_element = UTF8ToUTF16(string_attr_map["submit_element"]); | 136 form->submit_element = UTF8ToUTF16(string_attr_map["submit_element"]); |
| 137 form->signon_realm = string_attr_map["signon_realm"]; | 137 form->signon_realm = string_attr_map["signon_realm"]; |
| 138 form->ssl_valid = uint_attr_map["ssl_valid"]; | |
| 139 form->preferred = uint_attr_map["preferred"]; | 138 form->preferred = uint_attr_map["preferred"]; |
| 140 int64_t date_created = 0; | 139 int64_t date_created = 0; |
| 141 bool date_ok = base::StringToInt64(string_attr_map["date_created"], | 140 bool date_ok = base::StringToInt64(string_attr_map["date_created"], |
| 142 &date_created); | 141 &date_created); |
| 143 DCHECK(date_ok); | 142 DCHECK(date_ok); |
| 144 // In the past |date_created| was stored as time_t. Currently is stored as | 143 // In the past |date_created| was stored as time_t. Currently is stored as |
| 145 // base::Time's internal value. We need to distinguish, which format the | 144 // base::Time's internal value. We need to distinguish, which format the |
| 146 // number in |date_created| was stored in. We use the fact that | 145 // number in |date_created| was stored in. We use the fact that |
| 147 // kMaxPossibleTimeTValue interpreted as the internal value corresponds to an | 146 // kMaxPossibleTimeTValue interpreted as the internal value corresponds to an |
| 148 // unlikely date back in 17th century, and anything above | 147 // unlikely date back in 17th century, and anything above |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (lookup_form) { | 227 if (lookup_form) { |
| 229 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", | 228 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", |
| 230 allow_psl_match | 229 allow_psl_match |
| 231 ? psl_domain_match_metric | 230 ? psl_domain_match_metric |
| 232 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, | 231 : password_manager::PSL_DOMAIN_MATCH_NOT_USED, |
| 233 password_manager::PSL_DOMAIN_MATCH_COUNT); | 232 password_manager::PSL_DOMAIN_MATCH_COUNT); |
| 234 } | 233 } |
| 235 return forms; | 234 return forms; |
| 236 } | 235 } |
| 237 | 236 |
| 238 // Schema is analagous to the fields in PasswordForm. | 237 // Schema is analogous to the fields in PasswordForm. |
| 239 const GnomeKeyringPasswordSchema kGnomeSchema = { | 238 const GnomeKeyringPasswordSchema kGnomeSchema = { |
| 240 GNOME_KEYRING_ITEM_GENERIC_SECRET, | 239 GNOME_KEYRING_ITEM_GENERIC_SECRET, |
| 241 {{"origin_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 240 {{"origin_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 242 {"action_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 241 {"action_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 243 {"username_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 242 {"username_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 244 {"username_value", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 243 {"username_value", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 245 {"password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 244 {"password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 246 {"submit_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 245 {"submit_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 247 {"signon_realm", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 246 {"signon_realm", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 248 {"ssl_valid", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | |
| 249 {"preferred", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | 247 {"preferred", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, |
| 250 {"date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 248 {"date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 251 {"blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | 249 {"blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, |
| 252 {"scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | 250 {"scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, |
| 253 {"type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | 251 {"type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, |
| 254 {"times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, | 252 {"times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32}, |
| 255 {"date_synced", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 253 {"date_synced", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 256 {"display_name", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 254 {"display_name", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 257 {"avatar_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 255 {"avatar_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| 258 {"federation_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, | 256 {"federation_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 UTF16ToUTF8(form.password_value).c_str(), OnOperationDone, | 363 UTF16ToUTF8(form.password_value).c_str(), OnOperationDone, |
| 366 this, // data | 364 this, // data |
| 367 nullptr, // destroy_data | 365 nullptr, // destroy_data |
| 368 "origin_url", form.origin.spec().c_str(), | 366 "origin_url", form.origin.spec().c_str(), |
| 369 "action_url", form.action.spec().c_str(), | 367 "action_url", form.action.spec().c_str(), |
| 370 "username_element", UTF16ToUTF8(form.username_element).c_str(), | 368 "username_element", UTF16ToUTF8(form.username_element).c_str(), |
| 371 "username_value", UTF16ToUTF8(form.username_value).c_str(), | 369 "username_value", UTF16ToUTF8(form.username_value).c_str(), |
| 372 "password_element", UTF16ToUTF8(form.password_element).c_str(), | 370 "password_element", UTF16ToUTF8(form.password_element).c_str(), |
| 373 "submit_element", UTF16ToUTF8(form.submit_element).c_str(), | 371 "submit_element", UTF16ToUTF8(form.submit_element).c_str(), |
| 374 "signon_realm", form.signon_realm.c_str(), | 372 "signon_realm", form.signon_realm.c_str(), |
| 375 "ssl_valid", form.ssl_valid, | |
| 376 "preferred", form.preferred, | 373 "preferred", form.preferred, |
| 377 "date_created", base::Int64ToString(date_created).c_str(), | 374 "date_created", base::Int64ToString(date_created).c_str(), |
| 378 "blacklisted_by_user", form.blacklisted_by_user, | 375 "blacklisted_by_user", form.blacklisted_by_user, |
| 379 "type", form.type, | 376 "type", form.type, |
| 380 "times_used", form.times_used, | 377 "times_used", form.times_used, |
| 381 "scheme", form.scheme, | 378 "scheme", form.scheme, |
| 382 "date_synced", base::Int64ToString(date_synced).c_str(), | 379 "date_synced", base::Int64ToString(date_synced).c_str(), |
| 383 "display_name", UTF16ToUTF8(form.display_name).c_str(), | 380 "display_name", UTF16ToUTF8(form.display_name).c_str(), |
| 384 "avatar_url", form.icon_url.spec().c_str(), | 381 "avatar_url", form.icon_url.spec().c_str(), |
| 385 // We serialize unique origins as "", in order to make other systems that | 382 // We serialize unique origins as "", in order to make other systems that |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 ScopedVector<PasswordForm> forms; | 837 ScopedVector<PasswordForm> forms; |
| 841 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) | 838 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) |
| 842 return false; | 839 return false; |
| 843 | 840 |
| 844 for (size_t i = 0; i < forms.size(); ++i) { | 841 for (size_t i = 0; i < forms.size(); ++i) { |
| 845 if (!RemoveLogin(*forms[i], changes)) | 842 if (!RemoveLogin(*forms[i], changes)) |
| 846 return false; | 843 return false; |
| 847 } | 844 } |
| 848 return true; | 845 return true; |
| 849 } | 846 } |
| OLD | NEW |