| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/password_manager/sync/browser/password_sync_util.h" | 5 #include "components/password_manager/sync/browser/password_sync_util.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/common/password_form.h" | 8 #include "components/autofill/core/common/password_form.h" |
| 9 #include "google_apis/gaia/gaia_auth_util.h" | 9 #include "google_apis/gaia/gaia_auth_util.h" |
| 10 #include "google_apis/gaia/gaia_urls.h" | 10 #include "google_apis/gaia/gaia_urls.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool IsSyncAccountCredential(const autofill::PasswordForm& form, | 34 bool IsSyncAccountCredential(const autofill::PasswordForm& form, |
| 35 const sync_driver::SyncService* sync_service, | 35 const sync_driver::SyncService* sync_service, |
| 36 const SigninManagerBase* signin_manager) { | 36 const SigninManagerBase* signin_manager) { |
| 37 const Origin gaia_origin(GaiaUrls::GetInstance()->gaia_url().GetOrigin()); | 37 const Origin gaia_origin(GaiaUrls::GetInstance()->gaia_url().GetOrigin()); |
| 38 if (!Origin(GURL(form.signon_realm)).IsSameOriginWith(gaia_origin)) { | 38 if (!Origin(GURL(form.signon_realm)).IsSameOriginWith(gaia_origin)) { |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // The empty username can mean that Chrome did not detect it correctly. For |
| 43 // reasons described in http://crbug.com/636292#c1, the username is suspected |
| 44 // to be the sync username unless proven otherwise. |
| 45 if (form.username_value.empty()) |
| 46 return true; |
| 47 |
| 42 return gaia::AreEmailsSame( | 48 return gaia::AreEmailsSame( |
| 43 base::UTF16ToUTF8(form.username_value), | 49 base::UTF16ToUTF8(form.username_value), |
| 44 GetSyncUsernameIfSyncingPasswords(sync_service, signin_manager)); | 50 GetSyncUsernameIfSyncingPasswords(sync_service, signin_manager)); |
| 45 } | 51 } |
| 46 | 52 |
| 47 } // namespace sync_util | 53 } // namespace sync_util |
| 48 } // namespace password_manager | 54 } // namespace password_manager |
| OLD | NEW |