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

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

Issue 384003002: [cleanup] SAML is always enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Misprint. Created 6 years, 5 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 | Annotate | Revision Log
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * Handles 'change' event in the scraped password fields. 127 * Handles 'change' event in the scraped password fields.
128 * @param {number} index The index of the password fields in 128 * @param {number} index The index of the password fields in
129 * |passwordFields_|. 129 * |passwordFields_|.
130 */ 130 */
131 onPasswordChanged_: function(index) { 131 onPasswordChanged_: function(index) {
132 this.maybeSendUpdatedPassword(index); 132 this.maybeSendUpdatedPassword(index);
133 } 133 }
134 }; 134 };
135 135
136 /** 136 /**
137 * Returns true if the script is injected into auth main page.
138 */
139 function isAuthMainPage() {
140 return window.location.href.indexOf(
141 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html') == 0;
142 }
143
144 /**
145 * Heuristic test whether the current page is a relevant SAML page. 137 * Heuristic test whether the current page is a relevant SAML page.
146 * Current implementation checks if it is a http or https page and has 138 * Current implementation checks if it is a http or https page and has
147 * some content in it. 139 * some content in it.
148 * @return {boolean} Whether the current page looks like a SAML page. 140 * @return {boolean} Whether the current page looks like a SAML page.
149 */ 141 */
150 function isSAMLPage() { 142 function isSAMLPage() {
151 var url = window.location.href; 143 var url = window.location.href;
152 if (!url.match(/^(http|https):\/\//)) 144 if (!url.match(/^(http|https):\/\//))
153 return false; 145 return false;
154 146
155 return document.body.scrollWidth > 50 && document.body.scrollHeight > 50; 147 return document.body.scrollWidth > 50 && document.body.scrollHeight > 50;
156 } 148 }
157 149
158 if (isAuthMainPage()) { 150 if (isSAMLPage()) {
159 // Use an event to signal the auth main to enable SAML support. 151 var pageURL = window.location.href;
160 var e = document.createEvent('Event');
161 e.initEvent('enableSAML', false, false);
162 document.dispatchEvent(e);
163 } else {
164 var channel;
165 var passwordScraper;
166 if (isSAMLPage()) {
167 var pageURL = window.location.href;
168 152
169 channel = new Channel(); 153 var channel = new Channel();
170 channel.connect('injected'); 154 channel.connect('injected');
171 channel.send({name: 'pageLoaded', url: pageURL}); 155 channel.send({name: 'pageLoaded', url: pageURL});
172 156
173 apiCallForwarder = new APICallForwarder(); 157 var apiCallForwarder = new APICallForwarder();
174 apiCallForwarder.init(channel); 158 apiCallForwarder.init(channel);
175 159
176 passwordScraper = new PasswordInputScraper(); 160 var passwordScraper = new PasswordInputScraper();
177 passwordScraper.init(channel, pageURL, document.documentElement); 161 passwordScraper.init(channel, pageURL, document.documentElement);
178 }
179 } 162 }
180 })(); 163 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698