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 * A background script of the auth extension that bridges the communication | 7 * A background script of the auth extension that bridges the communication |
8 * between the main and injected scripts. | 8 * between the main and injected scripts. |
9 * | 9 * |
10 * Here is an overview of the communication flow when SAML is being used: | 10 * Here is an overview of the communication flow when SAML is being used: |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 'setGaiaUrl', this.onSetGaiaUrl_.bind(this)); | 156 'setGaiaUrl', this.onSetGaiaUrl_.bind(this)); |
157 this.channelMain_.registerMessage( | 157 this.channelMain_.registerMessage( |
158 'setBlockInsecureContent', this.onSetBlockInsecureContent_.bind(this)); | 158 'setBlockInsecureContent', this.onSetBlockInsecureContent_.bind(this)); |
159 this.channelMain_.registerMessage( | 159 this.channelMain_.registerMessage( |
160 'resetAuth', this.onResetAuth_.bind(this)); | 160 'resetAuth', this.onResetAuth_.bind(this)); |
161 this.channelMain_.registerMessage( | 161 this.channelMain_.registerMessage( |
162 'startAuth', this.onAuthStarted_.bind(this)); | 162 'startAuth', this.onAuthStarted_.bind(this)); |
163 this.channelMain_.registerMessage( | 163 this.channelMain_.registerMessage( |
164 'getScrapedPasswords', | 164 'getScrapedPasswords', |
165 this.onGetScrapedPasswords_.bind(this)); | 165 this.onGetScrapedPasswords_.bind(this)); |
| 166 this.channelMain_.registerMessage( |
| 167 'apiResponse', this.onAPIResponse_.bind(this)); |
166 | 168 |
167 this.channelMain_.send({ | 169 this.channelMain_.send({ |
168 'name': 'channelConnected' | 170 'name': 'channelConnected' |
169 }); | 171 }); |
170 }, | 172 }, |
171 | 173 |
172 /** | 174 /** |
173 * Sets up the communication channel with the injected script. | 175 * Sets up the communication channel with the injected script. |
174 */ | 176 */ |
175 setupForInjected: function(port) { | 177 setupForInjected: function(port) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 * @return {Array.<string>} The array with de-duped scraped passwords. | 336 * @return {Array.<string>} The array with de-duped scraped passwords. |
335 */ | 337 */ |
336 onGetScrapedPasswords_: function() { | 338 onGetScrapedPasswords_: function() { |
337 var passwords = {}; | 339 var passwords = {}; |
338 for (var property in this.passwordStore_) { | 340 for (var property in this.passwordStore_) { |
339 passwords[this.passwordStore_[property]] = true; | 341 passwords[this.passwordStore_[property]] = true; |
340 } | 342 } |
341 return Object.keys(passwords); | 343 return Object.keys(passwords); |
342 }, | 344 }, |
343 | 345 |
| 346 /** |
| 347 * Handler for 'apiResponse' signal sent from the main script. Passes on the |
| 348 * |msg| to the injected script. |
| 349 */ |
| 350 onAPIResponse_: function(msg) { |
| 351 this.channelInjected_.send(msg); |
| 352 }, |
| 353 |
344 onAPICall_: function(msg) { | 354 onAPICall_: function(msg) { |
345 this.channelMain_.send(msg); | 355 this.channelMain_.send(msg); |
346 }, | 356 }, |
347 | 357 |
348 onUpdatePassword_: function(msg) { | 358 onUpdatePassword_: function(msg) { |
349 if (!this.authStarted_) | 359 if (!this.authStarted_) |
350 return; | 360 return; |
351 | 361 |
352 this.passwordStore_[msg.id] = msg.password; | 362 this.passwordStore_[msg.id] = msg.password; |
353 }, | 363 }, |
354 | 364 |
355 onPageLoaded_: function(msg) { | 365 onPageLoaded_: function(msg) { |
356 if (this.channelMain_) | 366 if (this.channelMain_) |
357 this.channelMain_.send({name: 'onAuthPageLoaded', url: msg.url}); | 367 this.channelMain_.send({name: 'onAuthPageLoaded', url: msg.url}); |
358 } | 368 } |
359 }; | 369 }; |
360 | 370 |
361 var backgroundBridgeManager = new BackgroundBridgeManager(); | 371 var backgroundBridgeManager = new BackgroundBridgeManager(); |
362 backgroundBridgeManager.run(); | 372 backgroundBridgeManager.run(); |
OLD | NEW |