OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 A helper object used from the the People section to interact | 6 * @fileoverview A helper object used from the the People section to interact |
7 * with the Easy Unlock functionality of the browser. ChromeOS only. | 7 * with the Easy Unlock functionality of the browser. ChromeOS only. |
8 */ | 8 */ |
9 cr.exportPath('settings'); | 9 cr.exportPath('settings'); |
10 | 10 |
11 cr.define('settings', function() { | 11 cr.define('settings', function() { |
12 /** @interface */ | 12 /** @interface */ |
13 function EasyUnlockBrowserProxy() {} | 13 class EasyUnlockBrowserProxy { |
14 | |
15 EasyUnlockBrowserProxy.prototype = { | |
16 /** | 14 /** |
17 * Returns a true promise if Easy Unlock is already enabled on the device. | 15 * Returns a true promise if Easy Unlock is already enabled on the device. |
18 * @return {!Promise<boolean>} | 16 * @return {!Promise<boolean>} |
19 */ | 17 */ |
20 getEnabledStatus: function() {}, | 18 getEnabledStatus() {} |
21 | 19 |
22 /** | 20 /** |
23 * Starts the Easy Unlock setup flow. | 21 * Starts the Easy Unlock setup flow. |
24 */ | 22 */ |
25 startTurnOnFlow: function() {}, | 23 startTurnOnFlow() {} |
26 | 24 |
27 /** | 25 /** |
28 * Returns the Easy Unlock turn off flow status. | 26 * Returns the Easy Unlock turn off flow status. |
29 * @return {!Promise<string>} | 27 * @return {!Promise<string>} |
30 */ | 28 */ |
31 getTurnOffFlowStatus: function() {}, | 29 getTurnOffFlowStatus() {} |
32 | 30 |
33 /** | 31 /** |
34 * Begins the Easy Unlock turn off flow. | 32 * Begins the Easy Unlock turn off flow. |
35 */ | 33 */ |
36 startTurnOffFlow: function() {}, | 34 startTurnOffFlow() {} |
37 | 35 |
38 /** | 36 /** |
39 * Cancels any in-progress Easy Unlock turn-off flows. | 37 * Cancels any in-progress Easy Unlock turn-off flows. |
40 */ | 38 */ |
41 cancelTurnOffFlow: function() {}, | 39 cancelTurnOffFlow() {} |
42 }; | 40 } |
43 | 41 |
44 /** | 42 /** |
45 * @constructor | |
46 * @implements {settings.EasyUnlockBrowserProxy} | 43 * @implements {settings.EasyUnlockBrowserProxy} |
47 */ | 44 */ |
48 function EasyUnlockBrowserProxyImpl() {} | 45 class EasyUnlockBrowserProxyImpl { |
| 46 /** @override */ |
| 47 getEnabledStatus() { |
| 48 return cr.sendWithPromise('easyUnlockGetEnabledStatus'); |
| 49 } |
| 50 |
| 51 /** @override */ |
| 52 startTurnOnFlow() { |
| 53 chrome.send('easyUnlockStartTurnOnFlow'); |
| 54 } |
| 55 |
| 56 /** @override */ |
| 57 getTurnOffFlowStatus() { |
| 58 return cr.sendWithPromise('easyUnlockGetTurnOffFlowStatus'); |
| 59 } |
| 60 |
| 61 /** @override */ |
| 62 startTurnOffFlow() { |
| 63 chrome.send('easyUnlockStartTurnOffFlow'); |
| 64 } |
| 65 |
| 66 /** @override */ |
| 67 cancelTurnOffFlow() { |
| 68 chrome.send('easyUnlockCancelTurnOffFlow'); |
| 69 } |
| 70 } |
| 71 |
49 // The singleton instance_ is replaced with a test version of this wrapper | 72 // The singleton instance_ is replaced with a test version of this wrapper |
50 // during testing. | 73 // during testing. |
51 cr.addSingletonGetter(EasyUnlockBrowserProxyImpl); | 74 cr.addSingletonGetter(EasyUnlockBrowserProxyImpl); |
52 | 75 |
53 EasyUnlockBrowserProxyImpl.prototype = { | |
54 /** @override */ | |
55 getEnabledStatus: function() { | |
56 return cr.sendWithPromise('easyUnlockGetEnabledStatus'); | |
57 }, | |
58 | |
59 /** @override */ | |
60 startTurnOnFlow: function() { | |
61 chrome.send('easyUnlockStartTurnOnFlow'); | |
62 }, | |
63 | |
64 /** @override */ | |
65 getTurnOffFlowStatus: function() { | |
66 return cr.sendWithPromise('easyUnlockGetTurnOffFlowStatus'); | |
67 }, | |
68 | |
69 /** @override */ | |
70 startTurnOffFlow: function() { | |
71 chrome.send('easyUnlockStartTurnOffFlow'); | |
72 }, | |
73 | |
74 /** @override */ | |
75 cancelTurnOffFlow: function() { | |
76 chrome.send('easyUnlockCancelTurnOffFlow'); | |
77 }, | |
78 }; | |
79 | |
80 return { | 76 return { |
81 EasyUnlockBrowserProxy: EasyUnlockBrowserProxy, | 77 EasyUnlockBrowserProxy: EasyUnlockBrowserProxy, |
82 EasyUnlockBrowserProxyImpl: EasyUnlockBrowserProxyImpl, | 78 EasyUnlockBrowserProxyImpl: EasyUnlockBrowserProxyImpl, |
83 }; | 79 }; |
84 }); | 80 }); |
OLD | NEW |