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

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

Issue 114803004: Polish VK show/hide animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 21 matching lines...) Expand all
32 #include "ui/keyboard/keyboard_controller.h" 32 #include "ui/keyboard/keyboard_controller.h"
33 33
34 namespace virtual_keyboard_private = extensions::api::virtual_keyboard_private; 34 namespace virtual_keyboard_private = extensions::api::virtual_keyboard_private;
35 typedef virtual_keyboard_private::OnTextInputBoxFocused::Context Context; 35 typedef virtual_keyboard_private::OnTextInputBoxFocused::Context Context;
36 36
37 namespace { 37 namespace {
38 38
39 const char* kVirtualKeyboardExtensionID = "mppnpdlheglhdfmldimlhpnegondlapf"; 39 const char* kVirtualKeyboardExtensionID = "mppnpdlheglhdfmldimlhpnegondlapf";
40 40
41 // The virtual keyboard show/hide animation duration. 41 // The virtual keyboard show/hide animation duration.
42 const int kAnimationDurationMs = 1000; 42 const int kAnimationDurationMs = 100;
43 43
44 Context::Type TextInputTypeToGeneratedInputTypeEnum(ui::TextInputType type) { 44 Context::Type TextInputTypeToGeneratedInputTypeEnum(ui::TextInputType type) {
45 switch (type) { 45 switch (type) {
46 case ui::TEXT_INPUT_TYPE_NONE: 46 case ui::TEXT_INPUT_TYPE_NONE:
47 return Context::TYPE_NONE; 47 return Context::TYPE_NONE;
48 case ui::TEXT_INPUT_TYPE_PASSWORD: 48 case ui::TEXT_INPUT_TYPE_PASSWORD:
49 return Context::TYPE_PASSWORD; 49 return Context::TYPE_PASSWORD;
50 case ui::TEXT_INPUT_TYPE_EMAIL: 50 case ui::TEXT_INPUT_TYPE_EMAIL:
51 return Context::TYPE_EMAIL; 51 return Context::TYPE_EMAIL;
52 case ui::TEXT_INPUT_TYPE_NUMBER: 52 case ui::TEXT_INPUT_TYPE_NUMBER:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 { 167 {
168 // Scope the following animation settings as we don't want to animate 168 // Scope the following animation settings as we don't want to animate
169 // visibility change that triggered by a call to the base class function 169 // visibility change that triggered by a call to the base class function
170 // ShowKeyboardContainer with these settings. The container should become 170 // ShowKeyboardContainer with these settings. The container should become
171 // visible immediately. 171 // visible immediately.
172 ui::ScopedLayerAnimationSettings settings(container_animator); 172 ui::ScopedLayerAnimationSettings settings(container_animator);
173 settings.SetTweenType(gfx::Tween::EASE_IN); 173 settings.SetTweenType(gfx::Tween::EASE_IN);
174 settings.SetTransitionDuration( 174 settings.SetTransitionDuration(
175 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); 175 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
176 container->SetTransform(gfx::Transform()); 176 container->SetTransform(gfx::Transform());
177 container->layer()->SetOpacity(1.0);
177 } 178 }
178 179
179 // TODO(bshe): Add animation observer and do the workspace resizing after 180 // TODO(bshe): Add animation observer and do the workspace resizing after
180 // animation finished. 181 // animation finished.
181 KeyboardControllerProxy::ShowKeyboardContainer(container); 182 KeyboardControllerProxy::ShowKeyboardContainer(container);
182 // GetTextInputClient may return NULL when keyboard-usability-experiment flag 183 // GetTextInputClient may return NULL when keyboard-usability-experiment flag
183 // is set. 184 // is set.
184 if (GetInputMethod()->GetTextInputClient()) { 185 if (GetInputMethod()->GetTextInputClient()) {
185 gfx::Rect showing_area = 186 gfx::Rect showing_area =
186 ash::DisplayController::GetPrimaryDisplay().work_area(); 187 ash::DisplayController::GetPrimaryDisplay().work_area();
187 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); 188 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area);
188 } 189 }
189 } 190 }
190 191
191 void AshKeyboardControllerProxy::HideKeyboardContainer( 192 void AshKeyboardControllerProxy::HideKeyboardContainer(
192 aura::Window* container) { 193 aura::Window* container) {
193 // The following animation settings should persist within this function scope. 194 // The following animation settings should persist within this function scope.
194 // Otherwise, a call to base class function HideKeyboardContainer will hide 195 // Otherwise, a call to base class function HideKeyboardContainer will hide
195 // the container immediately. 196 // the container immediately.
196 ui::ScopedLayerAnimationSettings 197 ui::ScopedLayerAnimationSettings
197 settings(container->layer()->GetAnimator()); 198 settings(container->layer()->GetAnimator());
198 settings.SetTweenType(gfx::Tween::EASE_OUT); 199 settings.SetTweenType(gfx::Tween::EASE_OUT);
199 settings.SetTransitionDuration( 200 settings.SetTransitionDuration(
200 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); 201 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
201 gfx::Transform transform; 202 gfx::Transform transform;
202 transform.Translate(0, GetKeyboardWindow()->bounds().height()); 203 transform.Translate(0, GetKeyboardWindow()->bounds().height());
203 container->SetTransform(transform); 204 container->SetTransform(transform);
205 container->layer()->SetOpacity(0.0);
204 KeyboardControllerProxy::HideKeyboardContainer(container); 206 KeyboardControllerProxy::HideKeyboardContainer(container);
205 } 207 }
206 208
207 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { 209 void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
208 // TODO(bshe): Need to check the affected window's profile once multi-profile 210 // TODO(bshe): Need to check the affected window's profile once multi-profile
209 // is supported. 211 // is supported.
210 Profile* profile = ProfileManager::GetDefaultProfile(); 212 Profile* profile = ProfileManager::GetDefaultProfile();
211 extensions::EventRouter* router = 213 extensions::EventRouter* router =
212 extensions::ExtensionSystem::Get(profile)->event_router(); 214 extensions::ExtensionSystem::Get(profile)->event_router();
213 215
214 if (!router->HasEventListener( 216 if (!router->HasEventListener(
215 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { 217 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) {
216 return; 218 return;
217 } 219 }
218 220
219 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 221 scoped_ptr<base::ListValue> event_args(new base::ListValue());
220 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); 222 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue());
221 input_context->SetString("type", 223 input_context->SetString("type",
222 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type))); 224 Context::ToString(TextInputTypeToGeneratedInputTypeEnum(type)));
223 event_args->Append(input_context.release()); 225 event_args->Append(input_context.release());
224 226
225 scoped_ptr<extensions::Event> event(new extensions::Event( 227 scoped_ptr<extensions::Event> event(new extensions::Event(
226 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, 228 virtual_keyboard_private::OnTextInputBoxFocused::kEventName,
227 event_args.Pass())); 229 event_args.Pass()));
228 event->restrict_to_browser_context = profile; 230 event->restrict_to_browser_context = profile;
229 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass()); 231 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, event.Pass());
230 } 232 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698