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/chrome_keyboard_ui.h" | 5 #include "chrome/browser/ui/ash/chrome_keyboard_ui.h" |
6 | 6 |
| 7 #include "ash/root_window_controller.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
10 #include "content/public/browser/host_zoom_map.h" | 12 #include "content/public/browser/host_zoom_map.h" |
11 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/site_instance.h" | 15 #include "content/public/browser/site_instance.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
16 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/browser/view_type_utils.h" | 19 #include "extensions/browser/view_type_utils.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 171 |
170 void ChromeKeyboardUI::ShowKeyboardContainer(aura::Window* container) { | 172 void ChromeKeyboardUI::ShowKeyboardContainer(aura::Window* container) { |
171 // TODO(bshe): Implement logic to decide which root window should display | 173 // TODO(bshe): Implement logic to decide which root window should display |
172 // virtual keyboard. http://crbug.com/303429 | 174 // virtual keyboard. http://crbug.com/303429 |
173 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) | 175 if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) |
174 NOTIMPLEMENTED(); | 176 NOTIMPLEMENTED(); |
175 | 177 |
176 KeyboardUIContent::ShowKeyboardContainer(container); | 178 KeyboardUIContent::ShowKeyboardContainer(container); |
177 } | 179 } |
178 | 180 |
| 181 bool ChromeKeyboardUI::ShouldWindowOverscroll(aura::Window* window) const { |
| 182 aura::Window* root_window = window->GetRootWindow(); |
| 183 if (!root_window) |
| 184 return true; |
| 185 |
| 186 if (root_window != GetKeyboardRootWindow()) |
| 187 return false; |
| 188 |
| 189 ash::RootWindowController* root_window_controller = |
| 190 ash::GetRootWindowController(root_window); |
| 191 // Shell ime window container contains virtual keyboard windows and IME |
| 192 // windows(IME windows are created by chrome.app.window.create api). They |
| 193 // should never be overscrolled. |
| 194 return !root_window_controller |
| 195 ->GetContainer(ash::kShellWindowId_ImeWindowParentContainer) |
| 196 ->Contains(window); |
| 197 } |
| 198 |
179 void ChromeKeyboardUI::SetUpdateInputType(ui::TextInputType type) { | 199 void ChromeKeyboardUI::SetUpdateInputType(ui::TextInputType type) { |
180 // TODO(bshe): Need to check the affected window's profile once multi-profile | 200 // TODO(bshe): Need to check the affected window's profile once multi-profile |
181 // is supported. | 201 // is supported. |
182 extensions::EventRouter* router = | 202 extensions::EventRouter* router = |
183 extensions::EventRouter::Get(browser_context()); | 203 extensions::EventRouter::Get(browser_context()); |
184 | 204 |
185 if (!router->HasEventListener( | 205 if (!router->HasEventListener( |
186 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { | 206 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { |
187 return; | 207 return; |
188 } | 208 } |
189 | 209 |
190 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 210 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
191 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); | 211 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); |
192 input_context->SetString("type", | 212 input_context->SetString("type", |
193 virtual_keyboard_private::ToString( | 213 virtual_keyboard_private::ToString( |
194 TextInputTypeToGeneratedInputTypeEnum(type))); | 214 TextInputTypeToGeneratedInputTypeEnum(type))); |
195 event_args->Append(input_context.release()); | 215 event_args->Append(input_context.release()); |
196 | 216 |
197 scoped_ptr<extensions::Event> event(new extensions::Event( | 217 scoped_ptr<extensions::Event> event(new extensions::Event( |
198 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, | 218 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, |
199 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, | 219 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, |
200 event_args.Pass())); | 220 event_args.Pass())); |
201 event->restrict_to_browser_context = browser_context(); | 221 event->restrict_to_browser_context = browser_context(); |
202 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); | 222 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); |
203 } | 223 } |
OLD | NEW |