| OLD | NEW |
| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 function onGetSAMLFlag(channel, isSAMLPage) { | 183 function onGetSAMLFlag(channel, isSAMLPage) { |
| 184 if (!isSAMLPage) | 184 if (!isSAMLPage) |
| 185 return; | 185 return; |
| 186 var pageURL = window.location.href; | 186 var pageURL = window.location.href; |
| 187 | 187 |
| 188 channel.send({name: 'pageLoaded', url: pageURL}); | 188 channel.send({name: 'pageLoaded', url: pageURL}); |
| 189 | 189 |
| 190 var apiCallForwarder = new APICallForwarder(); | |
| 191 apiCallForwarder.init(channel); | |
| 192 | |
| 193 var initPasswordScraper = function() { | 190 var initPasswordScraper = function() { |
| 194 var passwordScraper = new PasswordInputScraper(); | 191 var passwordScraper = new PasswordInputScraper(); |
| 195 passwordScraper.init(channel, pageURL, document.documentElement); | 192 passwordScraper.init(channel, pageURL, document.documentElement); |
| 196 }; | 193 }; |
| 197 | 194 |
| 198 if (document.readyState == 'loading') { | 195 if (document.readyState == 'loading') { |
| 199 window.addEventListener('readystatechange', function listener(event) { | 196 window.addEventListener('readystatechange', function listener(event) { |
| 200 if (document.readyState == 'loading') | 197 if (document.readyState == 'loading') |
| 201 return; | 198 return; |
| 202 initPasswordScraper(); | 199 initPasswordScraper(); |
| 203 window.removeEventListener(event.type, listener, true); | 200 window.removeEventListener(event.type, listener, true); |
| 204 }, true); | 201 }, true); |
| 205 } else { | 202 } else { |
| 206 initPasswordScraper(); | 203 initPasswordScraper(); |
| 207 } | 204 } |
| 208 } | 205 } |
| 209 | 206 |
| 210 var channel = new Channel(); | 207 var channel = Channel.create(); |
| 211 channel.connect('injected'); | 208 channel.connect('injected'); |
| 212 channel.sendWithCallback({name: 'getSAMLFlag'}, | 209 channel.sendWithCallback({name: 'getSAMLFlag'}, |
| 213 onGetSAMLFlag.bind(undefined, channel)); | 210 onGetSAMLFlag.bind(undefined, channel)); |
| 211 |
| 212 var apiCallForwarder = new APICallForwarder(); |
| 213 apiCallForwarder.init(channel); |
| 214 })(); | 214 })(); |
| OLD | NEW |