summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:51:10 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:51:10 +0000
commit9fa9b2a457b0e0854a5aa958dfa7566c1c463256 (patch)
tree5fc6b7cc0589efdde11051493c161ba49bf55a50 /ui
parentcef49836ac72092482edab557acc1274bb54c5e1 (diff)
downloadchromium_src-9fa9b2a457b0e0854a5aa958dfa7566c1c463256.zip
chromium_src-9fa9b2a457b0e0854a5aa958dfa7566c1c463256.tar.gz
chromium_src-9fa9b2a457b0e0854a5aa958dfa7566c1c463256.tar.bz2
Allow virtual keyboard window to access audio stream and speech api for voice input
BUG=238350 TEST= 1. navigate to chrome://flags 2. turn on virtual keyboard flag 3. login again. focus on any input box (virtual keyboard should show up) 4. press "mic" button, it should turn to green. 5. speak 6. result should be displayed in the input box Review URL: https://chromiumcodereview.appspot.com/14646041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/keyboard/keyboard_controller_proxy.cc15
-rw-r--r--ui/keyboard/keyboard_controller_proxy.h6
-rw-r--r--ui/keyboard/keyboard_controller_unittest.cc3
3 files changed, 22 insertions, 2 deletions
diff --git a/ui/keyboard/keyboard_controller_proxy.cc b/ui/keyboard/keyboard_controller_proxy.cc
index 33e2b71..6f73f27 100644
--- a/ui/keyboard/keyboard_controller_proxy.cc
+++ b/ui/keyboard/keyboard_controller_proxy.cc
@@ -19,7 +19,8 @@ namespace {
class KeyboardContentsDelegate : public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
- KeyboardContentsDelegate() {}
+ KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy)
+ : proxy_(proxy) {}
virtual ~KeyboardContentsDelegate() {}
private:
@@ -33,11 +34,21 @@ class KeyboardContentsDelegate : public content::WebContentsDelegate,
return source;
}
+ // Overridden from content::WebContentsDelegate:
+ virtual void RequestMediaAccessPermission(content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) OVERRIDE {
+ proxy_->RequestAudioInput(web_contents, request, callback);
+ }
+
+
// Overridden from content::WebContentsObserver:
virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE {
delete this;
}
+ keyboard::KeyboardControllerProxy* proxy_;
+
DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
};
@@ -58,7 +69,7 @@ aura::Window* KeyboardControllerProxy::GetKeyboardWindow() {
keyboard_contents_.reset(content::WebContents::Create(
content::WebContents::CreateParams(context,
content::SiteInstance::CreateForURL(context, url))));
- keyboard_contents_->SetDelegate(new KeyboardContentsDelegate);
+ keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this));
SetupWebContents(keyboard_contents_.get());
content::OpenURLParams params(url,
diff --git a/ui/keyboard/keyboard_controller_proxy.h b/ui/keyboard/keyboard_controller_proxy.h
index 09e88cd..e88e52b 100644
--- a/ui/keyboard/keyboard_controller_proxy.h
+++ b/ui/keyboard/keyboard_controller_proxy.h
@@ -6,6 +6,7 @@
#define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
#include "base/memory/scoped_ptr.h"
+#include "content/public/common/media_stream_request.h"
#include "ui/keyboard/keyboard_export.h"
namespace aura {
@@ -40,6 +41,11 @@ class KEYBOARD_EXPORT KeyboardControllerProxy {
// text input context.
virtual ui::InputMethod* GetInputMethod() = 0;
+ // Requests the audio input from microphone for speech input.
+ virtual void RequestAudioInput(content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) = 0;
+
// Shows the container window of the keyboard. The default implementation
// simply shows the container. An overridden implementation can set up
// necessary animation, or delay the visibility change as it desires.
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index 73ac2f8..0f502c4 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -70,6 +70,9 @@ class TestKeyboardControllerProxy : public KeyboardControllerProxy {
virtual ui::InputMethod* GetInputMethod() OVERRIDE {
return input_method_.get();
}
+ virtual void RequestAudioInput(content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) OVERRIDE { return; }
private:
scoped_ptr<aura::Window> window_;