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/event_names.h" | 9 #include "chrome/browser/extensions/event_names.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 { | 166 { |
167 // Scope the following animation settings as we don't want to animate | 167 // Scope the following animation settings as we don't want to animate |
168 // visibility change that triggered by a call to the base class function | 168 // visibility change that triggered by a call to the base class function |
169 // ShowKeyboardContainer with these settings. The container should become | 169 // ShowKeyboardContainer with these settings. The container should become |
170 // visible immediately. | 170 // visible immediately. |
171 ui::ScopedLayerAnimationSettings settings(container_animator); | 171 ui::ScopedLayerAnimationSettings settings(container_animator); |
172 settings.SetTweenType(gfx::Tween::EASE_IN); | 172 settings.SetTweenType(gfx::Tween::EASE_IN); |
173 settings.SetTransitionDuration( | 173 settings.SetTransitionDuration( |
174 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 174 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
175 container->SetTransform(gfx::Transform()); | 175 container->SetTransform(gfx::Transform()); |
176 container->layer()->SetOpacity(1.0); | |
177 } | 176 } |
178 | 177 |
179 // TODO(bshe): Add animation observer and do the workspace resizing after | 178 // TODO(bshe): Add animation observer and do the workspace resizing after |
180 // animation finished. | 179 // animation finished. |
181 KeyboardControllerProxy::ShowKeyboardContainer(container); | 180 KeyboardControllerProxy::ShowKeyboardContainer(container); |
182 // GetTextInputClient may return NULL when keyboard-usability-experiment flag | 181 // GetTextInputClient may return NULL when keyboard-usability-experiment flag |
183 // is set. | 182 // is set. |
184 if (GetInputMethod()->GetTextInputClient()) { | 183 if (GetInputMethod()->GetTextInputClient()) { |
185 gfx::Rect showing_area = | 184 gfx::Rect showing_area = |
186 ash::DisplayController::GetPrimaryDisplay().work_area(); | 185 ash::DisplayController::GetPrimaryDisplay().work_area(); |
187 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); | 186 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); |
188 } | 187 } |
189 } | 188 } |
190 | 189 |
191 void AshKeyboardControllerProxy::HideKeyboardContainer( | 190 void AshKeyboardControllerProxy::HideKeyboardContainer( |
192 aura::Window* container) { | 191 aura::Window* container) { |
193 // The following animation settings should persist within this function scope. | 192 // The following animation settings should persist within this function scope. |
194 // Otherwise, a call to base class function HideKeyboardContainer will hide | 193 // Otherwise, a call to base class function HideKeyboardContainer will hide |
195 // the container immediately. | 194 // the container immediately. |
196 ui::ScopedLayerAnimationSettings | 195 ui::ScopedLayerAnimationSettings |
197 settings(container->layer()->GetAnimator()); | 196 settings(container->layer()->GetAnimator()); |
198 settings.SetTweenType(gfx::Tween::EASE_OUT); | 197 settings.SetTweenType(gfx::Tween::EASE_OUT); |
199 settings.SetTransitionDuration( | 198 settings.SetTransitionDuration( |
200 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 199 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
201 gfx::Transform transform; | 200 gfx::Transform transform; |
202 transform.Translate(0, GetKeyboardWindow()->bounds().height()); | 201 transform.Translate(0, GetKeyboardWindow()->bounds().height()); |
203 container->SetTransform(transform); | 202 container->SetTransform(transform); |
204 container->layer()->SetOpacity(0.0); | |
205 KeyboardControllerProxy::HideKeyboardContainer(container); | 203 KeyboardControllerProxy::HideKeyboardContainer(container); |
206 } | 204 } |
207 | 205 |
208 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { | 206 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { |
209 // TODO(bshe): Need to check the affected window's profile once multi-profile | 207 // TODO(bshe): Need to check the affected window's profile once multi-profile |
210 // is supported. | 208 // is supported. |
211 content::BrowserContext* context = GetBrowserContext(); | 209 content::BrowserContext* context = GetBrowserContext(); |
212 extensions::EventRouter* router = | 210 extensions::EventRouter* router = |
213 extensions::ExtensionSystem::GetForBrowserContext(context)-> | 211 extensions::ExtensionSystem::GetForBrowserContext(context)-> |
214 event_router(); | 212 event_router(); |
215 | 213 |
216 if (!router->HasEventListener( | 214 if (!router->HasEventListener( |
217 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { | 215 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { |
218 return; | 216 return; |
219 } | 217 } |
220 | 218 |
221 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 219 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
222 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); | 220 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); |
223 input_context->SetString("type", | 221 input_context->SetString("type", |
224 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); | 222 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); |
225 event_args->Append(input_context.release()); | 223 event_args->Append(input_context.release()); |
226 | 224 |
227 scoped_ptr<extensions::Event> event(new extensions::Event( | 225 scoped_ptr<extensions::Event> event(new extensions::Event( |
228 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, | 226 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, |
229 event_args.Pass())); | 227 event_args.Pass())); |
230 event->restrict_to_browser_context = context; | 228 event->restrict_to_browser_context = context; |
231 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); | 229 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); |
232 } | 230 } |
OLD | NEW |