Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1459)

Side by Side Diff: chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc

Issue 14646041: Allow virtual keyboard window to access audio stream and speech api for voice input (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add view type Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" 5 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" 9 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
10 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/extensions/extension_messages.h" 15 #include "chrome/common/extensions/extension_messages.h"
13 #include "content/public/browser/site_instance.h" 16 #include "content/public/browser/site_instance.h"
14 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_view.h" 18 #include "content/public/browser/web_contents_view.h"
19 #include "extensions/browser/view_type_utils.h"
20 #include "extensions/common/constants.h"
16 #include "ipc/ipc_message_macros.h" 21 #include "ipc/ipc_message_macros.h"
17 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
20 #include "ui/base/ime/input_method.h" 25 #include "ui/base/ime/input_method.h"
21 #include "ui/base/ime/text_input_client.h" 26 #include "ui/base/ime/text_input_client.h"
22 #include "ui/keyboard/keyboard_controller.h" 27 #include "ui/keyboard/keyboard_controller.h"
23 28
24 AshKeyboardControllerProxy::AshKeyboardControllerProxy() {} 29 AshKeyboardControllerProxy::AshKeyboardControllerProxy() {}
25 30
26 AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {} 31 AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {}
27 32
28 void AshKeyboardControllerProxy::OnRequest( 33 void AshKeyboardControllerProxy::OnRequest(
29 const ExtensionHostMsg_Request_Params& params) { 34 const ExtensionHostMsg_Request_Params& params) {
30 extension_function_dispatcher_->Dispatch( 35 extension_function_dispatcher_->Dispatch(
31 params, web_contents()->GetRenderViewHost()); 36 params, web_contents()->GetRenderViewHost());
32 } 37 }
33 38
34 content::BrowserContext* AshKeyboardControllerProxy::GetBrowserContext() { 39 content::BrowserContext* AshKeyboardControllerProxy::GetBrowserContext() {
35 return ProfileManager::GetDefaultProfile(); 40 return ProfileManager::GetDefaultProfile();
36 } 41 }
37 42
38 ui::InputMethod* AshKeyboardControllerProxy::GetInputMethod() { 43 ui::InputMethod* AshKeyboardControllerProxy::GetInputMethod() {
39 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); 44 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
40 DCHECK(root_window); 45 DCHECK(root_window);
41 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 46 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
42 } 47 }
43 48
49 void AshKeyboardControllerProxy::RequestAudioInput(
50 content::WebContents* web_contents,
51 const content::MediaStreamRequest& request,
52 const content::MediaResponseCallback& callback) {
53 const extensions::Extension* extension = NULL;
54 GURL origin(request.security_origin);
55 if (origin.SchemeIs(extensions::kExtensionScheme)) {
56 ExtensionService* extensions_service =
57 extensions::ExtensionSystem::Get(ProfileManager::GetDefaultProfile())->
58 extension_service();
59 extension = extensions_service->extensions()->GetByID(origin.host());
60 DCHECK(extension);
61 }
62
63 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
64 web_contents, request, callback, extension);
65 }
66
44 void AshKeyboardControllerProxy::SetupWebContents( 67 void AshKeyboardControllerProxy::SetupWebContents(
45 content::WebContents* contents) { 68 content::WebContents* contents) {
46 extension_function_dispatcher_.reset( 69 extension_function_dispatcher_.reset(
47 new ExtensionFunctionDispatcher(ProfileManager::GetDefaultProfile(), 70 new ExtensionFunctionDispatcher(ProfileManager::GetDefaultProfile(),
48 this)); 71 this));
72 extensions::SetViewType(contents, extensions::VIEW_TYPE_VIRTUAL_KEYBOARD);
49 Observe(contents); 73 Observe(contents);
50 } 74 }
51 75
52 extensions::WindowController* 76 extensions::WindowController*
53 AshKeyboardControllerProxy::GetExtensionWindowController() const { 77 AshKeyboardControllerProxy::GetExtensionWindowController() const {
54 // The keyboard doesn't have a window controller. 78 // The keyboard doesn't have a window controller.
55 return NULL; 79 return NULL;
56 } 80 }
57 81
58 content::WebContents* 82 content::WebContents*
(...skipping 11 matching lines...) Expand all
70 return handled; 94 return handled;
71 } 95 }
72 96
73 void AshKeyboardControllerProxy::ShowKeyboardContainer( 97 void AshKeyboardControllerProxy::ShowKeyboardContainer(
74 aura::Window* container) { 98 aura::Window* container) {
75 KeyboardControllerProxy::ShowKeyboardContainer(container); 99 KeyboardControllerProxy::ShowKeyboardContainer(container);
76 gfx::Rect showing_area = 100 gfx::Rect showing_area =
77 ash::DisplayController::GetPrimaryDisplay().work_area(); 101 ash::DisplayController::GetPrimaryDisplay().work_area();
78 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); 102 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area);
79 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698