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

Side by Side Diff: components/password_manager/core/browser/login_database.cc

Issue 1723583004: CREDENTIAL: Convert federations from URLs to origins throughout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS2 Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/core/browser/login_database.h" 5 #include "components/password_manager/core/browser/login_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 13 matching lines...) Expand all
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "components/autofill/core/common/password_form.h" 25 #include "components/autofill/core/common/password_form.h"
26 #include "components/password_manager/core/browser/affiliation_utils.h" 26 #include "components/password_manager/core/browser/affiliation_utils.h"
27 #include "components/password_manager/core/browser/password_manager_client.h" 27 #include "components/password_manager/core/browser/password_manager_client.h"
28 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 28 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
29 #include "google_apis/gaia/gaia_auth_util.h" 29 #include "google_apis/gaia/gaia_auth_util.h"
30 #include "google_apis/gaia/gaia_urls.h" 30 #include "google_apis/gaia/gaia_urls.h"
31 #include "sql/connection.h" 31 #include "sql/connection.h"
32 #include "sql/statement.h" 32 #include "sql/statement.h"
33 #include "sql/transaction.h" 33 #include "sql/transaction.h"
34 #include "url/origin.h"
34 #include "url/url_constants.h" 35 #include "url/url_constants.h"
35 36
36 using autofill::PasswordForm; 37 using autofill::PasswordForm;
37 38
38 namespace password_manager { 39 namespace password_manager {
39 40
40 // The current version number of the login database schema. 41 // The current version number of the login database schema.
41 const int kCurrentVersionNumber = 16; 42 const int kCurrentVersionNumber = 16;
42 // The oldest version of the schema such that a legacy Chrome client using that 43 // The oldest version of the schema such that a legacy Chrome client using that
43 // version can still read/write the current database. 44 // version can still read/write the current database.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 usernames_pickle.size()); 134 usernames_pickle.size());
134 s->BindInt(COLUMN_TIMES_USED, form.times_used); 135 s->BindInt(COLUMN_TIMES_USED, form.times_used);
135 base::Pickle form_data_pickle; 136 base::Pickle form_data_pickle;
136 autofill::SerializeFormData(form.form_data, &form_data_pickle); 137 autofill::SerializeFormData(form.form_data, &form_data_pickle);
137 s->BindBlob(COLUMN_FORM_DATA, 138 s->BindBlob(COLUMN_FORM_DATA,
138 form_data_pickle.data(), 139 form_data_pickle.data(),
139 form_data_pickle.size()); 140 form_data_pickle.size());
140 s->BindInt64(COLUMN_DATE_SYNCED, form.date_synced.ToInternalValue()); 141 s->BindInt64(COLUMN_DATE_SYNCED, form.date_synced.ToInternalValue());
141 s->BindString16(COLUMN_DISPLAY_NAME, form.display_name); 142 s->BindString16(COLUMN_DISPLAY_NAME, form.display_name);
142 s->BindString(COLUMN_ICON_URL, form.icon_url.spec()); 143 s->BindString(COLUMN_ICON_URL, form.icon_url.spec());
143 s->BindString(COLUMN_FEDERATION_URL, form.federation_url.spec()); 144 s->BindString(COLUMN_FEDERATION_URL, form.federation_origin.Serialize());
144 s->BindInt(COLUMN_SKIP_ZERO_CLICK, form.skip_zero_click); 145 s->BindInt(COLUMN_SKIP_ZERO_CLICK, form.skip_zero_click);
145 s->BindInt(COLUMN_GENERATION_UPLOAD_STATUS, form.generation_upload_status); 146 s->BindInt(COLUMN_GENERATION_UPLOAD_STATUS, form.generation_upload_status);
146 } 147 }
147 148
148 void AddCallback(int err, sql::Statement* /*stmt*/) { 149 void AddCallback(int err, sql::Statement* /*stmt*/) {
149 if (err == 19 /*SQLITE_CONSTRAINT*/) 150 if (err == 19 /*SQLITE_CONSTRAINT*/)
150 DLOG(WARNING) << "LoginDatabase::AddLogin updated an existing form"; 151 DLOG(WARNING) << "LoginDatabase::AddLogin updated an existing form";
151 } 152 }
152 153
153 bool DoesMatchConstraints(const PasswordForm& form) { 154 bool DoesMatchConstraints(const PasswordForm& form) {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 s.BindBlob(4, pickle.data(), pickle.size()); 927 s.BindBlob(4, pickle.data(), pickle.size());
927 s.BindInt(5, form.times_used); 928 s.BindInt(5, form.times_used);
928 s.BindString16(6, form.submit_element); 929 s.BindString16(6, form.submit_element);
929 s.BindInt64(7, form.date_synced.ToInternalValue()); 930 s.BindInt64(7, form.date_synced.ToInternalValue());
930 s.BindInt64(8, form.date_created.ToInternalValue()); 931 s.BindInt64(8, form.date_created.ToInternalValue());
931 s.BindInt(9, form.blacklisted_by_user); 932 s.BindInt(9, form.blacklisted_by_user);
932 s.BindInt(10, form.scheme); 933 s.BindInt(10, form.scheme);
933 s.BindInt(11, form.type); 934 s.BindInt(11, form.type);
934 s.BindString16(12, form.display_name); 935 s.BindString16(12, form.display_name);
935 s.BindString(13, form.icon_url.spec()); 936 s.BindString(13, form.icon_url.spec());
936 s.BindString(14, form.federation_url.spec()); 937 s.BindString(14, form.federation_origin.Serialize());
937 s.BindInt(15, form.skip_zero_click); 938 s.BindInt(15, form.skip_zero_click);
938 s.BindInt(16, form.generation_upload_status); 939 s.BindInt(16, form.generation_upload_status);
939 940
940 // WHERE starts here. 941 // WHERE starts here.
941 s.BindString(17, form.origin.spec()); 942 s.BindString(17, form.origin.spec());
942 s.BindString16(18, form.username_element); 943 s.BindString16(18, form.username_element);
943 s.BindString16(19, form.username_value); 944 s.BindString16(19, form.username_value);
944 s.BindString16(20, form.password_element); 945 s.BindString16(20, form.password_element);
945 s.BindString(21, form.signon_realm); 946 s.BindString(21, form.signon_realm);
946 947
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 autofill::DeserializeFormData(&form_data_iter, &form->form_data); 1068 autofill::DeserializeFormData(&form_data_iter, &form->form_data);
1068 metrics_util::FormDeserializationStatus status = 1069 metrics_util::FormDeserializationStatus status =
1069 success ? metrics_util::LOGIN_DATABASE_SUCCESS 1070 success ? metrics_util::LOGIN_DATABASE_SUCCESS
1070 : metrics_util::LOGIN_DATABASE_FAILURE; 1071 : metrics_util::LOGIN_DATABASE_FAILURE;
1071 metrics_util::LogFormDataDeserializationStatus(status); 1072 metrics_util::LogFormDataDeserializationStatus(status);
1072 } 1073 }
1073 form->date_synced = 1074 form->date_synced =
1074 base::Time::FromInternalValue(s.ColumnInt64(COLUMN_DATE_SYNCED)); 1075 base::Time::FromInternalValue(s.ColumnInt64(COLUMN_DATE_SYNCED));
1075 form->display_name = s.ColumnString16(COLUMN_DISPLAY_NAME); 1076 form->display_name = s.ColumnString16(COLUMN_DISPLAY_NAME);
1076 form->icon_url = GURL(s.ColumnString(COLUMN_ICON_URL)); 1077 form->icon_url = GURL(s.ColumnString(COLUMN_ICON_URL));
1077 form->federation_url = GURL(s.ColumnString(COLUMN_FEDERATION_URL)); 1078 form->federation_origin =
1079 url::Origin(GURL(s.ColumnString(COLUMN_FEDERATION_URL)));
1078 form->skip_zero_click = (s.ColumnInt(COLUMN_SKIP_ZERO_CLICK) > 0); 1080 form->skip_zero_click = (s.ColumnInt(COLUMN_SKIP_ZERO_CLICK) > 0);
1079 int generation_upload_status_int = 1081 int generation_upload_status_int =
1080 s.ColumnInt(COLUMN_GENERATION_UPLOAD_STATUS); 1082 s.ColumnInt(COLUMN_GENERATION_UPLOAD_STATUS);
1081 DCHECK(generation_upload_status_int >= 0 && 1083 DCHECK(generation_upload_status_int >= 0 &&
1082 generation_upload_status_int <= PasswordForm::UNKNOWN_STATUS); 1084 generation_upload_status_int <= PasswordForm::UNKNOWN_STATUS);
1083 form->generation_upload_status = 1085 form->generation_upload_status =
1084 static_cast<PasswordForm::GenerationUploadStatus>( 1086 static_cast<PasswordForm::GenerationUploadStatus>(
1085 generation_upload_status_int); 1087 generation_upload_status_int);
1086 return ENCRYPTION_RESULT_SUCCESS; 1088 return ENCRYPTION_RESULT_SUCCESS;
1087 } 1089 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1296 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1295 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); 1297 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT);
1296 } 1298 }
1297 1299
1298 if (!statement->Succeeded()) 1300 if (!statement->Succeeded())
1299 return false; 1301 return false;
1300 return true; 1302 return true;
1301 } 1303 }
1302 1304
1303 } // namespace password_manager 1305 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698