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

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 78763003: Record user actions for Ash accelerators. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: alphabetize helpers 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
« no previous file with comments | « ash/accelerators/accelerator_commands.cc ('k') | ash/shell_delegate.h » ('j') | 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) 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
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 HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { 95 bool HandleAccessibleFocusCycle(bool reverse) {
96 if (reverse) {
97 content::RecordAction(
98 content::UserMetricsAction("Accel_Accessible_Focus_Previous"));
99 } else {
100 content::RecordAction(
101 content::UserMetricsAction("Accel_Accessible_Focus_Next"));
102 }
103
104 if (!Shell::GetInstance()->accessibility_delegate()->
105 IsSpokenFeedbackEnabled()) {
106 return false;
107 }
108 aura::Window* active_window = ash::wm::GetActiveWindow();
109 if (!active_window)
110 return false;
111 views::Widget* widget =
112 views::Widget::GetWidgetForNativeWindow(active_window);
113 if (!widget)
114 return false;
115 views::FocusManager* focus_manager = widget->GetFocusManager();
116 if (!focus_manager)
117 return false;
118 views::View* view = focus_manager->GetFocusedView();
119 if (!view)
120 return false;
121 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName))
122 return false;
123
124 focus_manager->AdvanceFocus(reverse);
125 return true;
126 }
127
128 bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) {
96 Shell* shell = Shell::GetInstance(); 129 Shell* shell = Shell::GetInstance();
97 130
98 if (accelerator.key_code() == ui::VKEY_TAB) 131 if (accelerator.key_code() == ui::VKEY_TAB)
99 content::RecordAction(content::UserMetricsAction("Accel_PrevWindow_Tab")); 132 content::RecordAction(content::UserMetricsAction("Accel_PrevWindow_Tab"));
100 133
101 if (switches::UseOverviewMode()) { 134 if (switches::UseOverviewMode()) {
102 shell->window_selector_controller()->HandleCycleWindow( 135 shell->window_selector_controller()->HandleCycleWindow(
103 WindowSelector::BACKWARD); 136 WindowSelector::BACKWARD);
104 return; 137 return true;
105 } 138 }
106 shell->window_cycle_controller()->HandleCycleWindow( 139 shell->window_cycle_controller()->HandleCycleWindow(
107 WindowCycleController::BACKWARD, accelerator.IsAltDown()); 140 WindowCycleController::BACKWARD, accelerator.IsAltDown());
141 return true;
108 } 142 }
109 143
110 void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { 144 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) {
111 Shell* shell = Shell::GetInstance(); 145 Shell* shell = Shell::GetInstance();
112 146
113 if (accelerator.key_code() == ui::VKEY_TAB) 147 if (accelerator.key_code() == ui::VKEY_TAB)
114 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_Tab")); 148 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_Tab"));
115 149
116 if (switches::UseOverviewMode()) { 150 if (switches::UseOverviewMode()) {
117 shell->window_selector_controller()->HandleCycleWindow( 151 shell->window_selector_controller()->HandleCycleWindow(
118 WindowSelector::FORWARD); 152 WindowSelector::FORWARD);
119 return; 153 return true;
120 } 154 }
121 shell->window_cycle_controller()->HandleCycleWindow( 155 shell->window_cycle_controller()->HandleCycleWindow(
122 WindowCycleController::FORWARD, accelerator.IsAltDown()); 156 WindowCycleController::FORWARD, accelerator.IsAltDown());
157 return true;
123 } 158 }
124 159
125 void HandleCycleLinear(const ui::Accelerator& accelerator) { 160 bool HandleCycleLinear(const ui::Accelerator& accelerator) {
126 Shell* shell = Shell::GetInstance(); 161 Shell* shell = Shell::GetInstance();
127 162
128 // TODO(jamescook): When overview becomes the default the AcceleratorAction 163 // TODO(jamescook): When overview becomes the default the AcceleratorAction
129 // should be renamed from CYCLE_LINEAR to TOGGLE_OVERVIEW. 164 // should be renamed from CYCLE_LINEAR to TOGGLE_OVERVIEW.
130 if (switches::UseOverviewMode()) { 165 if (switches::UseOverviewMode()) {
131 content::RecordAction(content::UserMetricsAction("Accel_Overview_F5")); 166 content::RecordAction(content::UserMetricsAction("Accel_Overview_F5"));
132 shell->window_selector_controller()->ToggleOverview(); 167 shell->window_selector_controller()->ToggleOverview();
133 return; 168 return true;
134 } 169 }
135 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) 170 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1)
136 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_F5")); 171 content::RecordAction(content::UserMetricsAction("Accel_NextWindow_F5"));
137 shell->window_cycle_controller()->HandleLinearCycleWindow(); 172 shell->window_cycle_controller()->HandleLinearCycleWindow();
138 } 173 return true;
139 174 }
140 bool HandleAccessibleFocusCycle(bool reverse) { 175
141 if (!Shell::GetInstance()->accessibility_delegate()-> 176 bool HandleDisableCapsLock(ui::KeyboardCode key_code,
142 IsSpokenFeedbackEnabled()) { 177 ui::EventType previous_event_type,
178 ui::KeyboardCode previous_key_code) {
179 Shell* shell = Shell::GetInstance();
180
181 if (previous_event_type == ui::ET_KEY_RELEASED ||
182 (previous_key_code != ui::VKEY_LSHIFT &&
183 previous_key_code != ui::VKEY_SHIFT &&
184 previous_key_code != ui::VKEY_RSHIFT)) {
185 // If something else was pressed between the Shift key being pressed
186 // and released, then ignore the release of the Shift key.
143 return false; 187 return false;
144 } 188 }
145 aura::Window* active_window = ash::wm::GetActiveWindow(); 189 content::RecordAction(
146 if (!active_window) 190 content::UserMetricsAction("Accel_Disable_Caps_Lock"));
191 if (shell->caps_lock_delegate()->IsCapsLockEnabled()) {
192 shell->caps_lock_delegate()->SetCapsLockEnabled(false);
193 return true;
194 }
195 return false;
196 }
197
198 bool HandleFocusLauncher() {
199 Shell* shell = Shell::GetInstance();
200 content::RecordAction(content::UserMetricsAction("Accel_Focus_Launcher"));
201 return shell->focus_cycler()->FocusWidget(
202 Launcher::ForPrimaryDisplay()->shelf_widget());
203 }
204
205 bool HandleLaunchApp0() {
206 content::RecordAction(
207 content::UserMetricsAction("Accel_Launch_App_0"));
James Cook 2013/11/27 21:25:28 Do you really care about whether the user hit 1, 2
SteveT 2013/11/27 22:04:52 Good point. I feel like we might not care about w
208 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(0);
209 return true;
210 }
211
212 bool HandleLaunchApp1() {
213 content::RecordAction(
214 content::UserMetricsAction("Accel_Launch_App_1"));
215 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(1);
216 return true;
217 }
218
219 bool HandleLaunchApp2() {
220 content::RecordAction(
221 content::UserMetricsAction("Accel_Launch_App_2"));
222 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(2);
223 return true;
224 }
225
226 bool HandleLaunchApp3() {
227 content::RecordAction(
228 content::UserMetricsAction("Accel_Launch_App_3"));
229 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(3);
230 return true;
231 }
232
233 bool HandleLaunchApp4() {
234 content::RecordAction(
235 content::UserMetricsAction("Accel_Launch_App_4"));
236 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(4);
237 return true;
238 }
239
240 bool HandleLaunchApp5() {
241 content::RecordAction(
242 content::UserMetricsAction("Accel_Launch_App_5"));
243 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(5);
244 return true;
245 }
246
247 bool HandleLaunchApp6() {
248 content::RecordAction(
249 content::UserMetricsAction("Accel_Launch_App_6"));
250 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(6);
251 return true;
252 }
253
254 bool HandleLaunchApp7() {
255 content::RecordAction(
256 content::UserMetricsAction("Accel_Launch_App_7"));
257 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(7);
258 return true;
259 }
260
261 bool HandleLaunchLastApp() {
262 content::RecordAction(
263 content::UserMetricsAction("Accel_Launch_Last_App"));
264 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(-1);
265 return true;
266 }
267
268 // Magnify the screen
269 bool HandleMagnifyScreen(int delta_index) {
270 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) {
271 // TODO(yoshiki): Move the following logic to MagnificationController.
272 float scale =
273 ash::Shell::GetInstance()->magnification_controller()->GetScale();
274 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale.
275 int scale_index =
276 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5);
277
278 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));
279
280 ash::Shell::GetInstance()->magnification_controller()->
281 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true);
282 } else if (ash::Shell::GetInstance()->
283 partial_magnification_controller()->is_enabled()) {
284 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1;
285 ash::Shell::GetInstance()->partial_magnification_controller()->
286 SetScale(scale);
287 }
288
289 return true;
290 }
291
292 bool HandleMediaNextTrack() {
293 Shell::GetInstance()->media_delegate()->HandleMediaNextTrack();
294 return true;
295 }
296
297 bool HandleMediaPlayPause() {
298 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause();
299 return true;
300 }
301
302 bool HandleMediaPrevTrack() {
303 Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack();
304 return true;
305 }
306
307 bool HandleNewIncognitoWindow() {
308 content::RecordAction(
309 content::UserMetricsAction("Accel_New_Incognito_Window"));
310 bool incognito_allowed =
311 Shell::GetInstance()->delegate()->IsIncognitoAllowed();
312 if (incognito_allowed)
313 Shell::GetInstance()->new_window_delegate()->NewWindow(
314 true /* is_incognito */);
315 return incognito_allowed;
316 }
317
318 bool HandleNewTab(ui::KeyboardCode key_code) {
319 if (key_code == ui::VKEY_T)
320 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T"));
321 Shell::GetInstance()->new_window_delegate()->NewTab();
322 return true;
323 }
324
325 bool HandleNewWindow() {
326 content::RecordAction(content::UserMetricsAction("Accel_New_Window"));
327 Shell::GetInstance()->new_window_delegate()->NewWindow(
328 false /* is_incognito */);
329 return true;
330 }
331
332 bool HandleNextIme(ImeControlDelegate* ime_control_delegate,
333 ui::EventType previous_event_type,
334 ui::KeyboardCode previous_key_code) {
335 // This check is necessary e.g. not to process the Shift+Alt+
336 // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/
337 // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab
338 // is released.
339 if (previous_event_type == ui::ET_KEY_RELEASED &&
340 // Workaround for crbug.com/139556. CJK IME users tend to press
341 // Enter (or Space) and Shift+Alt almost at the same time to commit
342 // an IME string and then switch from the IME to the English layout.
343 // This workaround allows the user to trigger NEXT_IME even if the
344 // user presses Shift+Alt before releasing Enter.
345 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way.
346 previous_key_code != ui::VKEY_RETURN &&
347 previous_key_code != ui::VKEY_SPACE) {
348 // We totally ignore this accelerator.
349 // TODO(mazda): Fix crbug.com/158217
147 return false; 350 return false;
148 views::Widget* widget = 351 }
149 views::Widget::GetWidgetForNativeWindow(active_window); 352 content::RecordAction(
150 if (!widget) 353 content::UserMetricsAction("Accel_Next_Ime"));
151 return false; 354 if (ime_control_delegate)
152 views::FocusManager* focus_manager = widget->GetFocusManager(); 355 return ime_control_delegate->HandleNextIme();
153 if (!focus_manager) 356 return false;
154 return false; 357 }
155 views::View* view = focus_manager->GetFocusedView(); 358
156 if (!view) 359 bool HandleOpenFeedbackPage() {
157 return false; 360 content::RecordAction(
158 if (!strcmp(view->GetClassName(), views::WebView::kViewClassName)) 361 content::UserMetricsAction("Accel_Open_Feedback_Page"));
159 return false; 362 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
160 363 return true;
161 focus_manager->AdvanceFocus(reverse); 364 }
162 return true; 365
163 } 366 bool HandlePositionCenter() {
164 367 content::RecordAction(
165 void HandleSilenceSpokenFeedback() { 368 content::UserMetricsAction("Accel_Window_Position_Center"));
166 AccessibilityDelegate* delegate = 369 aura::Window* window = wm::GetActiveWindow();
167 Shell::GetInstance()->accessibility_delegate(); 370 // Docked windows do not support centering and ignore accelerator.
168 if (!delegate->IsSpokenFeedbackEnabled()) 371 if (window && !wm::GetWindowState(window)->IsDocked()) {
169 return; 372 wm::CenterWindow(window);
170 delegate->SilenceSpokenFeedback(); 373 return true;
171 } 374 }
172 375 return false;
173 #if defined(OS_CHROMEOS) 376 }
174 bool HandleLock() { 377
175 Shell::GetInstance()->session_state_delegate()->LockScreen(); 378 bool HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
176 return true; 379 const ui::Accelerator& accelerator) {
177 } 380 content::RecordAction(
178 381 content::UserMetricsAction("Accel_Previous_Ime"));
179 bool HandleFileManager() { 382 if (ime_control_delegate)
180 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); 383 return ime_control_delegate->HandlePreviousIme(accelerator);
181 return true; 384 return false;
182 } 385 }
183 386
184 bool HandleCrosh() { 387 bool HandleRestoreTab() {
185 Shell::GetInstance()->new_window_delegate()->OpenCrosh(); 388 content::RecordAction(content::UserMetricsAction("Accel_Restore_Tab"));
186 return true; 389 Shell::GetInstance()->new_window_delegate()->RestoreTab();
187 } 390 return true;
188 391 }
189 bool HandleToggleSpokenFeedback() {
190 Shell::GetInstance()->accessibility_delegate()->
191 ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW);
192 return true;
193 }
194
195 bool SwitchToNextUser() {
196 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled())
197 return false;
198 ash::SessionStateDelegate* delegate =
199 ash::Shell::GetInstance()->session_state_delegate();
200 if (delegate->NumberOfLoggedInUsers() <= 1)
201 return false;
202 MultiProfileUMA::RecordSwitchActiveUser(
203 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR);
204 delegate->SwitchActiveUserToNext();
205 return true;
206 }
207
208 #endif // defined(OS_CHROMEOS)
209 392
210 bool HandleRotatePaneFocus(Shell::Direction direction) { 393 bool HandleRotatePaneFocus(Shell::Direction direction) {
211 Shell* shell = Shell::GetInstance(); 394 Shell* shell = Shell::GetInstance();
212 switch (direction) { 395 switch (direction) {
213 case Shell::FORWARD: 396 // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE.
397 case Shell::FORWARD: {
398 content::RecordAction(
399 content::UserMetricsAction("Accel_Focus_Next_Pane"));
214 shell->focus_cycler()->RotateFocus(internal::FocusCycler::FORWARD); 400 shell->focus_cycler()->RotateFocus(internal::FocusCycler::FORWARD);
215 break; 401 break;
216 case Shell::BACKWARD: 402 }
403 case Shell::BACKWARD: {
404 content::RecordAction(
405 content::UserMetricsAction("Accel_Focus_Previous_Pane"));
217 shell->focus_cycler()->RotateFocus(internal::FocusCycler::BACKWARD); 406 shell->focus_cycler()->RotateFocus(internal::FocusCycler::BACKWARD);
218 break; 407 break;
408 }
219 } 409 }
220 return true; 410 return true;
221 } 411 }
222 412
223 // Rotate the active window. 413 // Rotate the active window.
224 bool HandleRotateActiveWindow() { 414 bool HandleRotateActiveWindow() {
415 content::RecordAction(
416 content::UserMetricsAction("Accel_Rotate_Window"));
225 aura::Window* active_window = wm::GetActiveWindow(); 417 aura::Window* active_window = wm::GetActiveWindow();
226 if (active_window) { 418 if (active_window) {
227 // The rotation animation bases its target transform on the current 419 // The rotation animation bases its target transform on the current
228 // rotation and position. Since there could be an animation in progress 420 // 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 421 // 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. 422 // rotation and position. Use replace so we only enqueue one at a time.
231 active_window->layer()->GetAnimator()-> 423 active_window->layer()->GetAnimator()->
232 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 424 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
233 active_window->layer()->GetAnimator()->StartAnimation( 425 active_window->layer()->GetAnimator()->StartAnimation(
234 new ui::LayerAnimationSequence( 426 new ui::LayerAnimationSequence(
(...skipping 10 matching lines...) Expand all
245 return gfx::Display::ROTATE_180; 437 return gfx::Display::ROTATE_180;
246 case gfx::Display::ROTATE_180: 438 case gfx::Display::ROTATE_180:
247 return gfx::Display::ROTATE_270; 439 return gfx::Display::ROTATE_270;
248 case gfx::Display::ROTATE_270: 440 case gfx::Display::ROTATE_270:
249 return gfx::Display::ROTATE_0; 441 return gfx::Display::ROTATE_0;
250 } 442 }
251 NOTREACHED() << "Unknown rotation:" << current; 443 NOTREACHED() << "Unknown rotation:" << current;
252 return gfx::Display::ROTATE_0; 444 return gfx::Display::ROTATE_0;
253 } 445 }
254 446
447 // Rotates the screen.
448 bool HandleRotateScreen() {
449 content::RecordAction(
450 content::UserMetricsAction("Accel_Rotate_Window"));
451 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint();
452 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point);
453 const DisplayInfo& display_info =
454 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
455 Shell::GetInstance()->display_manager()->SetDisplayRotation(
456 display.id(), GetNextRotation(display_info.rotation()));
457 return true;
458 }
459
460 bool HandleScaleReset() {
461 internal::DisplayManager* display_manager =
462 Shell::GetInstance()->display_manager();
463 int64 display_id = display_manager->GetDisplayIdForUIScaling();
464 if (display_id == gfx::Display::kInvalidDisplayID)
465 return false;
466
467 content::RecordAction(
468 content::UserMetricsAction("Accel_Scale_Ui_Reset"));
469
470 display_manager->SetDisplayUIScale(display_id, 1.0f);
471 return true;
472 }
473
255 bool HandleScaleUI(bool up) { 474 bool HandleScaleUI(bool up) {
256 internal::DisplayManager* display_manager = 475 internal::DisplayManager* display_manager =
257 Shell::GetInstance()->display_manager(); 476 Shell::GetInstance()->display_manager();
258 int64 display_id = display_manager->GetDisplayIdForUIScaling(); 477 int64 display_id = display_manager->GetDisplayIdForUIScaling();
259 if (display_id == gfx::Display::kInvalidDisplayID) 478 if (display_id == gfx::Display::kInvalidDisplayID)
260 return false; 479 return false;
480
481 if (up) {
482 content::RecordAction(
483 content::UserMetricsAction("Accel_Scale_Ui_Up"));
484 } else {
485 content::RecordAction(
486 content::UserMetricsAction("Accel_Scale_Ui_Down"));
487 }
488
261 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); 489 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id);
262 float next_scale = 490 float next_scale =
263 internal::DisplayManager::GetNextUIScale(display_info, up); 491 internal::DisplayManager::GetNextUIScale(display_info, up);
264 display_manager->SetDisplayUIScale(display_id, next_scale); 492 display_manager->SetDisplayUIScale(display_id, next_scale);
265 return true; 493 return true;
266 } 494 }
267 495
268 bool HandleScaleReset() { 496 bool HandleSwapPrimaryDisplay() {
269 internal::DisplayManager* display_manager = 497 content::RecordAction(
270 Shell::GetInstance()->display_manager(); 498 content::UserMetricsAction("Accel_Swap_Primary_Display"));
271 int64 display_id = display_manager->GetDisplayIdForUIScaling(); 499 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
272 if (display_id == gfx::Display::kInvalidDisplayID)
273 return false;
274 display_manager->SetDisplayUIScale(display_id, 1.0f);
275 return true; 500 return true;
276 } 501 }
277 502
278 // Rotates the screen. 503 bool HandleShowKeyboardOverlay() {
279 bool HandleRotateScreen() { 504 content::RecordAction(
280 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); 505 content::UserMetricsAction("Accel_Show_Keyboard_Overlay"));
281 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); 506 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
282 const DisplayInfo& display_info = 507
283 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
284 Shell::GetInstance()->display_manager()->SetDisplayRotation(
285 display.id(), GetNextRotation(display_info.rotation()));
286 return true; 508 return true;
287 } 509 }
288 510
511 void HandleShowMessageCenterBubble() {
512 content::RecordAction(
513 content::UserMetricsAction("Accel_Show_Message_Center_Bubble"));
514 internal::RootWindowController* controller =
515 internal::RootWindowController::ForTargetRootWindow();
516 internal::StatusAreaWidget* status_area_widget =
517 controller->shelf()->status_area_widget();
518 if (status_area_widget) {
519 WebNotificationTray* notification_tray =
520 status_area_widget->web_notification_tray();
521 if (notification_tray->visible())
522 notification_tray->ShowMessageCenterBubble();
523 }
524 }
525
526 bool HandleShowOak() {
527 if (CommandLine::ForCurrentProcess()->HasSwitch(
528 switches::kAshEnableOak)) {
529 oak::ShowOakWindowWithContext(Shell::GetPrimaryRootWindow());
530 return true;
531 }
532 return false;
533 }
534
535 bool HandleShowSystemTrayBubble() {
536 content::RecordAction(
537 content::UserMetricsAction("Accel_Show_System_Tray_Bubble"));
538 internal::RootWindowController* controller =
539 internal::RootWindowController::ForTargetRootWindow();
540 if (!controller->GetSystemTray()->HasSystemBubble()) {
541 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
542 return true;
543 }
544 return false;
545 }
546
547 bool HandleShowTaskManager() {
548 content::RecordAction(
549 content::UserMetricsAction("Accel_Show_Task_Manager"));
550 Shell::GetInstance()->new_window_delegate()->ShowTaskManager();
551 return true;
552 }
553
554 void HandleSilenceSpokenFeedback() {
555 content::RecordAction(
556 content::UserMetricsAction("Accel_Silence_Spoken_Feedback"));
557
558 AccessibilityDelegate* delegate =
559 Shell::GetInstance()->accessibility_delegate();
560 if (!delegate->IsSpokenFeedbackEnabled())
561 return;
562 delegate->SilenceSpokenFeedback();
563 }
564
565 bool HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
566 const ui::Accelerator& accelerator) {
567 content::RecordAction(
568 content::UserMetricsAction("Accel_Switch_Ime"));
569 if (ime_control_delegate)
570 return ime_control_delegate->HandleSwitchIme(accelerator);
571 return false;
572 }
573
574 bool HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) {
575 content::RecordAction(
576 content::UserMetricsAction("Accel_Take_Partial_Screenshot"));
577 if (screenshot_delegate) {
578 ash::PartialScreenshotView::StartPartialScreenshot(
579 screenshot_delegate);
580 }
581 // Return true to prevent propagation of the key event because
582 // this key combination is reserved for partial screenshot.
583 return true;
584 }
585
586 bool HandleTakeScreenshot(ScreenshotDelegate* screenshot_delegate) {
587 content::RecordAction(
588 content::UserMetricsAction("Accel_Take_Screenshot"));
589 if (screenshot_delegate &&
590 screenshot_delegate->CanTakeScreenshot()) {
591 screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
592 }
593 // Return true to prevent propagation of the key event.
594 return true;
595 }
596
597 bool HandleToggleAppList(ui::KeyboardCode key_code,
598 ui::EventType previous_event_type,
599 ui::KeyboardCode previous_key_code,
600 const ui::Accelerator& accelerator) {
601 // If something else was pressed between the Search key (LWIN)
602 // being pressed and released, then ignore the release of the
603 // Search key.
604 if (key_code == ui::VKEY_LWIN &&
605 (previous_event_type == ui::ET_KEY_RELEASED ||
606 previous_key_code != ui::VKEY_LWIN))
607 return false;
608 if (key_code == ui::VKEY_LWIN)
609 content::RecordAction(content::UserMetricsAction("Accel_Search_LWin"));
610 // When spoken feedback is enabled, we should neither toggle the list nor
611 // consume the key since Search+Shift is one of the shortcuts the a11y
612 // feature uses. crbug.com/132296
613 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code());
614 if (Shell::GetInstance()->accessibility_delegate()->
615 IsSpokenFeedbackEnabled())
616 return false;
617 ash::Shell::GetInstance()->ToggleAppList(NULL);
618 return true;
619 }
620
621 bool HandleToggleCapsLock(ui::KeyboardCode key_code,
622 ui::EventType previous_event_type,
623 ui::KeyboardCode previous_key_code) {
624 Shell* shell = Shell::GetInstance();
625 if (key_code == ui::VKEY_LWIN) {
626 // If something else was pressed between the Search key (LWIN)
627 // being pressed and released, then ignore the release of the
628 // Search key.
629 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495
630 if (previous_event_type == ui::ET_KEY_RELEASED ||
631 previous_key_code != ui::VKEY_LWIN)
632 return false;
633 }
634 content::RecordAction(
635 content::UserMetricsAction("Accel_Toggle_Caps_Lock"));
636 shell->caps_lock_delegate()->ToggleCapsLock();
637 return true;
638 }
639
640 bool HandleToggleFullscreen(ui::KeyboardCode key_code) {
641 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) {
642 content::RecordAction(
643 content::UserMetricsAction("Accel_Fullscreen_F4"));
644 }
645 accelerators::ToggleFullscreen();
646 return true;
647 }
648
289 bool HandleToggleRootWindowFullScreen() { 649 bool HandleToggleRootWindowFullScreen() {
290 Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->ToggleFullScreen(); 650 Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->ToggleFullScreen();
291 return true; 651 return true;
292 } 652 }
293 653
294 // Magnify the screen 654 bool HandleWindowSnap(int action) {
295 bool HandleMagnifyScreen(int delta_index) { 655 wm::WindowState* window_state = wm::GetActiveWindowState();
296 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { 656 // Disable window snapping shortcut key for full screen window due to
297 // TODO(yoshiki): Move the following logic to MagnificationController. 657 // http://crbug.com/135487.
298 float scale = 658 if (!window_state ||
299 ash::Shell::GetInstance()->magnification_controller()->GetScale(); 659 window_state->window()->type() != aura::client::WINDOW_TYPE_NORMAL ||
300 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. 660 window_state->IsFullscreen()) {
301 int scale_index = 661 return false;
302 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5);
303
304 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));
305
306 ash::Shell::GetInstance()->magnification_controller()->
307 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true);
308 } else if (ash::Shell::GetInstance()->
309 partial_magnification_controller()->is_enabled()) {
310 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1;
311 ash::Shell::GetInstance()->partial_magnification_controller()->
312 SetScale(scale);
313 } 662 }
314 663
664 if (action == WINDOW_SNAP_LEFT) {
665 content::RecordAction(
666 content::UserMetricsAction("Accel_Window_Snap_Left"));
667 } else {
668 content::RecordAction(
669 content::UserMetricsAction("Accel_Window_Snap_Right"));
670 }
671
672 internal::SnapSizer::SnapWindow(window_state,
673 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE :
674 internal::SnapSizer::RIGHT_EDGE);
315 return true; 675 return true;
316 } 676 }
317 677
318 bool HandleMediaNextTrack() { 678 #if defined(OS_CHROMEOS)
319 Shell::GetInstance()->media_delegate()->HandleMediaNextTrack(); 679 bool HandleAddRemoveDisplay() {
680 content::RecordAction(
681 content::UserMetricsAction("Accel_Add_Remove_Display"));
682 Shell::GetInstance()->display_manager()->AddRemoveDisplay();
320 return true; 683 return true;
321 } 684 }
322 685
323 bool HandleMediaPlayPause() { 686 bool HandleCrosh() {
324 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); 687 content::RecordAction(
688 content::UserMetricsAction("Accel_Open_Crosh"));
689
690 Shell::GetInstance()->new_window_delegate()->OpenCrosh();
325 return true; 691 return true;
326 } 692 }
327 693
328 bool HandleMediaPrevTrack() { 694 bool HandleFileManager() {
329 Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack(); 695 content::RecordAction(
696 content::UserMetricsAction("Accel_Open_File_Manager"));
697
698 Shell::GetInstance()->new_window_delegate()->OpenFileManager();
330 return true; 699 return true;
331 } 700 }
332 701
702 bool HandleLock(ui::KeyboardCode key_code) {
703 Shell::GetInstance()->session_state_delegate()->LockScreen();
James Cook 2013/11/27 21:25:28 I'm surprised this one doesn't get a metric.
SteveT 2013/11/27 22:04:52 My bad. This one used to have a metric but it got
704 return true;
705 }
706
707 bool HandleSwitchToNextUser() {
708 content::RecordAction(
709 content::UserMetricsAction("Accel_Switch_To_Next_User"));
710
711 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled())
712 return false;
713 ash::SessionStateDelegate* delegate =
714 ash::Shell::GetInstance()->session_state_delegate();
715 if (delegate->NumberOfLoggedInUsers() <= 1)
716 return false;
717 MultiProfileUMA::RecordSwitchActiveUser(
718 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR);
719 delegate->SwitchActiveUserToNext();
720 return true;
721 }
722
723 bool HandleToggleMirrorMode() {
724 content::RecordAction(
725 content::UserMetricsAction("Accel_Toggle_Mirror_Mode"));
726 Shell::GetInstance()->display_controller()->ToggleMirrorMode();
727 return true;
728 }
729
730 bool HandleToggleSpokenFeedback() {
731 content::RecordAction(
732 content::UserMetricsAction("Accel_Toggle_Spoken_Feedback"));
733
734 Shell::GetInstance()->accessibility_delegate()->
735 ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW);
736 return true;
737 }
738
739 bool HandleTouchHudClear() {
740 internal::RootWindowController* controller =
741 internal::RootWindowController::ForTargetRootWindow();
742 if (controller->touch_hud_debug()) {
743 controller->touch_hud_debug()->Clear();
744 return true;
745 }
746 return false;
747 }
748
749 bool HandleTouchHudModeChange() {
750 internal::RootWindowController* controller =
751 internal::RootWindowController::ForTargetRootWindow();
752 if (controller->touch_hud_debug()) {
753 controller->touch_hud_debug()->ChangeToNextMode();
754 return true;
755 }
756 return false;
757 }
758
759 bool HandleTouchHudProjectToggle() {
760 content::RecordAction(
761 content::UserMetricsAction("Accel_Touch_Hud_Clear"));
762 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled();
763 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled);
764 return true;
765 }
766
767 #endif // defined(OS_CHROMEOS)
768
769 // Debug print methods.
770
333 bool HandlePrintLayerHierarchy() { 771 bool HandlePrintLayerHierarchy() {
334 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 772 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
335 for (size_t i = 0; i < root_windows.size(); ++i) { 773 for (size_t i = 0; i < root_windows.size(); ++i) {
336 ui::PrintLayerHierarchy( 774 ui::PrintLayerHierarchy(
337 root_windows[i]->layer(), 775 root_windows[i]->layer(),
338 root_windows[i]->GetDispatcher()->GetLastMouseLocationInRoot()); 776 root_windows[i]->GetDispatcher()->GetLastMouseLocationInRoot());
339 } 777 }
340 return true; 778 return true;
341 } 779 }
342 780
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // 996 //
559 // If your accelerator invokes more than one line of code, please either 997 // If your accelerator invokes more than one line of code, please either
560 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE 998 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE
561 // below) or pull it into a HandleFoo() function above. 999 // below) or pull it into a HandleFoo() function above.
562 switch (action) { 1000 switch (action) {
563 case ACCESSIBLE_FOCUS_NEXT: 1001 case ACCESSIBLE_FOCUS_NEXT:
564 return HandleAccessibleFocusCycle(false); 1002 return HandleAccessibleFocusCycle(false);
565 case ACCESSIBLE_FOCUS_PREVIOUS: 1003 case ACCESSIBLE_FOCUS_PREVIOUS:
566 return HandleAccessibleFocusCycle(true); 1004 return HandleAccessibleFocusCycle(true);
567 case CYCLE_BACKWARD_MRU: 1005 case CYCLE_BACKWARD_MRU:
568 HandleCycleBackwardMRU(accelerator); 1006 return HandleCycleBackwardMRU(accelerator);
569 return true;
570 case CYCLE_FORWARD_MRU: 1007 case CYCLE_FORWARD_MRU:
571 HandleCycleForwardMRU(accelerator); 1008 return HandleCycleForwardMRU(accelerator);
572 return true;
573 case CYCLE_LINEAR: 1009 case CYCLE_LINEAR:
574 HandleCycleLinear(accelerator); 1010 return HandleCycleLinear(accelerator);
575 return true;
576 #if defined(OS_CHROMEOS) 1011 #if defined(OS_CHROMEOS)
577 case ADD_REMOVE_DISPLAY: 1012 case ADD_REMOVE_DISPLAY:
578 Shell::GetInstance()->display_manager()->AddRemoveDisplay(); 1013 return HandleAddRemoveDisplay();
579 return true;
580 case TOGGLE_MIRROR_MODE: 1014 case TOGGLE_MIRROR_MODE:
581 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); 1015 return HandleToggleMirrorMode();
582 return true;
583 case LOCK_SCREEN: 1016 case LOCK_SCREEN:
584 if (key_code == ui::VKEY_L) 1017 return HandleLock(key_code);
585 content::RecordAction(content::UserMetricsAction("Accel_LockScreen_L"));
586 return HandleLock();
587 case OPEN_FILE_MANAGER: 1018 case OPEN_FILE_MANAGER:
588 return HandleFileManager(); 1019 return HandleFileManager();
589 case OPEN_CROSH: 1020 case OPEN_CROSH:
590 return HandleCrosh(); 1021 return HandleCrosh();
591 case SILENCE_SPOKEN_FEEDBACK: 1022 case SILENCE_SPOKEN_FEEDBACK:
592 HandleSilenceSpokenFeedback(); 1023 HandleSilenceSpokenFeedback();
593 break; 1024 break;
594 case SWAP_PRIMARY_DISPLAY: 1025 case SWAP_PRIMARY_DISPLAY:
595 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); 1026 return HandleSwapPrimaryDisplay();
596 return true;
597 case SWITCH_TO_NEXT_USER: 1027 case SWITCH_TO_NEXT_USER:
598 return SwitchToNextUser(); 1028 return HandleSwitchToNextUser();
599 case TOGGLE_SPOKEN_FEEDBACK: 1029 case TOGGLE_SPOKEN_FEEDBACK:
600 return HandleToggleSpokenFeedback(); 1030 return HandleToggleSpokenFeedback();
601 case TOGGLE_WIFI: 1031 case TOGGLE_WIFI:
602 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); 1032 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi();
603 return true; 1033 return true;
604 case TOUCH_HUD_CLEAR: { 1034 case TOUCH_HUD_CLEAR:
605 internal::RootWindowController* controller = 1035 return HandleTouchHudClear();
606 internal::RootWindowController::ForTargetRootWindow(); 1036 case TOUCH_HUD_MODE_CHANGE:
607 if (controller->touch_hud_debug()) { 1037 return HandleTouchHudModeChange();
608 controller->touch_hud_debug()->Clear(); 1038 case TOUCH_HUD_PROJECTION_TOGGLE:
609 return true; 1039 return 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;
626 }
627 case DISABLE_GPU_WATCHDOG: 1040 case DISABLE_GPU_WATCHDOG:
628 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); 1041 content::GpuDataManager::GetInstance()->DisableGpuWatchdog();
629 return true; 1042 return true;
630 #endif 1043 #endif // OS_CHROMEOS
631 case OPEN_FEEDBACK_PAGE: 1044 case OPEN_FEEDBACK_PAGE:
632 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); 1045 return HandleOpenFeedbackPage();
633 return true;
634 case EXIT: 1046 case EXIT:
635 // UMA metrics are recorded in the handler. 1047 // UMA metrics are recorded in the handler.
636 exit_warning_handler_.HandleAccelerator(); 1048 exit_warning_handler_.HandleAccelerator();
637 return true; 1049 return true;
638 case NEW_INCOGNITO_WINDOW: { 1050 case NEW_INCOGNITO_WINDOW:
639 bool incognito_allowed = 1051 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: 1052 case NEW_TAB:
647 if (key_code == ui::VKEY_T) 1053 return HandleNewTab(key_code);
648 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T"));
649 Shell::GetInstance()->new_window_delegate()->NewTab();
650 return true;
651 case NEW_WINDOW: 1054 case NEW_WINDOW:
652 Shell::GetInstance()->new_window_delegate()->NewWindow( 1055 return HandleNewWindow();
653 false /* is_incognito */);
654 return true;
655 case RESTORE_TAB: 1056 case RESTORE_TAB:
656 Shell::GetInstance()->new_window_delegate()->RestoreTab(); 1057 return HandleRestoreTab();
657 return true;
658 case TAKE_SCREENSHOT: 1058 case TAKE_SCREENSHOT:
659 if (screenshot_delegate_.get() && 1059 return HandleTakeScreenshot(screenshot_delegate_.get());
660 screenshot_delegate_->CanTakeScreenshot()) {
661 screenshot_delegate_->HandleTakeScreenshotForAllRootWindows();
662 }
663 // Return true to prevent propagation of the key event.
664 return true;
665 case TAKE_PARTIAL_SCREENSHOT: 1060 case TAKE_PARTIAL_SCREENSHOT:
666 if (screenshot_delegate_) { 1061 HandleTakePartialScreenshot(screenshot_delegate_.get());
667 ash::PartialScreenshotView::StartPartialScreenshot(
668 screenshot_delegate_.get());
669 }
670 // Return true to prevent propagation of the key event because
671 // this key combination is reserved for partial screenshot.
672 return true;
673 case TOGGLE_APP_LIST: 1062 case TOGGLE_APP_LIST:
674 // If something else was pressed between the Search key (LWIN) 1063 return HandleToggleAppList(
675 // being pressed and released, then ignore the release of the 1064 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: 1065 case DISABLE_CAPS_LOCK:
693 if (previous_event_type == ui::ET_KEY_RELEASED || 1066 return HandleDisableCapsLock(
694 (previous_key_code != ui::VKEY_LSHIFT && 1067 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: 1068 case TOGGLE_CAPS_LOCK:
707 if (key_code == ui::VKEY_LWIN) { 1069 return HandleToggleCapsLock(
708 // If something else was pressed between the Search key (LWIN) 1070 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: 1071 case BRIGHTNESS_DOWN:
719 if (brightness_control_delegate_) 1072 if (brightness_control_delegate_)
720 return brightness_control_delegate_->HandleBrightnessDown(accelerator); 1073 return brightness_control_delegate_->HandleBrightnessDown(accelerator);
721 break; 1074 break;
722 case BRIGHTNESS_UP: 1075 case BRIGHTNESS_UP:
723 if (brightness_control_delegate_) 1076 if (brightness_control_delegate_)
724 return brightness_control_delegate_->HandleBrightnessUp(accelerator); 1077 return brightness_control_delegate_->HandleBrightnessUp(accelerator);
725 break; 1078 break;
726 case KEYBOARD_BRIGHTNESS_DOWN: 1079 case KEYBOARD_BRIGHTNESS_DOWN:
727 if (keyboard_brightness_control_delegate_) 1080 if (keyboard_brightness_control_delegate_)
(...skipping 14 matching lines...) Expand all
742 ash::VolumeControlDelegate* volume_delegate = 1095 ash::VolumeControlDelegate* volume_delegate =
743 shell->system_tray_delegate()->GetVolumeControlDelegate(); 1096 shell->system_tray_delegate()->GetVolumeControlDelegate();
744 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator); 1097 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator);
745 } 1098 }
746 case VOLUME_UP: { 1099 case VOLUME_UP: {
747 ash::VolumeControlDelegate* volume_delegate = 1100 ash::VolumeControlDelegate* volume_delegate =
748 shell->system_tray_delegate()->GetVolumeControlDelegate(); 1101 shell->system_tray_delegate()->GetVolumeControlDelegate();
749 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator); 1102 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator);
750 } 1103 }
751 case FOCUS_LAUNCHER: 1104 case FOCUS_LAUNCHER:
752 return shell->focus_cycler()->FocusWidget( 1105 return HandleFocusLauncher();
753 Launcher::ForPrimaryDisplay()->shelf_widget());
754 case FOCUS_NEXT_PANE: 1106 case FOCUS_NEXT_PANE:
755 return HandleRotatePaneFocus(Shell::FORWARD); 1107 return HandleRotatePaneFocus(Shell::FORWARD);
756 case FOCUS_PREVIOUS_PANE: 1108 case FOCUS_PREVIOUS_PANE:
757 return HandleRotatePaneFocus(Shell::BACKWARD); 1109 return HandleRotatePaneFocus(Shell::BACKWARD);
758 case SHOW_KEYBOARD_OVERLAY: 1110 case SHOW_KEYBOARD_OVERLAY:
759 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); 1111 return HandleShowKeyboardOverlay();
760 return true;
761 case SHOW_OAK: 1112 case SHOW_OAK:
762 if (CommandLine::ForCurrentProcess()->HasSwitch( 1113 return HandleShowOak();
763 switches::kAshEnableOak)) { 1114 case SHOW_SYSTEM_TRAY_BUBBLE:
764 oak::ShowOakWindowWithContext(Shell::GetPrimaryRootWindow()); 1115 return HandleShowSystemTrayBubble();
765 return true; 1116 case SHOW_MESSAGE_CENTER_BUBBLE:
766 } 1117 HandleShowMessageCenterBubble();
767 break; 1118 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: 1119 case SHOW_TASK_MANAGER:
791 Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); 1120 return HandleShowTaskManager();
792 return true;
793 case NEXT_IME: 1121 case NEXT_IME:
794 // This check is necessary e.g. not to process the Shift+Alt+ 1122 return HandleNextIme(
795 // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/ 1123 ime_control_delegate_.get(), previous_event_type, previous_key_code);
796 // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab
797 // is released.
798 if (previous_event_type == ui::ET_KEY_RELEASED &&
799 // 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
801 // 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
803 // user presses Shift+Alt before releasing Enter.
804 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way.
805 previous_key_code != ui::VKEY_RETURN &&
806 previous_key_code != ui::VKEY_SPACE) {
807 // We totally ignore this accelerator.
808 // TODO(mazda): Fix crbug.com/158217
809 return false;
810 }
811 if (ime_control_delegate_)
812 return ime_control_delegate_->HandleNextIme();
813 break;
814 case PREVIOUS_IME: 1124 case PREVIOUS_IME:
815 if (ime_control_delegate_) 1125 return HandlePreviousIme(ime_control_delegate_.get(), accelerator);
816 return ime_control_delegate_->HandlePreviousIme(accelerator);
817 break;
818 case PRINT_UI_HIERARCHIES: 1126 case PRINT_UI_HIERARCHIES:
819 return HandlePrintUIHierarchies(); 1127 return HandlePrintUIHierarchies();
820 case SWITCH_IME: 1128 case SWITCH_IME:
821 if (ime_control_delegate_) 1129 return HandleSwitchIme(ime_control_delegate_.get(), accelerator);
822 return ime_control_delegate_->HandleSwitchIme(accelerator);
823 break;
824 case LAUNCH_APP_0: 1130 case LAUNCH_APP_0:
825 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(0); 1131 return HandleLaunchApp0();
826 return true;
827 case LAUNCH_APP_1: 1132 case LAUNCH_APP_1:
828 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(1); 1133 return HandleLaunchApp1();
829 return true;
830 case LAUNCH_APP_2: 1134 case LAUNCH_APP_2:
831 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(2); 1135 return HandleLaunchApp2();
832 return true;
833 case LAUNCH_APP_3: 1136 case LAUNCH_APP_3:
834 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(3); 1137 return HandleLaunchApp3();
835 return true;
836 case LAUNCH_APP_4: 1138 case LAUNCH_APP_4:
837 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(4); 1139 return HandleLaunchApp4();
838 return true;
839 case LAUNCH_APP_5: 1140 case LAUNCH_APP_5:
840 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(5); 1141 return HandleLaunchApp5();
841 return true;
842 case LAUNCH_APP_6: 1142 case LAUNCH_APP_6:
843 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(6); 1143 return HandleLaunchApp6();
844 return true;
845 case LAUNCH_APP_7: 1144 case LAUNCH_APP_7:
846 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(7); 1145 return HandleLaunchApp7();
847 return true;
848 case LAUNCH_LAST_APP: 1146 case LAUNCH_LAST_APP:
849 Launcher::ForPrimaryDisplay()->LaunchAppIndexAt(-1); 1147 return HandleLaunchLastApp();
850 return true;
851 case WINDOW_SNAP_LEFT: 1148 case WINDOW_SNAP_LEFT:
852 case WINDOW_SNAP_RIGHT: { 1149 case WINDOW_SNAP_RIGHT:
853 wm::WindowState* window_state = wm::GetActiveWindowState(); 1150 return HandleWindowSnap(action);
854 // Disable window snapping shortcut key for full screen window due to
855 // http://crbug.com/135487.
856 if (!window_state ||
857 window_state->window()->type() != aura::client::WINDOW_TYPE_NORMAL ||
858 window_state->IsFullscreen()) {
859 break;
860 }
861
862 internal::SnapSizer::SnapWindow(window_state,
863 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE :
864 internal::SnapSizer::RIGHT_EDGE);
865 return true;
866 }
867 case WINDOW_MINIMIZE: 1151 case WINDOW_MINIMIZE:
868 return accelerators::ToggleMinimized(); 1152 return accelerators::ToggleMinimized();
869 case TOGGLE_FULLSCREEN: { 1153 case TOGGLE_FULLSCREEN:
870 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) { 1154 return HandleToggleFullscreen(key_code);
871 content::RecordAction( 1155 case TOGGLE_MAXIMIZED:
872 content::UserMetricsAction("Accel_Fullscreen_F4"));
873 }
874 accelerators::ToggleFullscreen();
875 return true;
876 }
877 case TOGGLE_MAXIMIZED: {
878 accelerators::ToggleMaximized(); 1156 accelerators::ToggleMaximized();
879 return true; 1157 return true;
880 } 1158 case WINDOW_POSITION_CENTER:
881 case WINDOW_POSITION_CENTER: { 1159 return HandlePositionCenter();
882 content::RecordAction(content::UserMetricsAction("Accel_Center"));
883 aura::Window* window = wm::GetActiveWindow();
884 // Docked windows do not support centering and ignore accelerator.
885 if (window && !wm::GetWindowState(window)->IsDocked()) {
886 wm::CenterWindow(window);
887 return true;
888 }
889 break;
890 }
891 case SCALE_UI_UP: 1160 case SCALE_UI_UP:
892 return HandleScaleUI(true /* up */); 1161 return HandleScaleUI(true /* up */);
893 case SCALE_UI_DOWN: 1162 case SCALE_UI_DOWN:
894 return HandleScaleUI(false /* down */); 1163 return HandleScaleUI(false /* down */);
895 case SCALE_UI_RESET: 1164 case SCALE_UI_RESET:
896 return HandleScaleReset(); 1165 return HandleScaleReset();
897 case ROTATE_WINDOW: 1166 case ROTATE_WINDOW:
898 return HandleRotateActiveWindow(); 1167 return HandleRotateActiveWindow();
899 case ROTATE_SCREEN: 1168 case ROTATE_SCREEN:
900 return HandleRotateScreen(); 1169 return HandleRotateScreen();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 keyboard_brightness_control_delegate) { 1276 keyboard_brightness_control_delegate) {
1008 keyboard_brightness_control_delegate_ = 1277 keyboard_brightness_control_delegate_ =
1009 keyboard_brightness_control_delegate.Pass(); 1278 keyboard_brightness_control_delegate.Pass();
1010 } 1279 }
1011 1280
1012 bool AcceleratorController::CanHandleAccelerators() const { 1281 bool AcceleratorController::CanHandleAccelerators() const {
1013 return true; 1282 return true;
1014 } 1283 }
1015 1284
1016 } // namespace ash 1285 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_commands.cc ('k') | ash/shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698