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

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

Issue 276483002: Fix calculation of usable area of screen when VK is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test Created 6 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/chrome_extension_web_contents_observer.h" 9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/extensions/api/virtual_keyboard_private.h" 14 #include "chrome/common/extensions/api/virtual_keyboard_private.h"
15 #include "content/public/browser/site_instance.h" 15 #include "content/public/browser/site_instance.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "extensions/browser/event_router.h" 17 #include "extensions/browser/event_router.h"
18 #include "extensions/browser/extension_function_dispatcher.h" 18 #include "extensions/browser/extension_function_dispatcher.h"
19 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/view_type_utils.h" 20 #include "extensions/browser/view_type_utils.h"
21 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
22 #include "extensions/common/extension_messages.h" 22 #include "extensions/common/extension_messages.h"
23 #include "ipc/ipc_message_macros.h" 23 #include "ipc/ipc_message_macros.h"
24 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
26 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
27 #include "ui/base/ime/input_method.h"
28 #include "ui/base/ime/text_input_client.h"
29 #include "ui/compositor/scoped_layer_animation_settings.h" 27 #include "ui/compositor/scoped_layer_animation_settings.h"
30 #include "ui/keyboard/keyboard_controller.h" 28 #include "ui/keyboard/keyboard_controller.h"
31 29
32 namespace virtual_keyboard_private = extensions::api::virtual_keyboard_private; 30 namespace virtual_keyboard_private = extensions::api::virtual_keyboard_private;
33 typedef virtual_keyboard_private::OnTextInputBoxFocused::Context Context; 31 typedef virtual_keyboard_private::OnTextInputBoxFocused::Context Context;
34 32
35 namespace { 33 namespace {
36 34
37 const char* kVirtualKeyboardExtensionID = "mppnpdlheglhdfmldimlhpnegondlapf"; 35 const char* kVirtualKeyboardExtensionID = "mppnpdlheglhdfmldimlhpnegondlapf";
38 36
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void AshKeyboardControllerProxy::ShowKeyboardContainer( 140 void AshKeyboardControllerProxy::ShowKeyboardContainer(
143 aura::Window* container) { 141 aura::Window* container) {
144 // TODO(bshe): Implement logic to decide which root window should display 142 // TODO(bshe): Implement logic to decide which root window should display
145 // virtual keyboard. http://crbug.com/303429 143 // virtual keyboard. http://crbug.com/303429
146 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) 144 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow())
147 NOTIMPLEMENTED(); 145 NOTIMPLEMENTED();
148 146
149 KeyboardControllerProxy::ShowKeyboardContainer(container); 147 KeyboardControllerProxy::ShowKeyboardContainer(container);
150 } 148 }
151 149
152 void AshKeyboardControllerProxy::EnsureCaretInWorkArea() {
153 // GetTextInputClient may return NULL when keyboard-usability-experiment
154 // flag is set.
155 if (GetInputMethod()->GetTextInputClient()) {
156 gfx::Rect showing_area =
157 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area();
158 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area);
159 }
160 }
161
162 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { 150 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
163 // TODO(bshe): Need to check the affected window's profile once multi-profile 151 // TODO(bshe): Need to check the affected window's profile once multi-profile
164 // is supported. 152 // is supported.
165 content::BrowserContext* context = GetBrowserContext(); 153 content::BrowserContext* context = GetBrowserContext();
166 extensions::EventRouter* router = extensions::EventRouter::Get(context); 154 extensions::EventRouter* router = extensions::EventRouter::Get(context);
167 155
168 if (!router->HasEventListener( 156 if (!router->HasEventListener(
169 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { 157 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) {
170 return; 158 return;
171 } 159 }
172 160
173 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 161 scoped_ptr<base::ListValue> event_args(new base::ListValue());
174 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); 162 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue());
175 input_context->SetString("type", 163 input_context->SetString("type",
176 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); 164 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type)));
177 event_args->Append(input_context.release()); 165 event_args->Append(input_context.release());
178 166
179 scoped_ptr<extensions::Event> event(new extensions::Event( 167 scoped_ptr<extensions::Event> event(new extensions::Event(
180 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, 168 virtual_keyboard_private::OnTextInputBoxFocused::kEventName,
181 event_args.Pass())); 169 event_args.Pass()));
182 event->restrict_to_browser_context = context; 170 event->restrict_to_browser_context = context;
183 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); 171 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass());
184 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698