diff options
Diffstat (limited to 'chrome/common/extensions/docs/examples/api')
4 files changed, 50 insertions, 39 deletions
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic.zip b/chrome/common/extensions/docs/examples/api/speechInput/basic.zip Binary files differindex 8c30190..e782bd1 100644 --- a/chrome/common/extensions/docs/examples/api/speechInput/basic.zip +++ b/chrome/common/extensions/docs/examples/api/speechInput/basic.zip diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html index 34e7151..713f0c3 100644 --- a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html +++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html @@ -1,40 +1,9 @@ +<!doctype html> <html> -<script> -function setStartIcon() { - chrome.browserAction.setIcon({ path: "start.png" }); -} - -function setStopIcon() { - chrome.browserAction.setIcon({ path: "stop.png" }); -} - -chrome.browserAction.onClicked.addListener(function(tab) { - chrome.experimental.speechInput.isRecording(function(recording) { - if (!recording) { - chrome.experimental.speechInput.start({}, function() { - if (chrome.extension.lastError) { - alert("Couldn't start speech input: " + chrome.extension.lastError.message); - setStartIcon(); - } else { - setStopIcon(); - } - }); - } else { - chrome.experimental.speechInput.stop(function() { - setStartIcon(); - }); - } - }); -}); - -chrome.experimental.speechInput.onError.addListener(function(error) { - alert("Speech input failed: " + error.code); - setStartIcon(); -}); - -chrome.experimental.speechInput.onResult.addListener(function(result) { - alert(result.hypotheses[0].utterance); - setStartIcon(); -}); -</script> + <head> + <title>Speech Input API Background Page</title> + </head> + <body> + <script src="background.js"></script> + </body> </html> diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js new file mode 100644 index 0000000..3093b6c --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js @@ -0,0 +1,41 @@ +// Copyright (c) 2011 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. + +function setStartIcon() { + chrome.browserAction.setIcon({ path: "start.png" }); +} + +function setStopIcon() { + chrome.browserAction.setIcon({ path: "stop.png" }); +} + +chrome.browserAction.onClicked.addListener(function(tab) { + chrome.experimental.speechInput.isRecording(function(recording) { + if (!recording) { + chrome.experimental.speechInput.start({}, function() { + if (chrome.extension.lastError) { + alert("Couldn't start speech input: " + + chrome.extension.lastError.message); + setStartIcon(); + } else { + setStopIcon(); + } + }); + } else { + chrome.experimental.speechInput.stop(function() { + setStartIcon(); + }); + } + }); +}); + +chrome.experimental.speechInput.onError.addListener(function(error) { + alert("Speech input failed: " + error.code); + setStartIcon(); +}); + +chrome.experimental.speechInput.onResult.addListener(function(result) { + alert(result.hypotheses[0].utterance); + setStartIcon(); +}); diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json b/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json index f9a321c..4cc1564 100644 --- a/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json +++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json @@ -12,5 +12,6 @@ "permissions": [ "experimental" - ] + ], + "content_security_policy": "default-src 'self'" } |