OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <iostream> | 9 #include <iostream> |
10 #include <string> | 10 #include <string> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 | 85 |
86 bool DebugShortcutsEnabled() { | 86 bool DebugShortcutsEnabled() { |
87 #if defined(NDEBUG) | 87 #if defined(NDEBUG) |
88 return CommandLine::ForCurrentProcess()->HasSwitch( | 88 return CommandLine::ForCurrentProcess()->HasSwitch( |
89 switches::kAshDebugShortcuts); | 89 switches::kAshDebugShortcuts); |
90 #else | 90 #else |
91 return true; | 91 return true; |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 void HandleAddRemoveDisplay() { | |
96 content::RecordAction( | |
97 content::UserMetricsAction("Accel_Add_Remove_Display")); | |
98 Shell::GetInstance()->display_manager()->AddRemoveDisplay(); | |
99 } | |
100 | |
95 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { | 101 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
96 Shell* shell = Shell::GetInstance(); | 102 Shell* shell = Shell::GetInstance(); |
97 | 103 |
98 if (accelerator.key_code() == ui::VKEY_TAB) | 104 if (accelerator.key_code() == ui::VKEY_TAB) |
99 content::RecordAction(content::UserMetricsAction("Accel_PrevWindow_Tab")); | 105 content::RecordAction(content::UserMetricsAction("Accel_PrevWindow_Tab")); |
100 | 106 |
101 if (switches::UseOverviewMode()) { | 107 if (switches::UseOverviewMode()) { |
102 shell->window_selector_controller()->HandleCycleWindow( | 108 shell->window_selector_controller()->HandleCycleWindow( |
103 WindowSelector::BACKWARD); | 109 WindowSelector::BACKWARD); |
104 return; | 110 return; |
(...skipping 25 matching lines...) Expand all Loading... | |
130 if (switches::UseOverviewMode()) { | 136 if (switches::UseOverviewMode()) { |
131 content::RecordAction(content::UserMetricsAction("Accel_Overview_F5")); | 137 content::RecordAction(content::UserMetricsAction("Accel_Overview_F5")); |
132 shell->window_selector_controller()->ToggleOverview(); | 138 shell->window_selector_controller()->ToggleOverview(); |
133 return; | 139 return; |
134 } | 140 } |
135 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) | 141 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) |
136 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_F5")); | 142 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_F5")); |
137 shell->window_cycle_controller()->HandleLinearCycleWindow(); | 143 shell->window_cycle_controller()->HandleLinearCycleWindow(); |
138 } | 144 } |
139 | 145 |
146 bool HandleDisableCapsLock(ui::KeyboardCode key_code, | |
147 ui::EventType previous_event_type, | |
148 ui::KeyboardCode previous_key_code) { | |
149 Shell* shell = Shell::GetInstance(); | |
150 | |
151 if (previous_event_type == ui::ET_KEY_RELEASED || | |
152 (previous_key_code != ui::VKEY_LSHIFT && | |
153 previous_key_code != ui::VKEY_SHIFT && | |
154 previous_key_code != ui::VKEY_RSHIFT)) { | |
155 // If something else was pressed between the Shift key being pressed | |
156 // and released, then ignore the release of the Shift key. | |
157 return false; | |
158 } | |
159 content::RecordAction( | |
160 content::UserMetricsAction("Accel_Disable_Caps_Lock")); | |
161 if (shell->caps_lock_delegate()->IsCapsLockEnabled()) { | |
162 shell->caps_lock_delegate()->SetCapsLockEnabled(false); | |
163 return true; | |
164 } | |
165 return false; | |
166 } | |
167 | |
140 bool HandleAccessibleFocusCycle(bool reverse) { | 168 bool HandleAccessibleFocusCycle(bool reverse) { |
169 if (reverse) { | |
170 content::RecordAction( | |
171 content::UserMetricsAction("Accel_Accessible_Focus_Previous")); | |
172 } else { | |
173 content::RecordAction( | |
174 content::UserMetricsAction("Accel_Accessible_Focus_Next")); | |
175 } | |
176 | |
141 if (!Shell::GetInstance()->accessibility_delegate()-> | 177 if (!Shell::GetInstance()->accessibility_delegate()-> |
142 IsSpokenFeedbackEnabled()) { | 178 IsSpokenFeedbackEnabled()) { |
143 return false; | 179 return false; |
144 } | 180 } |
145 aura::Window* active_window = ash::wm::GetActiveWindow(); | 181 aura::Window* active_window = ash::wm::GetActiveWindow(); |
146 if (!active_window) | 182 if (!active_window) |
147 return false; | 183 return false; |
148 views::Widget* widget = | 184 views::Widget* widget = |
149 views::Widget::GetWidgetForNativeWindow(active_window); | 185 views::Widget::GetWidgetForNativeWindow(active_window); |
150 if (!widget) | 186 if (!widget) |
151 return false; | 187 return false; |
152 views::FocusManager* focus_manager = widget->GetFocusManager(); | 188 views::FocusManager* focus_manager = widget->GetFocusManager(); |
153 if (!focus_manager) | 189 if (!focus_manager) |
154 return false; | 190 return false; |
155 views::View* view = focus_manager->GetFocusedView(); | 191 views::View* view = focus_manager->GetFocusedView(); |
156 if (!view) | 192 if (!view) |
157 return false; | 193 return false; |
158 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) | 194 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) |
159 return false; | 195 return false; |
160 | 196 |
161 focus_manager->AdvanceFocus(reverse); | 197 focus_manager->AdvanceFocus(reverse); |
162 return true; | 198 return true; |
163 } | 199 } |
164 | 200 |
201 void HandleShowKeyboardOverlay() { | |
202 content::RecordAction( | |
203 content::UserMetricsAction("Accel_Show_Keyboard_Overlay")); | |
204 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); | |
205 } | |
206 | |
207 void HandleShowMessageCenterBubble() { | |
208 content::RecordAction( | |
209 content::UserMetricsAction("Accel_Show_Message_Center_Bubble")); | |
210 internal::RootWindowController* controller = | |
211 internal::RootWindowController::ForTargetRootWindow(); | |
212 internal::StatusAreaWidget* status_area_widget = | |
213 controller->shelf()->status_area_widget(); | |
214 if (status_area_widget) { | |
215 WebNotificationTray* notification_tray = | |
216 status_area_widget->web_notification_tray(); | |
217 if (notification_tray->visible()) | |
218 notification_tray->ShowMessageCenterBubble(); | |
219 } | |
220 } | |
221 | |
222 bool HandleShowOak() { | |
223 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
224 switches::kAshEnableOak)) { | |
225 oak::ShowOakWindowWithContext(Shell::GetPrimaryRootWindow()); | |
226 return true; | |
227 } | |
228 return false; | |
229 } | |
230 | |
231 bool HandleShowSystemTrayBubble() { | |
232 content::RecordAction( | |
233 content::UserMetricsAction("Accel_Show_System_Tray_Bubble")); | |
234 internal::RootWindowController* controller = | |
235 internal::RootWindowController::ForTargetRootWindow(); | |
236 if (!controller->GetSystemTray()->HasSystemBubble()) { | |
237 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | |
238 return true; | |
239 } | |
240 return false; | |
241 } | |
242 | |
243 void HandleShowTaskManager() { | |
244 content::RecordAction( | |
245 content::UserMetricsAction("Accel_Show_Task_Manager")); | |
246 Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); | |
247 } | |
248 | |
165 void HandleSilenceSpokenFeedback() { | 249 void HandleSilenceSpokenFeedback() { |
250 content::RecordAction( | |
251 content::UserMetricsAction("Accel_Silence_Spoken_Feedback")); | |
252 | |
166 AccessibilityDelegate* delegate = | 253 AccessibilityDelegate* delegate = |
167 Shell::GetInstance()->accessibility_delegate(); | 254 Shell::GetInstance()->accessibility_delegate(); |
168 if (!delegate->IsSpokenFeedbackEnabled()) | 255 if (!delegate->IsSpokenFeedbackEnabled()) |
169 return; | 256 return; |
170 delegate->SilenceSpokenFeedback(); | 257 delegate->SilenceSpokenFeedback(); |
171 } | 258 } |
172 | 259 |
173 #if defined(OS_CHROMEOS) | 260 #if defined(OS_CHROMEOS) |
174 bool HandleLock() { | 261 bool HandleLock(ui::KeyboardCode key_code) { |
175 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 262 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
176 return true; | 263 return true; |
177 } | 264 } |
178 | 265 |
179 bool HandleFileManager() { | 266 bool HandleFileManager() { |
267 content::RecordAction( | |
268 content::UserMetricsAction("Accel_Open_File_Manager")); | |
269 | |
180 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); | 270 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); |
181 return true; | 271 return true; |
182 } | 272 } |
183 | 273 |
274 bool HandleFocusLauncher() { | |
275 Shell* shell = Shell::GetInstance(); | |
276 content::RecordAction(content::UserMetricsAction("Accel_Focus_Launcher")); | |
277 return shell->focus_cycler()->FocusWidget( | |
278 Launcher::ForPrimaryDisplay()->shelf_widget()); | |
279 } | |
280 | |
184 bool HandleCrosh() { | 281 bool HandleCrosh() { |
282 content::RecordAction( | |
283 content::UserMetricsAction("Accel_Open_Crosh")); | |
284 | |
185 Shell::GetInstance()->new_window_delegate()->OpenCrosh(); | 285 Shell::GetInstance()->new_window_delegate()->OpenCrosh(); |
186 return true; | 286 return true; |
187 } | 287 } |
188 | 288 |
289 void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) { | |
290 content::RecordAction( | |
291 content::UserMetricsAction("Accel_Take_Partial_Screenshot")); | |
292 if (screenshot_delegate) { | |
293 ash::PartialScreenshotView::StartPartialScreenshot( | |
294 screenshot_delegate); | |
295 } | |
296 } | |
297 | |
298 void HandleTakeScreenshot(ScreenshotDelegate* screenshot_delegate) { | |
299 content::RecordAction( | |
300 content::UserMetricsAction("Accel_Take_Screenshot")); | |
301 if (screenshot_delegate && | |
302 screenshot_delegate->CanTakeScreenshot()) { | |
303 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); | |
304 } | |
305 } | |
306 | |
307 bool HandleToggleAppList(ui::KeyboardCode key_code, | |
308 ui::EventType previous_event_type, | |
309 ui::KeyboardCode previous_key_code, | |
310 const ui::Accelerator& accelerator) { | |
311 // If something else was pressed between the Search key (LWIN) | |
312 // being pressed and released, then ignore the release of the | |
313 // Search key. | |
314 if (key_code == ui::VKEY_LWIN && | |
315 (previous_event_type == ui::ET_KEY_RELEASED || | |
316 previous_key_code != ui::VKEY_LWIN)) | |
317 return false; | |
318 if (key_code == ui::VKEY_LWIN) | |
319 content::RecordAction(content::UserMetricsAction("Accel_Search_LWin")); | |
320 // When spoken feedback is enabled, we should neither toggle the list nor | |
321 // consume the key since Search+Shift is one of the shortcuts the a11y | |
322 // feature uses. crbug.com/132296 | |
323 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); | |
324 if (Shell::GetInstance()->accessibility_delegate()-> | |
325 IsSpokenFeedbackEnabled()) | |
326 return false; | |
327 ash::Shell::GetInstance()->ToggleAppList(NULL); | |
328 return true; | |
329 } | |
330 | |
331 bool HandleToggleCapsLock(ui::KeyboardCode key_code, | |
332 ui::EventType previous_event_type, | |
333 ui::KeyboardCode previous_key_code) { | |
334 Shell* shell = Shell::GetInstance(); | |
335 if (key_code == ui::VKEY_LWIN) { | |
336 // If something else was pressed between the Search key (LWIN) | |
337 // being pressed and released, then ignore the release of the | |
338 // Search key. | |
339 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495 | |
340 if (previous_event_type == ui::ET_KEY_RELEASED || | |
341 previous_key_code != ui::VKEY_LWIN) | |
342 return false; | |
343 } | |
344 content::RecordAction( | |
345 content::UserMetricsAction("Accel_Toggle_Caps_Lock")); | |
346 shell->caps_lock_delegate()->ToggleCapsLock(); | |
347 return true; | |
348 } | |
349 | |
350 void HandleToggleMirrorMode() { | |
351 content::RecordAction( | |
352 content::UserMetricsAction("Accel_Toggle_Mirror_Mode")); | |
353 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); | |
354 } | |
355 | |
189 bool HandleToggleSpokenFeedback() { | 356 bool HandleToggleSpokenFeedback() { |
357 content::RecordAction( | |
358 content::UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | |
359 | |
190 Shell::GetInstance()->accessibility_delegate()-> | 360 Shell::GetInstance()->accessibility_delegate()-> |
191 ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW); | 361 ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW); |
192 return true; | 362 return true; |
193 } | 363 } |
194 | 364 |
195 bool SwitchToNextUser() { | 365 bool HandleTouchHudClear() { |
366 internal::RootWindowController* controller = | |
367 internal::RootWindowController::ForTargetRootWindow(); | |
368 if (controller->touch_hud_debug()) { | |
369 controller->touch_hud_debug()->Clear(); | |
370 return true; | |
371 } | |
372 return false; | |
373 } | |
374 | |
375 bool HandleTouchHudModeChange() { | |
376 internal::RootWindowController* controller = | |
377 internal::RootWindowController::ForTargetRootWindow(); | |
378 if (controller->touch_hud_debug()) { | |
379 controller->touch_hud_debug()->ChangeToNextMode(); | |
380 return true; | |
381 } | |
382 return false; | |
383 } | |
384 | |
385 void HandleTouchHudProjectToggle() { | |
386 content::RecordAction( | |
387 content::UserMetricsAction("Accel_Touch_Hud_Clear")); | |
388 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); | |
389 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); | |
390 } | |
391 | |
392 bool HandleSwitchToNextUser() { | |
393 content::RecordAction( | |
394 content::UserMetricsAction("Accel_Switch_To_Next_User")); | |
395 | |
196 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) | 396 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) |
197 return false; | 397 return false; |
198 ash::SessionStateDelegate* delegate = | 398 ash::SessionStateDelegate* delegate = |
199 ash::Shell::GetInstance()->session_state_delegate(); | 399 ash::Shell::GetInstance()->session_state_delegate(); |
200 if (delegate->NumberOfLoggedInUsers() <= 1) | 400 if (delegate->NumberOfLoggedInUsers() <= 1) |
201 return false; | 401 return false; |
202 MultiProfileUMA::RecordSwitchActiveUser( | 402 MultiProfileUMA::RecordSwitchActiveUser( |
203 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); | 403 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); |
204 delegate->SwitchActiveUserToNext(); | 404 delegate->SwitchActiveUserToNext(); |
205 return true; | 405 return true; |
206 } | 406 } |
207 | 407 |
208 #endif // defined(OS_CHROMEOS) | 408 #endif // defined(OS_CHROMEOS) |
209 | 409 |
210 bool HandleRotatePaneFocus(Shell::Direction direction) { | 410 bool HandleRotatePaneFocus(Shell::Direction direction) { |
211 Shell* shell = Shell::GetInstance(); | 411 Shell* shell = Shell::GetInstance(); |
212 switch (direction) { | 412 switch (direction) { |
213 case Shell::FORWARD: | 413 // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE. |
414 case Shell::FORWARD: { | |
415 content::RecordAction( | |
416 content::UserMetricsAction("Accel_Focus_Next_Pane")); | |
214 shell->focus_cycler()->RotateFocus(internal::FocusCycler::FORWARD); | 417 shell->focus_cycler()->RotateFocus(internal::FocusCycler::FORWARD); |
215 break; | 418 break; |
216 case Shell::BACKWARD: | 419 } |
420 case Shell::BACKWARD: { | |
421 content::RecordAction( | |
422 content::UserMetricsAction("Accel_Focus_Previous_Pane")); | |
217 shell->focus_cycler()->RotateFocus(internal::FocusCycler::BACKWARD); | 423 shell->focus_cycler()->RotateFocus(internal::FocusCycler::BACKWARD); |
218 break; | 424 break; |
425 } | |
219 } | 426 } |
220 return true; | 427 return true; |
221 } | 428 } |
222 | 429 |
223 // Rotate the active window. | 430 // Rotate the active window. |
224 bool HandleRotateActiveWindow() { | 431 bool HandleRotateActiveWindow() { |
432 content::RecordAction( | |
433 content::UserMetricsAction("Accel_Rotate_Window")); | |
225 aura::Window* active_window = wm::GetActiveWindow(); | 434 aura::Window* active_window = wm::GetActiveWindow(); |
226 if (active_window) { | 435 if (active_window) { |
227 // The rotation animation bases its target transform on the current | 436 // The rotation animation bases its target transform on the current |
228 // rotation and position. Since there could be an animation in progress | 437 // rotation and position. Since there could be an animation in progress |
229 // right now, queue this animation so when it starts it picks up a neutral | 438 // right now, queue this animation so when it starts it picks up a neutral |
230 // rotation and position. Use replace so we only enqueue one at a time. | 439 // rotation and position. Use replace so we only enqueue one at a time. |
231 active_window->layer()->GetAnimator()-> | 440 active_window->layer()->GetAnimator()-> |
232 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 441 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
233 active_window->layer()->GetAnimator()->StartAnimation( | 442 active_window->layer()->GetAnimator()->StartAnimation( |
234 new ui::LayerAnimationSequence( | 443 new ui::LayerAnimationSequence( |
(...skipping 16 matching lines...) Expand all Loading... | |
251 NOTREACHED() << "Unknown rotation:" << current; | 460 NOTREACHED() << "Unknown rotation:" << current; |
252 return gfx::Display::ROTATE_0; | 461 return gfx::Display::ROTATE_0; |
253 } | 462 } |
254 | 463 |
255 bool HandleScaleUI(bool up) { | 464 bool HandleScaleUI(bool up) { |
256 internal::DisplayManager* display_manager = | 465 internal::DisplayManager* display_manager = |
257 Shell::GetInstance()->display_manager(); | 466 Shell::GetInstance()->display_manager(); |
258 int64 display_id = display_manager->GetDisplayIdForUIScaling(); | 467 int64 display_id = display_manager->GetDisplayIdForUIScaling(); |
259 if (display_id == gfx::Display::kInvalidDisplayID) | 468 if (display_id == gfx::Display::kInvalidDisplayID) |
260 return false; | 469 return false; |
470 | |
471 if (up) { | |
472 content::RecordAction( | |
473 content::UserMetricsAction("Accel_Scale_Ui_Up")); | |
474 } else { | |
475 content::RecordAction( | |
476 content::UserMetricsAction("Accel_Scale_Ui_Down")); | |
477 } | |
478 | |
261 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); | 479 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); |
262 float next_scale = | 480 float next_scale = |
263 internal::DisplayManager::GetNextUIScale(display_info, up); | 481 internal::DisplayManager::GetNextUIScale(display_info, up); |
264 display_manager->SetDisplayUIScale(display_id, next_scale); | 482 display_manager->SetDisplayUIScale(display_id, next_scale); |
265 return true; | 483 return true; |
266 } | 484 } |
267 | 485 |
268 bool HandleScaleReset() { | 486 bool HandleScaleReset() { |
269 internal::DisplayManager* display_manager = | 487 internal::DisplayManager* display_manager = |
270 Shell::GetInstance()->display_manager(); | 488 Shell::GetInstance()->display_manager(); |
271 int64 display_id = display_manager->GetDisplayIdForUIScaling(); | 489 int64 display_id = display_manager->GetDisplayIdForUIScaling(); |
272 if (display_id == gfx::Display::kInvalidDisplayID) | 490 if (display_id == gfx::Display::kInvalidDisplayID) |
273 return false; | 491 return false; |
492 | |
493 content::RecordAction( | |
494 content::UserMetricsAction("Accel_Scale_Ui_Reset")); | |
495 | |
274 display_manager->SetDisplayUIScale(display_id, 1.0f); | 496 display_manager->SetDisplayUIScale(display_id, 1.0f); |
275 return true; | 497 return true; |
276 } | 498 } |
277 | 499 |
500 void HandleSwapPrimaryDisplay() { | |
501 content::RecordAction( | |
502 content::UserMetricsAction("Accel_Swap_Primary_Display")); | |
503 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); | |
504 } | |
505 | |
506 void HandleRestoreTab() { | |
507 content::RecordAction(content::UserMetricsAction("Accel_Restore_Tab")); | |
508 Shell::GetInstance()->new_window_delegate()->RestoreTab(); | |
509 } | |
510 | |
278 // Rotates the screen. | 511 // Rotates the screen. |
279 bool HandleRotateScreen() { | 512 bool HandleRotateScreen() { |
513 content::RecordAction( | |
514 content::UserMetricsAction("Accel_Rotate_Window")); | |
280 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); | 515 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); |
281 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); | 516 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); |
282 const DisplayInfo& display_info = | 517 const DisplayInfo& display_info = |
283 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); | 518 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
284 Shell::GetInstance()->display_manager()->SetDisplayRotation( | 519 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
285 display.id(), GetNextRotation(display_info.rotation())); | 520 display.id(), GetNextRotation(display_info.rotation())); |
286 return true; | 521 return true; |
287 } | 522 } |
288 | 523 |
289 bool HandleToggleRootWindowFullScreen() { | 524 bool HandleToggleRootWindowFullScreen() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 bool HandleMediaPlayPause() { | 558 bool HandleMediaPlayPause() { |
324 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); | 559 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); |
325 return true; | 560 return true; |
326 } | 561 } |
327 | 562 |
328 bool HandleMediaPrevTrack() { | 563 bool HandleMediaPrevTrack() { |
329 Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack(); | 564 Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack(); |
330 return true; | 565 return true; |
331 } | 566 } |
332 | 567 |
568 bool HandleNewIncognitoWindow() { | |
569 content::RecordAction( | |
570 content::UserMetricsAction("Accel_New_Incognito_Window")); | |
571 bool incognito_allowed = | |
572 Shell::GetInstance()->delegate()->IsIncognitoAllowed(); | |
573 if (incognito_allowed) | |
574 Shell::GetInstance()->new_window_delegate()->NewWindow( | |
575 true /* is_incognito */); | |
576 return incognito_allowed; | |
577 } | |
578 | |
579 void HandleNewTab(ui::KeyboardCode key_code) { | |
580 if (key_code == ui::VKEY_T) | |
581 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T")); | |
582 Shell::GetInstance()->new_window_delegate()->NewTab(); | |
583 } | |
584 | |
585 void HandleNewWindow() { | |
586 content::RecordAction(content::UserMetricsAction("Accel_New_Window")); | |
587 Shell::GetInstance()->new_window_delegate()->NewWindow( | |
588 false /* is_incognito */); | |
589 } | |
590 | |
591 void HandleOpenFeedbackPage() { | |
592 content::RecordAction( | |
593 content::UserMetricsAction("Accel_Open_Feedback_Page")); | |
594 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); | |
595 } | |
596 | |
333 bool HandlePrintLayerHierarchy() { | 597 bool HandlePrintLayerHierarchy() { |
334 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 598 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
335 for (size_t i = 0; i < root_windows.size(); ++i) { | 599 for (size_t i = 0; i < root_windows.size(); ++i) { |
336 ui::PrintLayerHierarchy( | 600 ui::PrintLayerHierarchy( |
337 root_windows[i]->layer(), | 601 root_windows[i]->layer(), |
338 root_windows[i]->GetDispatcher()->GetLastMouseLocationInRoot()); | 602 root_windows[i]->GetDispatcher()->GetLastMouseLocationInRoot()); |
339 } | 603 } |
340 return true; | 604 return true; |
341 } | 605 } |
342 | 606 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 HandleCycleBackwardMRU(accelerator); | 832 HandleCycleBackwardMRU(accelerator); |
569 return true; | 833 return true; |
570 case CYCLE_FORWARD_MRU: | 834 case CYCLE_FORWARD_MRU: |
571 HandleCycleForwardMRU(accelerator); | 835 HandleCycleForwardMRU(accelerator); |
572 return true; | 836 return true; |
573 case CYCLE_LINEAR: | 837 case CYCLE_LINEAR: |
574 HandleCycleLinear(accelerator); | 838 HandleCycleLinear(accelerator); |
575 return true; | 839 return true; |
576 #if defined(OS_CHROMEOS) | 840 #if defined(OS_CHROMEOS) |
577 case ADD_REMOVE_DISPLAY: | 841 case ADD_REMOVE_DISPLAY: |
578 Shell::GetInstance()->display_manager()->AddRemoveDisplay(); | 842 HandleAddRemoveDisplay(); |
579 return true; | 843 return true; |
580 case TOGGLE_MIRROR_MODE: | 844 case TOGGLE_MIRROR_MODE: |
581 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); | 845 HandleToggleMirrorMode(); |
582 return true; | 846 return true; |
583 case LOCK_SCREEN: | 847 case LOCK_SCREEN: |
584 if (key_code == ui::VKEY_L) | 848 return HandleLock(key_code); |
585 content::RecordAction(content::UserMetricsAction("Accel_LockScreen_L")); | |
586 return HandleLock(); | |
587 case OPEN_FILE_MANAGER: | 849 case OPEN_FILE_MANAGER: |
588 return HandleFileManager(); | 850 return HandleFileManager(); |
589 case OPEN_CROSH: | 851 case OPEN_CROSH: |
590 return HandleCrosh(); | 852 return HandleCrosh(); |
591 case SILENCE_SPOKEN_FEEDBACK: | 853 case SILENCE_SPOKEN_FEEDBACK: |
592 HandleSilenceSpokenFeedback(); | 854 HandleSilenceSpokenFeedback(); |
593 break; | 855 break; |
594 case SWAP_PRIMARY_DISPLAY: | 856 case SWAP_PRIMARY_DISPLAY: |
595 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); | 857 HandleSwapPrimaryDisplay(); |
596 return true; | 858 return true; |
597 case SWITCH_TO_NEXT_USER: | 859 case SWITCH_TO_NEXT_USER: |
598 return SwitchToNextUser(); | 860 return HandleSwitchToNextUser(); |
599 case TOGGLE_SPOKEN_FEEDBACK: | 861 case TOGGLE_SPOKEN_FEEDBACK: |
600 return HandleToggleSpokenFeedback(); | 862 return HandleToggleSpokenFeedback(); |
601 case TOGGLE_WIFI: | 863 case TOGGLE_WIFI: |
602 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); | 864 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); |
603 return true; | 865 return true; |
604 case TOUCH_HUD_CLEAR: { | 866 case TOUCH_HUD_CLEAR: |
605 internal::RootWindowController* controller = | 867 return HandleTouchHudClear(); |
606 internal::RootWindowController::ForTargetRootWindow(); | 868 case TOUCH_HUD_MODE_CHANGE: |
607 if (controller->touch_hud_debug()) { | 869 return HandleTouchHudModeChange(); |
608 controller->touch_hud_debug()->Clear(); | 870 case TOUCH_HUD_PROJECTION_TOGGLE: |
609 return true; | 871 HandleTouchHudProjectToggle(); |
610 } | |
611 return false; | |
612 } | |
613 case TOUCH_HUD_MODE_CHANGE: { | |
614 internal::RootWindowController* controller = | |
615 internal::RootWindowController::ForTargetRootWindow(); | |
616 if (controller->touch_hud_debug()) { | |
617 controller->touch_hud_debug()->ChangeToNextMode(); | |
618 return true; | |
619 } | |
620 return false; | |
621 } | |
622 case TOUCH_HUD_PROJECTION_TOGGLE: { | |
623 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); | |
624 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); | |
625 return true; | 872 return true; |
626 } | |
627 case DISABLE_GPU_WATCHDOG: | 873 case DISABLE_GPU_WATCHDOG: |
628 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); | 874 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); |
629 return true; | 875 return true; |
630 #endif | 876 #endif |
631 case OPEN_FEEDBACK_PAGE: | 877 case OPEN_FEEDBACK_PAGE: |
632 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); | 878 HandleOpenFeedbackPage(); |
633 return true; | 879 return true; |
634 case EXIT: | 880 case EXIT: |
635 // UMA metrics are recorded in the handler. | 881 // UMA metrics are recorded in the handler. |
636 exit_warning_handler_.HandleAccelerator(); | 882 exit_warning_handler_.HandleAccelerator(); |
637 return true; | 883 return true; |
638 case NEW_INCOGNITO_WINDOW: { | 884 case NEW_INCOGNITO_WINDOW: |
639 bool incognito_allowed = | 885 return HandleNewIncognitoWindow(); |
640 Shell::GetInstance()->delegate()->IsIncognitoAllowed(); | |
641 if (incognito_allowed) | |
642 Shell::GetInstance()->new_window_delegate()->NewWindow( | |
643 true /* is_incognito */); | |
644 return incognito_allowed; | |
645 } | |
646 case NEW_TAB: | 886 case NEW_TAB: |
647 if (key_code == ui::VKEY_T) | 887 HandleNewTab(key_code); |
648 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T")); | |
649 Shell::GetInstance()->new_window_delegate()->NewTab(); | |
650 return true; | 888 return true; |
651 case NEW_WINDOW: | 889 case NEW_WINDOW: |
652 Shell::GetInstance()->new_window_delegate()->NewWindow( | 890 HandleNewWindow(); |
653 false /* is_incognito */); | |
654 return true; | 891 return true; |
655 case RESTORE_TAB: | 892 case RESTORE_TAB: |
656 Shell::GetInstance()->new_window_delegate()->RestoreTab(); | 893 HandleRestoreTab(); |
657 return true; | 894 return true; |
658 case TAKE_SCREENSHOT: | 895 case TAKE_SCREENSHOT: |
659 if (screenshot_delegate_.get() && | 896 HandleTakeScreenshot(screenshot_delegate_.get()); |
660 screenshot_delegate_->CanTakeScreenshot()) { | |
661 screenshot_delegate_->HandleTakeScreenshotForAllRootWindows(); | |
662 } | |
663 // Return true to prevent propagation of the key event. | 897 // Return true to prevent propagation of the key event. |
664 return true; | 898 return true; |
665 case TAKE_PARTIAL_SCREENSHOT: | 899 case TAKE_PARTIAL_SCREENSHOT: |
666 if (screenshot_delegate_) { | 900 HandleTakePartialScreenshot(screenshot_delegate_.get()); |
667 ash::PartialScreenshotView::StartPartialScreenshot( | |
668 screenshot_delegate_.get()); | |
669 } | |
670 // Return true to prevent propagation of the key event because | 901 // Return true to prevent propagation of the key event because |
671 // this key combination is reserved for partial screenshot. | 902 // this key combination is reserved for partial screenshot. |
672 return true; | 903 return true; |
673 case TOGGLE_APP_LIST: | 904 case TOGGLE_APP_LIST: |
674 // If something else was pressed between the Search key (LWIN) | 905 return HandleToggleAppList( |
675 // being pressed and released, then ignore the release of the | 906 key_code, previous_event_type, previous_key_code, accelerator); |
676 // Search key. | |
677 if (key_code == ui::VKEY_LWIN && | |
678 (previous_event_type == ui::ET_KEY_RELEASED || | |
679 previous_key_code != ui::VKEY_LWIN)) | |
680 return false; | |
681 if (key_code == ui::VKEY_LWIN) | |
682 content::RecordAction(content::UserMetricsAction("Accel_Search_LWin")); | |
683 // When spoken feedback is enabled, we should neither toggle the list nor | |
684 // consume the key since Search+Shift is one of the shortcuts the a11y | |
685 // feature uses. crbug.com/132296 | |
686 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); | |
687 if (Shell::GetInstance()->accessibility_delegate()-> | |
688 IsSpokenFeedbackEnabled()) | |
689 return false; | |
690 ash::Shell::GetInstance()->ToggleAppList(NULL); | |
691 return true; | |
692 case DISABLE_CAPS_LOCK: | 907 case DISABLE_CAPS_LOCK: |
693 if (previous_event_type == ui::ET_KEY_RELEASED || | 908 return HandleDisableCapsLock( |
694 (previous_key_code != ui::VKEY_LSHIFT && | 909 key_code, previous_event_type, previous_key_code); |
695 previous_key_code != ui::VKEY_SHIFT && | |
696 previous_key_code != ui::VKEY_RSHIFT)) { | |
697 // If something else was pressed between the Shift key being pressed | |
698 // and released, then ignore the release of the Shift key. | |
699 return false; | |
700 } | |
701 if (shell->caps_lock_delegate()->IsCapsLockEnabled()) { | |
702 shell->caps_lock_delegate()->SetCapsLockEnabled(false); | |
703 return true; | |
704 } | |
705 return false; | |
706 case TOGGLE_CAPS_LOCK: | 910 case TOGGLE_CAPS_LOCK: |
707 if (key_code == ui::VKEY_LWIN) { | 911 return HandleToggleCapsLock( |
708 // If something else was pressed between the Search key (LWIN) | 912 key_code, previous_event_type, previous_key_code); |
709 // being pressed and released, then ignore the release of the | |
710 // Search key. | |
711 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495 | |
712 if (previous_event_type == ui::ET_KEY_RELEASED || | |
713 previous_key_code != ui::VKEY_LWIN) | |
714 return false; | |
715 } | |
716 shell->caps_lock_delegate()->ToggleCapsLock(); | |
717 return true; | |
718 case BRIGHTNESS_DOWN: | 913 case BRIGHTNESS_DOWN: |
719 if (brightness_control_delegate_) | 914 if (brightness_control_delegate_) |
720 return brightness_control_delegate_->HandleBrightnessDown(accelerator); | 915 return brightness_control_delegate_->HandleBrightnessDown(accelerator); |
721 break; | 916 break; |
722 case BRIGHTNESS_UP: | 917 case BRIGHTNESS_UP: |
723 if (brightness_control_delegate_) | 918 if (brightness_control_delegate_) |
724 return brightness_control_delegate_->HandleBrightnessUp(accelerator); | 919 return brightness_control_delegate_->HandleBrightnessUp(accelerator); |
725 break; | 920 break; |
726 case KEYBOARD_BRIGHTNESS_DOWN: | 921 case KEYBOARD_BRIGHTNESS_DOWN: |
727 if (keyboard_brightness_control_delegate_) | 922 if (keyboard_brightness_control_delegate_) |
(...skipping 13 matching lines...) Expand all Loading... | |
741 case VOLUME_DOWN: { | 936 case VOLUME_DOWN: { |
742 ash::VolumeControlDelegate* volume_delegate = | 937 ash::VolumeControlDelegate* volume_delegate = |
743 shell->system_tray_delegate()->GetVolumeControlDelegate(); | 938 shell->system_tray_delegate()->GetVolumeControlDelegate(); |
744 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator); | 939 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator); |
745 } | 940 } |
746 case VOLUME_UP: { | 941 case VOLUME_UP: { |
747 ash::VolumeControlDelegate* volume_delegate = | 942 ash::VolumeControlDelegate* volume_delegate = |
748 shell->system_tray_delegate()->GetVolumeControlDelegate(); | 943 shell->system_tray_delegate()->GetVolumeControlDelegate(); |
749 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator); | 944 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator); |
750 } | 945 } |
751 case FOCUS_LAUNCHER: | 946 case FOCUS_LAUNCHER: { |
752 return shell->focus_cycler()->FocusWidget( | 947 return HandleFocusLauncher(); |
753 Launcher::ForPrimaryDisplay()->shelf_widget()); | 948 } |
James Cook
2013/11/26 21:40:59
nit: I don't think you need the extra braces and i
SteveT
2013/11/27 17:56:50
Done here and below.
| |
754 case FOCUS_NEXT_PANE: | 949 case FOCUS_NEXT_PANE: { |
755 return HandleRotatePaneFocus(Shell::FORWARD); | 950 return HandleRotatePaneFocus(Shell::FORWARD); |
756 case FOCUS_PREVIOUS_PANE: | 951 } |
952 case FOCUS_PREVIOUS_PANE: { | |
757 return HandleRotatePaneFocus(Shell::BACKWARD); | 953 return HandleRotatePaneFocus(Shell::BACKWARD); |
954 } | |
758 case SHOW_KEYBOARD_OVERLAY: | 955 case SHOW_KEYBOARD_OVERLAY: |
759 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); | 956 HandleShowKeyboardOverlay(); |
760 return true; | 957 return true; |
761 case SHOW_OAK: | 958 case SHOW_OAK: |
762 if (CommandLine::ForCurrentProcess()->HasSwitch( | 959 return HandleShowOak(); |
763 switches::kAshEnableOak)) { | 960 case SHOW_SYSTEM_TRAY_BUBBLE: |
764 oak::ShowOakWindowWithContext(Shell::GetPrimaryRootWindow()); | 961 return HandleShowSystemTrayBubble(); |
765 return true; | 962 case SHOW_MESSAGE_CENTER_BUBBLE: |
766 } | 963 HandleShowMessageCenterBubble(); |
767 break; | 964 break; |
768 case SHOW_SYSTEM_TRAY_BUBBLE: { | |
769 internal::RootWindowController* controller = | |
770 internal::RootWindowController::ForTargetRootWindow(); | |
771 if (!controller->GetSystemTray()->HasSystemBubble()) { | |
772 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | |
773 return true; | |
774 } | |
775 break; | |
776 } | |
777 case SHOW_MESSAGE_CENTER_BUBBLE: { | |
778 internal::RootWindowController* controller = | |
779 internal::RootWindowController::ForTargetRootWindow(); | |
780 internal::StatusAreaWidget* status_area_widget = | |
781 controller->shelf()->status_area_widget(); | |
782 if (status_area_widget) { | |
783 WebNotificationTray* notification_tray = | |
784 status_area_widget->web_notification_tray(); | |
785 if (notification_tray->visible()) | |
786 notification_tray->ShowMessageCenterBubble(); | |
787 } | |
788 break; | |
789 } | |
790 case SHOW_TASK_MANAGER: | 965 case SHOW_TASK_MANAGER: |
791 Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); | 966 HandleShowTaskManager(); |
792 return true; | 967 return true; |
793 case NEXT_IME: | 968 case NEXT_IME: |
794 // This check is necessary e.g. not to process the Shift+Alt+ | 969 // This check is necessary e.g. not to process the Shift+Alt+ |
795 // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/ | 970 // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/ |
796 // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab | 971 // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab |
797 // is released. | 972 // is released. |
798 if (previous_event_type == ui::ET_KEY_RELEASED && | 973 if (previous_event_type == ui::ET_KEY_RELEASED && |
799 // Workaround for crbug.com/139556. CJK IME users tend to press | 974 // Workaround for crbug.com/139556. CJK IME users tend to press |
800 // Enter (or Space) and Shift+Alt almost at the same time to commit | 975 // Enter (or Space) and Shift+Alt almost at the same time to commit |
801 // an IME string and then switch from the IME to the English layout. | 976 // an IME string and then switch from the IME to the English layout. |
802 // This workaround allows the user to trigger NEXT_IME even if the | 977 // This workaround allows the user to trigger NEXT_IME even if the |
803 // user presses Shift+Alt before releasing Enter. | 978 // user presses Shift+Alt before releasing Enter. |
804 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way. | 979 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way. |
805 previous_key_code != ui::VKEY_RETURN && | 980 previous_key_code != ui::VKEY_RETURN && |
806 previous_key_code != ui::VKEY_SPACE) { | 981 previous_key_code != ui::VKEY_SPACE) { |
807 // We totally ignore this accelerator. | 982 // We totally ignore this accelerator. |
808 // TODO(mazda): Fix crbug.com/158217 | 983 // TODO(mazda): Fix crbug.com/158217 |
809 return false; | 984 return false; |
810 } | 985 } |
986 content::RecordAction( | |
987 content::UserMetricsAction("Accel_Next_Ime")); | |
811 if (ime_control_delegate_) | 988 if (ime_control_delegate_) |
812 return ime_control_delegate_->HandleNextIme(); | 989 return ime_control_delegate_->HandleNextIme(); |
813 break; | 990 break; |
814 case PREVIOUS_IME: | 991 case PREVIOUS_IME: |
992 content::RecordAction( | |
993 content::UserMetricsAction("Accel_Previous_Ime")); | |
815 if (ime_control_delegate_) | 994 if (ime_control_delegate_) |
816 return ime_control_delegate_->HandlePreviousIme(accelerator); | 995 return ime_control_delegate_->HandlePreviousIme(accelerator); |
817 break; | 996 break; |
818 case PRINT_UI_HIERARCHIES: | 997 case PRINT_UI_HIERARCHIES: |
819 return HandlePrintUIHierarchies(); | 998 return HandlePrintUIHierarchies(); |
820 case SWITCH_IME: | 999 case SWITCH_IME: |
1000 content::RecordAction( | |
1001 content::UserMetricsAction("Accel_Switch_Ime")); | |
821 if (ime_control_delegate_) | 1002 if (ime_control_delegate_) |
822 return ime_control_delegate_->HandleSwitchIme(accelerator); | 1003 return ime_control_delegate_->HandleSwitchIme(accelerator); |
823 break; | 1004 break; |
824 case LAUNCH_APP_0: | 1005 case LAUNCH_APP_0: |
1006 content::RecordAction( | |
1007 content::UserMetricsAction("Accel_Launch_App_0")); | |
825 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(0); | 1008 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(0); |
826 return true; | 1009 return true; |
827 case LAUNCH_APP_1: | 1010 case LAUNCH_APP_1: |
1011 content::RecordAction( | |
1012 content::UserMetricsAction("Accel_Launch_App_1")); | |
828 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(1); | 1013 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(1); |
829 return true; | 1014 return true; |
830 case LAUNCH_APP_2: | 1015 case LAUNCH_APP_2: |
1016 content::RecordAction( | |
1017 content::UserMetricsAction("Accel_Launch_App_2")); | |
831 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(2); | 1018 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(2); |
832 return true; | 1019 return true; |
833 case LAUNCH_APP_3: | 1020 case LAUNCH_APP_3: |
1021 content::RecordAction( | |
1022 content::UserMetricsAction("Accel_Launch_App_3")); | |
834 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(3); | 1023 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(3); |
835 return true; | 1024 return true; |
836 case LAUNCH_APP_4: | 1025 case LAUNCH_APP_4: |
1026 content::RecordAction( | |
1027 content::UserMetricsAction("Accel_Launch_App_4")); | |
837 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(4); | 1028 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(4); |
838 return true; | 1029 return true; |
839 case LAUNCH_APP_5: | 1030 case LAUNCH_APP_5: |
1031 content::RecordAction( | |
1032 content::UserMetricsAction("Accel_Launch_App_5")); | |
840 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(5); | 1033 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(5); |
841 return true; | 1034 return true; |
842 case LAUNCH_APP_6: | 1035 case LAUNCH_APP_6: |
1036 content::RecordAction( | |
1037 content::UserMetricsAction("Accel_Launch_App_6")); | |
843 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(6); | 1038 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(6); |
844 return true; | 1039 return true; |
845 case LAUNCH_APP_7: | 1040 case LAUNCH_APP_7: |
1041 content::RecordAction( | |
1042 content::UserMetricsAction("Accel_Launch_App_7")); | |
846 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(7); | 1043 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(7); |
847 return true; | 1044 return true; |
848 case LAUNCH_LAST_APP: | 1045 case LAUNCH_LAST_APP: |
1046 content::RecordAction( | |
1047 content::UserMetricsAction("Accel_Launch_Last_App")); | |
849 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(-1); | 1048 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(-1); |
850 return true; | 1049 return true; |
851 case WINDOW_SNAP_LEFT: | 1050 case WINDOW_SNAP_LEFT: |
852 case WINDOW_SNAP_RIGHT: { | 1051 case WINDOW_SNAP_RIGHT: { |
853 wm::WindowState* window_state = wm::GetActiveWindowState(); | 1052 wm::WindowState* window_state = wm::GetActiveWindowState(); |
854 // Disable window snapping shortcut key for full screen window due to | 1053 // Disable window snapping shortcut key for full screen window due to |
855 // http://crbug.com/135487. | 1054 // http://crbug.com/135487. |
856 if (!window_state || | 1055 if (!window_state || |
857 window_state->window()->type() != aura::client::WINDOW_TYPE_NORMAL || | 1056 window_state->window()->type() != aura::client::WINDOW_TYPE_NORMAL || |
858 window_state->IsFullscreen()) { | 1057 window_state->IsFullscreen()) { |
859 break; | 1058 break; |
860 } | 1059 } |
861 | 1060 |
1061 if (action == WINDOW_SNAP_LEFT) { | |
1062 content::RecordAction( | |
1063 content::UserMetricsAction("Accel_Window_Snap_Left")); | |
1064 } else { | |
1065 content::RecordAction( | |
1066 content::UserMetricsAction("Accel_Window_Snap_Right")); | |
1067 } | |
1068 | |
862 internal::SnapSizer::SnapWindow(window_state, | 1069 internal::SnapSizer::SnapWindow(window_state, |
863 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE : | 1070 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE : |
864 internal::SnapSizer::RIGHT_EDGE); | 1071 internal::SnapSizer::RIGHT_EDGE); |
865 return true; | 1072 return true; |
866 } | 1073 } |
867 case WINDOW_MINIMIZE: | 1074 case WINDOW_MINIMIZE: |
868 return accelerators::ToggleMinimized(); | 1075 return accelerators::ToggleMinimized(); |
869 case TOGGLE_FULLSCREEN: { | 1076 case TOGGLE_FULLSCREEN: { |
870 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) { | 1077 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) { |
871 content::RecordAction( | 1078 content::RecordAction( |
872 content::UserMetricsAction("Accel_Fullscreen_F4")); | 1079 content::UserMetricsAction("Accel_Fullscreen_F4")); |
873 } | 1080 } |
874 accelerators::ToggleFullscreen(); | 1081 accelerators::ToggleFullscreen(); |
875 return true; | 1082 return true; |
876 } | 1083 } |
877 case TOGGLE_MAXIMIZED: { | 1084 case TOGGLE_MAXIMIZED: { |
878 accelerators::ToggleMaximized(); | 1085 accelerators::ToggleMaximized(); |
879 return true; | 1086 return true; |
880 } | 1087 } |
881 case WINDOW_POSITION_CENTER: { | 1088 case WINDOW_POSITION_CENTER: { |
882 content::RecordAction(content::UserMetricsAction("Accel_Center")); | 1089 content::RecordAction( |
1090 content::UserMetricsAction("Accel_Window_Position_Center")); | |
883 aura::Window* window = wm::GetActiveWindow(); | 1091 aura::Window* window = wm::GetActiveWindow(); |
884 // Docked windows do not support centering and ignore accelerator. | 1092 // Docked windows do not support centering and ignore accelerator. |
885 if (window && !wm::GetWindowState(window)->IsDocked()) { | 1093 if (window && !wm::GetWindowState(window)->IsDocked()) { |
886 wm::CenterWindow(window); | 1094 wm::CenterWindow(window); |
887 return true; | 1095 return true; |
888 } | 1096 } |
889 break; | 1097 break; |
890 } | 1098 } |
891 case SCALE_UI_UP: | 1099 case SCALE_UI_UP: |
892 return HandleScaleUI(true /* up */); | 1100 return HandleScaleUI(true /* up */); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 keyboard_brightness_control_delegate) { | 1215 keyboard_brightness_control_delegate) { |
1008 keyboard_brightness_control_delegate_ = | 1216 keyboard_brightness_control_delegate_ = |
1009 keyboard_brightness_control_delegate.Pass(); | 1217 keyboard_brightness_control_delegate.Pass(); |
1010 } | 1218 } |
1011 | 1219 |
1012 bool AcceleratorController::CanHandleAccelerators() const { | 1220 bool AcceleratorController::CanHandleAccelerators() const { |
1013 return true; | 1221 return true; |
1014 } | 1222 } |
1015 | 1223 |
1016 } // namespace ash | 1224 } // namespace ash |
OLD | NEW |