| 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 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]); | 148 form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]); |
| 149 form->times_used = uint_attr_map["times_used"]; | 149 form->times_used = uint_attr_map["times_used"]; |
| 150 form->scheme = static_cast<PasswordForm::Scheme>(uint_attr_map["scheme"]); | 150 form->scheme = static_cast<PasswordForm::Scheme>(uint_attr_map["scheme"]); |
| 151 int64 date_synced = 0; | 151 int64 date_synced = 0; |
| 152 base::StringToInt64(string_attr_map["date_synced"], &date_synced); | 152 base::StringToInt64(string_attr_map["date_synced"], &date_synced); |
| 153 form->date_synced = base::Time::FromInternalValue(date_synced); | 153 form->date_synced = base::Time::FromInternalValue(date_synced); |
| 154 form->display_name = UTF8ToUTF16(string_attr_map["display_name"]); | 154 form->display_name = UTF8ToUTF16(string_attr_map["display_name"]); |
| 155 form->avatar_url = GURL(string_attr_map["avatar_url"]); | 155 form->avatar_url = GURL(string_attr_map["avatar_url"]); |
| 156 form->federation_url = GURL(string_attr_map["federation_url"]); | 156 form->federation_url = GURL(string_attr_map["federation_url"]); |
| 157 form->skip_zero_click = uint_attr_map["skip_zero_click"]; | 157 form->skip_zero_click = uint_attr_map["skip_zero_click"]; |
| 158 form->generation_upload_status = |
| 159 static_cast<PasswordForm::GenerationUploadStatus>( |
| 160 uint_attr_map["generation_upload_status"]); |
| 158 | 161 |
| 159 return form.Pass(); | 162 return form.Pass(); |
| 160 } | 163 } |
| 161 | 164 |
| 162 // Parse all the results from the given GList into a | 165 // Parse all the results from the given GList into a |
| 163 // ScopedVector<autofill::PasswordForm>, and free the GList. PasswordForms are | 166 // ScopedVector<autofill::PasswordForm>, and free the GList. PasswordForms are |
| 164 // allocated on the heap, and should be deleted by the consumer. If not NULL, | 167 // allocated on the heap, and should be deleted by the consumer. If not NULL, |
| 165 // |lookup_form| is used to filter out results -- only credentials with signon | 168 // |lookup_form| is used to filter out results -- only credentials with signon |
| 166 // realms passing the PSL matching against |lookup_form->signon_realm| will be | 169 // realms passing the PSL matching against |lookup_form->signon_realm| will be |
| 167 // kept. PSL matched results get their signon_realm, origin, and action | 170 // kept. PSL matched results get their signon_realm, origin, and action |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 { "date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 239 { "date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 237 { "blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, | 240 { "blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 238 { "scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, | 241 { "scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 239 { "type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, | 242 { "type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 240 { "times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, | 243 { "times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 241 { "date_synced", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 244 { "date_synced", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 242 { "display_name", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 245 { "display_name", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 243 { "avatar_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 246 { "avatar_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 244 { "federation_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 247 { "federation_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 245 { "skip_zero_click", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, | 248 { "skip_zero_click", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 249 { "generation_upload_status", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, |
| 246 // This field is always "chrome" so that we can search for it. | 250 // This field is always "chrome" so that we can search for it. |
| 247 { "application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, | 251 { "application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, |
| 248 { NULL } | 252 { NULL } |
| 249 } | 253 } |
| 250 }; | 254 }; |
| 251 | 255 |
| 252 // Sadly, PasswordStore goes to great lengths to switch from the originally | 256 // Sadly, PasswordStore goes to great lengths to switch from the originally |
| 253 // calling thread to the DB thread, and to provide an asynchronous API to | 257 // calling thread to the DB thread, and to provide an asynchronous API to |
| 254 // callers while using a synchronous (virtual) API provided by subclasses like | 258 // callers while using a synchronous (virtual) API provided by subclasses like |
| 255 // PasswordStoreX -- but GNOME Keyring really wants to be on the GLib main | 259 // PasswordStoreX -- but GNOME Keyring really wants to be on the GLib main |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 "date_created", base::Int64ToString(date_created).c_str(), | 359 "date_created", base::Int64ToString(date_created).c_str(), |
| 356 "blacklisted_by_user", form.blacklisted_by_user, | 360 "blacklisted_by_user", form.blacklisted_by_user, |
| 357 "type", form.type, | 361 "type", form.type, |
| 358 "times_used", form.times_used, | 362 "times_used", form.times_used, |
| 359 "scheme", form.scheme, | 363 "scheme", form.scheme, |
| 360 "date_synced", base::Int64ToString(date_synced).c_str(), | 364 "date_synced", base::Int64ToString(date_synced).c_str(), |
| 361 "display_name", UTF16ToUTF8(form.display_name).c_str(), | 365 "display_name", UTF16ToUTF8(form.display_name).c_str(), |
| 362 "avatar_url", form.avatar_url.spec().c_str(), | 366 "avatar_url", form.avatar_url.spec().c_str(), |
| 363 "federation_url", form.federation_url.spec().c_str(), | 367 "federation_url", form.federation_url.spec().c_str(), |
| 364 "skip_zero_click", form.skip_zero_click, | 368 "skip_zero_click", form.skip_zero_click, |
| 369 "generation_upload_status", form.generation_upload_status, |
| 365 "application", app_string, | 370 "application", app_string, |
| 366 NULL); | 371 NULL); |
| 367 } | 372 } |
| 368 | 373 |
| 369 void GKRMethod::AddLoginSearch(const PasswordForm& form, | 374 void GKRMethod::AddLoginSearch(const PasswordForm& form, |
| 370 const char* app_string) { | 375 const char* app_string) { |
| 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 372 lookup_form_.reset(NULL); | 377 lookup_form_.reset(NULL); |
| 373 // Search GNOME Keyring for matching passwords to update. | 378 // Search GNOME Keyring for matching passwords to update. |
| 374 ScopedAttributeList attrs(gnome_keyring_attribute_list_new()); | 379 ScopedAttributeList attrs(gnome_keyring_attribute_list_new()); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 806 } |
| 802 return ok; | 807 return ok; |
| 803 } | 808 } |
| 804 | 809 |
| 805 std::string NativeBackendGnome::GetProfileSpecificAppString() const { | 810 std::string NativeBackendGnome::GetProfileSpecificAppString() const { |
| 806 // Originally, the application string was always just "chrome" and used only | 811 // Originally, the application string was always just "chrome" and used only |
| 807 // so that we had *something* to search for since GNOME Keyring won't search | 812 // so that we had *something* to search for since GNOME Keyring won't search |
| 808 // for nothing. Now we use it to distinguish passwords for different profiles. | 813 // for nothing. Now we use it to distinguish passwords for different profiles. |
| 809 return base::StringPrintf("%s-%d", kGnomeKeyringAppString, profile_id_); | 814 return base::StringPrintf("%s-%d", kGnomeKeyringAppString, profile_id_); |
| 810 } | 815 } |
| OLD | NEW |