| OLD | NEW |
| 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 /** | 5 /** |
| 6 * @fileoverview CryptoToken background page | 6 * @fileoverview CryptoToken background page |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| 11 /** @const */ | 11 /** @const */ |
| 12 var BROWSER_SUPPORTS_TLS_CHANNEL_ID = true; | 12 var BROWSER_SUPPORTS_TLS_CHANNEL_ID = true; |
| 13 | 13 |
| 14 /** @const */ | 14 /** @const */ |
| 15 var HTTP_ORIGINS_ALLOWED = false; | 15 var HTTP_ORIGINS_ALLOWED = false; |
| 16 | 16 |
| 17 /** @const */ | 17 /** @const */ |
| 18 var LOG_SAVER_EXTENSION_ID = 'fjajfjhkeibgmiggdfehjplbhmfkialk'; | 18 var LOG_SAVER_EXTENSION_ID = 'fjajfjhkeibgmiggdfehjplbhmfkialk'; |
| 19 | 19 |
| 20 // Singleton tracking available devices. | 20 // Singleton tracking available devices. |
| 21 var gnubbies = new Gnubbies(); | 21 var gnubbies = new Gnubbies(); |
| 22 HidGnubbyDevice.register(gnubbies); | 22 HidGnubbyDevice.register(gnubbies); |
| 23 UsbGnubbyDevice.register(gnubbies); | 23 UsbGnubbyDevice.register(gnubbies); |
| 24 | 24 |
| 25 var FACTORY_REGISTRY = (function() { | 25 var FACTORY_REGISTRY = (function() { |
| 26 var windowTimer = new WindowTimer(); | 26 var windowTimer = new WindowTimer(); |
| 27 var xhrTextFetcher = new XhrTextFetcher(); | 27 var xhrTextFetcher = new XhrTextFetcher(); |
| 28 return new FactoryRegistry( | 28 return new FactoryRegistry( |
| 29 new XhrAppIdCheckerFactory(xhrTextFetcher), | 29 new XhrAppIdCheckerFactory(xhrTextFetcher), |
| 30 new CryptoTokenApprovedOrigin(), | 30 new CryptoTokenApprovedOrigin(), new CountdownTimerFactory(windowTimer), |
| 31 new CountdownTimerFactory(windowTimer), | 31 new CryptoTokenOriginChecker(), new UsbHelper(), windowTimer, |
| 32 new CryptoTokenOriginChecker(), | |
| 33 new UsbHelper(), | |
| 34 windowTimer, | |
| 35 xhrTextFetcher); | 32 xhrTextFetcher); |
| 36 })(); | 33 })(); |
| 37 | 34 |
| 38 var DEVICE_FACTORY_REGISTRY = new DeviceFactoryRegistry( | 35 var DEVICE_FACTORY_REGISTRY = new DeviceFactoryRegistry( |
| 39 new UsbGnubbyFactory(gnubbies), | 36 new UsbGnubbyFactory(gnubbies), FACTORY_REGISTRY.getCountdownFactory(), |
| 40 FACTORY_REGISTRY.getCountdownFactory(), | |
| 41 new GoogleCorpIndividualAttestation()); | 37 new GoogleCorpIndividualAttestation()); |
| 42 | 38 |
| 43 /** | 39 /** |
| 44 * @param {*} request The received request | 40 * @param {*} request The received request |
| 45 * @return {boolean} Whether the request is a register/enroll request. | 41 * @return {boolean} Whether the request is a register/enroll request. |
| 46 */ | 42 */ |
| 47 function isRegisterRequest(request) { | 43 function isRegisterRequest(request) { |
| 48 if (!request) { | 44 if (!request) { |
| 49 return false; | 45 return false; |
| 50 } | 46 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 */ | 96 */ |
| 101 function messageHandler(request, sender, sendResponse) { | 97 function messageHandler(request, sender, sendResponse) { |
| 102 var responseCallback; | 98 var responseCallback; |
| 103 if (isRegisterRequest(request)) { | 99 if (isRegisterRequest(request)) { |
| 104 responseCallback = | 100 responseCallback = |
| 105 sendResponseToActiveTabOnly.bind(null, request, sender, sendResponse); | 101 sendResponseToActiveTabOnly.bind(null, request, sender, sendResponse); |
| 106 } else { | 102 } else { |
| 107 responseCallback = | 103 responseCallback = |
| 108 defaultResponseCallback.bind(null, request, sendResponse); | 104 defaultResponseCallback.bind(null, request, sendResponse); |
| 109 } | 105 } |
| 110 var closeable = handleWebPageRequest(/** @type {Object} */(request), | 106 var closeable = handleWebPageRequest( |
| 111 sender, responseCallback); | 107 /** @type {Object} */ (request), sender, responseCallback); |
| 112 return closeable; | 108 return closeable; |
| 113 } | 109 } |
| 114 | 110 |
| 115 /** | 111 /** |
| 116 * Listen to individual messages sent from (whitelisted) webpages via | 112 * Listen to individual messages sent from (whitelisted) webpages via |
| 117 * chrome.runtime.sendMessage | 113 * chrome.runtime.sendMessage |
| 118 * @param {*} request The received request | 114 * @param {*} request The received request |
| 119 * @param {!MessageSender} sender The message sender | 115 * @param {!MessageSender} sender The message sender |
| 120 * @param {function(*): void} sendResponse A callback that delivers a response | 116 * @param {function(*): void} sendResponse A callback that delivers a response |
| 121 * @return {boolean} | 117 * @return {boolean} |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (originalUtilFmt_) { | 166 if (originalUtilFmt_) { |
| 171 UTIL_fmt = originalUtilFmt_; | 167 UTIL_fmt = originalUtilFmt_; |
| 172 originalUtilFmt_ = null; | 168 originalUtilFmt_ = null; |
| 173 } | 169 } |
| 174 } | 170 } |
| 175 return false; | 171 return false; |
| 176 } | 172 } |
| 177 | 173 |
| 178 /** @private */ | 174 /** @private */ |
| 179 var originalUtilFmt_ = null; | 175 var originalUtilFmt_ = null; |
| OLD | NEW |