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 3 // found in the LICENSE file. 4 5 // The <code>chrome.hotwordPrivate</code> API allows extensions to access and 6 // mutate the preference for enabling hotword search. It also provides 7 // information on whether the hotword search is available. This API provides an 8 // event interface to transmit to the extension a signal that the preference fo 9 // hotword search has change. 10 // 11 // For an FYI, visit http://goo.gl/AyHbkH 12 13 [nodoc] namespace hotwordPrivate { 14 15 dictionary StatusDetails { 16 // Whether the hotword preference has been set. 17 boolean enabledSet; 18 19 // If the hotword extension is enabled. Will always be false if |available| 20 // is false. 21 boolean enabled; 22 23 // Whether the hotword extension is available to be enabled 24 boolean available; 25 26 // Whether the sound of "Ok, Google" plus a few seconds before is sent 27 // back to Google. 28 boolean audioLoggingEnabled; 29 30 // Whether experimental hotwording functionality is enabled. Mirrors the 31 // "enable-experimental-hotwording" flag. 32 boolean experimentalHotwordEnabled; 33 34 // Whether always-on hotwording is enabled. 35 boolean alwaysOnEnabled; 36 }; 37 38 dictionary LaunchState { 39 // TODO(kcarattini): Consider adding more variables here, 40 // such as the available state of the hotword service. 41 42 // The mode that the Hotword Audio Verification app was launched in. 43 long launchMode; 44 }; 45 46 47 // The type of the recognized hotword. Right now it only has 'search' but 48 // could be expanded to other types of actions in the future. 49 enum HotwordType { search }; 50 51 callback GenericDoneCallback = void (); 52 callback LaunchStateCallback = void(LaunchState result); 53 callback StatusDetailsCallback = void(StatusDetails result); 54 55 interface Functions { 56 // Sets the current enabled state of hotword search. 57 // True: enable hotword search. False: disable hotword search. 58 static void setEnabled(boolean state, 59 optional GenericDoneCallback callback); 60 61 // Retrieves the current state of hotword search. 62 // The result is put into a StatusDetails object. 63 static void getStatus(StatusDetailsCallback callback); 64 65 // Sets the current enabled state of audio logging in the extension. 66 // True: logging enabled. False: no logging. 67 static void setAudioLoggingEnabled(boolean state, 68 optional GenericDoneCallback callback); 69 70 // Sets the current enabled state of hotword-always-on-search pref. 71 // True: enable hotword always on search. 72 // False: disable hotword always on search. 73 static void setHotwordAlwaysOnSearchEnabled(boolean state, 74 optional GenericDoneCallback callback); 75 76 // Sets the current state of the browser-requested hotword session. 77 static void setHotwordSessionState(boolean started, 78 optional GenericDoneCallback callback); 79 80 // Notifies that a hotword has been recognized in the browser-requested 81 // hotword session. 82 static void notifyHotwordRecognition(HotwordType type, 83 optional GenericDoneCallback callback); 84 85 // Retrieves the state that the Hotword Audio Verification app was 86 // launched in. The result is put into a LaunchState object. 87 static void getLaunchState(LaunchStateCallback callback); 88 }; 89 90 interface Events { 91 // Fired when the hotword search enabled preference is changed. 92 static void onEnabledChanged(); 93 94 // Fired when the browser wants to start a hotword session. 95 static void onHotwordSessionRequested(); 96 97 // Fired when the browser wants to stop the requested hotword session. 98 static void onHotwordSessionStopped(); 99 }; 100 }; 101