Commit 7b783055 authored by amistry's avatar amistry Committed by Commit bot

Add a 'NaCl manager' to manage the state of the NaCl hotword detector plugin.

Based on the hotword extension, but heavily modified.

BUG=397019

Review URL: https://codereview.chromium.org/464213002

Cr-Commit-Position: refs/heads/master@{#291597}
parent 789317e7
......@@ -64,7 +64,9 @@
<include name="IDR_HOTWORD_HELPER_MANAGER_JS" file="hotword_helper/manager.js" type="BINDATA" />
<!-- (Experimental) hotword triggering extension -->
<include name="IDR_HOTWORD_CONSTANTS_JS" file="hotword/constants.js" type="BINDATA" />
<include name="IDR_HOTWORD_MANAGER_JS" file="hotword/manager.js" type="BINDATA" />
<include name="IDR_HOTWORD_NACL_MANAGER_JS" file="hotword/nacl_manager.js" type="BINDATA" />
</if>
<if expr="not is_android">
<include name="IDR_FEEDBACK_DEFAULT_HTML" file="feedback/html/default.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
......
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('hotword.constants', function() {
'use strict';
/**
* Hotword data shared module extension's ID.
* @const {string}
* TODO(amistry): Replace with real shared module ID.
*/
var SHARED_MODULE_ID = 'bepbmhgboaologfdajaanbcjmnhjmhfn';
/**
* Path to shared module data.
* @const {string}
*/
var SHARED_MODULE_ROOT = '_modules/' + SHARED_MODULE_ID;
/**
* Time to wait for expected messages, in milliseconds.
* @enum {number}
*/
var TimeoutMs = {
SHORT: 200,
NORMAL: 500,
LONG: 2000
};
/**
* The URL of the files used by the plugin.
* @enum {string}
*/
var File = {
RECOGNIZER_CONFIG: 'hotword.data',
};
/**
* Errors emitted by the NaClManager.
* @enum {string}
*/
var Error = {
NACL_CRASH: 'nacl_crash',
TIMEOUT: 'timeout',
};
/**
* Event types supported by NaClManager.
* @enum {string}
*/
var Event = {
READY: 'ready',
TRIGGER: 'trigger',
ERROR: 'error',
};
/**
* Messages for communicating with the NaCl recognizer plugin. These must match
* constants in <google3>/hotword_plugin.c
* @enum {string}
*/
var NaClPlugin = {
RESTART: 'r',
SAMPLE_RATE_PREFIX: 'h',
MODEL_PREFIX: 'm',
STOP: 's',
REQUEST_MODEL: 'model',
MODEL_LOADED: 'model_loaded',
READY_FOR_AUDIO: 'audio',
STOPPED: 'stopped',
HOTWORD_DETECTED: 'hotword',
MS_CONFIGURED: 'ms_configured'
};
/**
* The browser UI language.
* @const {string}
*/
var UI_LANGUAGE = (chrome.i18n && chrome.i18n.getUILanguage) ?
chrome.i18n.getUILanguage() : '';
return {
SHARED_MODULE_ID: SHARED_MODULE_ID,
SHARED_MODULE_ROOT: SHARED_MODULE_ROOT,
TimeoutMs: TimeoutMs,
File: File,
Error: Error,
Event: Event,
NaClPlugin: NaClPlugin,
UI_LANGUAGE: UI_LANGUAGE
};
});
......@@ -7,13 +7,21 @@
"manifest_version": 2,
"background": {
"scripts": ["manager.js"],
"scripts": [
"chrome://resources/js/cr.js",
"chrome://resources/js/util.js",
"chrome://resources/js/cr/event_target.js",
"constants.js",
"nacl_manager.js",
"manager.js"
],
"persistent": false
},
"permissions": [
"*://*.google.com/*",
"chrome://newtab/",
"chrome://resources/",
"hotwordPrivate",
"tabs"
],
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment