OLD | NEW |
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" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 void AshKeyboardControllerProxy::ShowKeyboardContainer( | 143 void AshKeyboardControllerProxy::ShowKeyboardContainer( |
144 aura::Window* container) { | 144 aura::Window* container) { |
145 // TODO(bshe): Implement logic to decide which root window should display | 145 // TODO(bshe): Implement logic to decide which root window should display |
146 // virtual keyboard. http://crbug.com/303429 | 146 // virtual keyboard. http://crbug.com/303429 |
147 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) | 147 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) |
148 NOTIMPLEMENTED(); | 148 NOTIMPLEMENTED(); |
149 | 149 |
150 KeyboardControllerProxy::ShowKeyboardContainer(container); | 150 KeyboardControllerProxy::ShowKeyboardContainer(container); |
151 gfx::Rect showing_area = | 151 // GetTextInputClient may return NULL when keyboard-usability-test flag is |
152 ash::DisplayController::GetPrimaryDisplay().work_area(); | 152 // set. |
153 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); | 153 if (GetInputMethod()->GetTextInputClient()) { |
| 154 gfx::Rect showing_area = |
| 155 ash::DisplayController::GetPrimaryDisplay().work_area(); |
| 156 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); |
| 157 } |
154 } | 158 } |
155 | 159 |
156 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { | 160 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { |
157 // TODO(bshe): Need to check the affected window's profile once multi-profile | 161 // TODO(bshe): Need to check the affected window's profile once multi-profile |
158 // is supported. | 162 // is supported. |
159 Profile* profile = ProfileManager::GetDefaultProfile(); | 163 Profile* profile = ProfileManager::GetDefaultProfile(); |
160 extensions::EventRouter* router = | 164 extensions::EventRouter* router = |
161 extensions::ExtensionSystem::Get(profile)->event_router(); | 165 extensions::ExtensionSystem::Get(profile)->event_router(); |
162 | 166 |
163 if (!router->HasEventListener( | 167 if (!router->HasEventListener( |
164 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { | 168 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { |
165 return; | 169 return; |
166 } | 170 } |
167 | 171 |
168 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 172 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
169 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); | 173 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); |
170 input_context->SetString("type", | 174 input_context->SetString("type", |
171 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); | 175 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); |
172 event_args->Append(input_context.release()); | 176 event_args->Append(input_context.release()); |
173 | 177 |
174 scoped_ptr<extensions::Event> event(new extensions::Event( | 178 scoped_ptr<extensions::Event> event(new extensions::Event( |
175 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, | 179 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, |
176 event_args.Pass())); | 180 event_args.Pass())); |
177 event->restrict_to_profile = profile; | 181 event->restrict_to_profile = profile; |
178 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); | 182 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); |
179 } | 183 } |
OLD | NEW |