[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / components / proximity_auth / webui / resources / cryptauth_interface.js
blob31f53a2640b6d724e8591b0edefc042534fabedb
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.
5 /**
6 * Responsible for interfacing with the native component of the WebUI to make
7 * CryptAuth API requests and handling the responses.
8 */
9 CryptAuthInterface = {
10 /**
11 * A list of observers of CryptAuth events.
13 observers_: [],
15 /**
16 * Adds an observer.
18 addObserver: function(observer) {
19 CryptAuthInterface.observers_.push(observer);
22 /**
23 * Removes an observer.
25 removeObserver: function(observer) {
26 CryptAuthInterface.observers_.remove(observer);
29 /**
30 * Starts the findEligibleUnlockDevices API call.
32 findEligibleUnlockDevices: function() {
33 chrome.send('findEligibleUnlockDevices');
36 /**
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);
43 });
46 /**
47 * Called by the browser when a findEligibleUnlockDevices completes
48 * successfully.
50 onGotEligibleDevices: function(eligibleDevices, ineligibleDevices) {
51 CryptAuthInterface.observers_.forEach(function(observer) {
52 if (observer.onGotEligibleDevices != null)
53 observer.onGotEligibleDevices(eligibleDevices, ineligibleDevices);
54 });