1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Responsible for interfacing with the native component of the WebUI to make
7 * CryptAuth API requests and handling the responses.
11 * A list of observers of CryptAuth events.
18 addObserver: function(observer
) {
19 CryptAuthInterface
.observers_
.push(observer
);
23 * Removes an observer.
25 removeObserver: function(observer
) {
26 CryptAuthInterface
.observers_
.remove(observer
);
30 * Starts the findEligibleUnlockDevices API call.
32 findEligibleUnlockDevices: function() {
33 chrome
.send('findEligibleUnlockDevices');
37 * Called by the browser when the API request fails.
39 onError: function(errorMessage
) {
40 CryptAuthInterface
.observers_
.forEach(function(observer
) {
41 if (observer
.onCryptAuthError
!= null)
42 observer
.onCryptAuthError(errorMessage
);
47 * Called by the browser when a findEligibleUnlockDevices completes
50 onGotEligibleDevices: function(eligibleDevices
, ineligibleDevices
) {
51 CryptAuthInterface
.observers_
.forEach(function(observer
) {
52 if (observer
.onGotEligibleDevices
!= null)
53 observer
.onGotEligibleDevices(eligibleDevices
, ineligibleDevices
);