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 | 6 * @fileoverview |
7 * Mock implementation of chrome.identity. | 7 * Mock implementation of chrome.identity. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 * @param {Array<*>} values | 72 * @param {Array<*>} values |
73 */ | 73 */ |
74 remoting.MockIdentity.validateTokenAndCall = | 74 remoting.MockIdentity.validateTokenAndCall = |
75 function(token, onDone, onError, values) { | 75 function(token, onDone, onError, values) { |
76 if (token == remoting.MockIdentity.AccessToken.VALID) { | 76 if (token == remoting.MockIdentity.AccessToken.VALID) { |
77 window.setTimeout( | 77 window.setTimeout( |
78 onDone.apply.bind(onDone, null, values), | 78 onDone.apply.bind(onDone, null, values), |
79 0); | 79 0); |
80 } else { | 80 } else { |
81 window.setTimeout( | 81 window.setTimeout( |
82 onError.bind(null, remoting.Error.AUTHENTICATION_FAILED), | 82 onError.bind(null, new remoting.Error( |
| 83 remoting.Error.Tag.AUTHENTICATION_FAILED)), |
83 0); | 84 0); |
84 } | 85 } |
85 }; | 86 }; |
86 | 87 |
87 /** | 88 /** |
88 * @param {Function} onDone | 89 * @param {Function} onDone |
89 * @param {function(!remoting.Error)} onError | 90 * @param {function(!remoting.Error)} onError |
90 * @param {Array<*>} values | 91 * @param {Array<*>} values |
91 */ | 92 */ |
92 remoting.MockIdentity.prototype.validateTokenAndCall = | 93 remoting.MockIdentity.prototype.validateTokenAndCall = |
93 function(onDone, onError, values) { | 94 function(onDone, onError, values) { |
94 remoting.MockIdentity.validateTokenAndCall( | 95 remoting.MockIdentity.validateTokenAndCall( |
95 this.accessToken_, onDone, onError, values); | 96 this.accessToken_, onDone, onError, values); |
96 }; | 97 }; |
97 | 98 |
98 /** | 99 /** |
99 * @param {boolean} active | 100 * @param {boolean} active |
100 */ | 101 */ |
101 remoting.MockIdentity.setActive = function(active) { | 102 remoting.MockIdentity.setActive = function(active) { |
102 chrome.identity = active ? remoting.mockIdentity | 103 chrome.identity = active ? remoting.mockIdentity |
103 : remoting.savedIdentityApi; | 104 : remoting.savedIdentityApi; |
104 }; | 105 }; |
105 | 106 |
106 /** @type {Object} */ | 107 /** @type {Object} */ |
107 remoting.savedIdentityApi = chrome.identity; | 108 remoting.savedIdentityApi = chrome.identity; |
108 | 109 |
109 /** @type {remoting.MockIdentity} */ | 110 /** @type {remoting.MockIdentity} */ |
110 remoting.mockIdentity = new remoting.MockIdentity(); | 111 remoting.mockIdentity = new remoting.MockIdentity(); |
OLD | NEW |