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

Side by Side Diff: chrome/browser/resources/gaia_auth/saml_injected.js

Issue 2053393003: Track password field id so it can be used to improve uniqueness of passwordId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Script to be injected into SAML provider pages, serving three main purposes: 7 * Script to be injected into SAML provider pages, serving three main purposes:
8 * 1. Signal hosting extension that an external page is loaded so that the 8 * 1. Signal hosting extension that an external page is loaded so that the
9 * UI around it should be changed accordingly; 9 * UI around it should be changed accordingly;
10 * 2. Provide an API via which the SAML provider can pass user credentials to 10 * 2. Provide an API via which the SAML provider can pass user credentials to
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 * @param {!HTMLInputElement} passworField The password field to track. 136 * @param {!HTMLInputElement} passworField The password field to track.
137 */ 137 */
138 trackPasswordField: function(passwordField) { 138 trackPasswordField: function(passwordField) {
139 var existing = this.passwordFields_.filter(function(element) { 139 var existing = this.passwordFields_.filter(function(element) {
140 return element === passwordField; 140 return element === passwordField;
141 }); 141 });
142 if (existing.length != 0) 142 if (existing.length != 0)
143 return; 143 return;
144 144
145 var index = this.passwordFields_.length; 145 var index = this.passwordFields_.length;
146 var fieldId = passwordField.id;
xiyuan 2016/06/10 17:05:58 It is possible that the IdP page does not set "id"
146 passwordField.addEventListener( 147 passwordField.addEventListener(
147 'input', this.onPasswordChanged_.bind(this, index)); 148 'input', this.onPasswordChanged_.bind(this, index, fieldId));
148 this.passwordFields_.push(passwordField); 149 this.passwordFields_.push(passwordField);
149 this.passwordValues_.push(passwordField.value); 150 this.passwordValues_.push(passwordField.value);
150 }, 151 },
151 152
152 /** 153 /**
153 * Check if the password field at |index| has changed. If so, sends back 154 * Check if the password field at |index| has changed. If so, sends back
154 * the updated value. 155 * the updated value.
155 */ 156 */
156 maybeSendUpdatedPassword: function(index) { 157 maybeSendUpdatedPassword: function(index, fieldId) {
157 var newValue = this.passwordFields_[index].value; 158 var newValue = this.passwordFields_[index].value;
158 if (newValue == this.passwordValues_[index]) 159 if (newValue == this.passwordValues_[index])
159 return; 160 return;
160 161
161 this.passwordValues_[index] = newValue; 162 this.passwordValues_[index] = newValue;
162 163
163 // Use an invalid char for URL as delimiter to concatenate page url and 164 // Use an invalid char for URL as delimiter to concatenate page url,
164 // password field index to construct a unique ID for the password field. 165 // password field index and id to construct a unique ID for the password
165 var passwordId = this.pageURL_.split('#')[0].split('?')[0] + '|' + index; 166 // field.
167 var passwordId = this.pageURL_.split('#')[0].split('?')[0] +
168 '|' + index + '|' + fieldId;
166 this.channel_.send({ 169 this.channel_.send({
167 name: 'updatePassword', 170 name: 'updatePassword',
168 id: passwordId, 171 id: passwordId,
169 password: newValue 172 password: newValue
170 }); 173 });
171 }, 174 },
172 175
173 /** 176 /**
174 * Handles 'change' event in the scraped password fields. 177 * Handles 'change' event in the scraped password fields.
175 * @param {number} index The index of the password fields in 178 * @param {number} index The index of the password fields in
176 * |passwordFields_|. 179 * |passwordFields_|.
xiyuan 2016/06/10 17:05:59 Document fieldId?
177 */ 180 */
178 onPasswordChanged_: function(index) { 181 onPasswordChanged_: function(index, fieldId) {
179 this.maybeSendUpdatedPassword(index); 182 this.maybeSendUpdatedPassword(index, fieldId);
180 } 183 }
181 }; 184 };
182 185
183 function onGetSAMLFlag(channel, isSAMLPage) { 186 function onGetSAMLFlag(channel, isSAMLPage) {
184 if (!isSAMLPage) 187 if (!isSAMLPage)
185 return; 188 return;
186 var pageURL = window.location.href; 189 var pageURL = window.location.href;
187 190
188 channel.send({name: 'pageLoaded', url: pageURL}); 191 channel.send({name: 'pageLoaded', url: pageURL});
189 192
(...skipping 15 matching lines...) Expand all
205 } 208 }
206 209
207 var channel = Channel.create(); 210 var channel = Channel.create();
208 channel.connect('injected'); 211 channel.connect('injected');
209 channel.sendWithCallback({name: 'getSAMLFlag'}, 212 channel.sendWithCallback({name: 'getSAMLFlag'},
210 onGetSAMLFlag.bind(undefined, channel)); 213 onGetSAMLFlag.bind(undefined, channel));
211 214
212 var apiCallForwarder = new APICallForwarder(); 215 var apiCallForwarder = new APICallForwarder();
213 apiCallForwarder.init(channel); 216 apiCallForwarder.init(channel);
214 })(); 217 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698