| 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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_commands.h" | 7 #include "ash/common/accelerators/accelerator_commands.h" |
| 8 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 8 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
| 9 #include "ash/common/accelerators/debug_commands.h" | 9 #include "ash/common/accelerators/debug_commands.h" |
| 10 #include "ash/common/accessibility_delegate.h" | 10 #include "ash/common/accessibility_delegate.h" |
| 11 #include "ash/common/accessibility_types.h" | 11 #include "ash/common/accessibility_types.h" |
| 12 #include "ash/common/focus_cycler.h" | 12 #include "ash/common/focus_cycler.h" |
| 13 #include "ash/common/ime_control_delegate.h" | 13 #include "ash/common/ime_control_delegate.h" |
| 14 #include "ash/common/media_delegate.h" | 14 #include "ash/common/media_delegate.h" |
| 15 #include "ash/common/multi_profile_uma.h" | 15 #include "ash/common/multi_profile_uma.h" |
| 16 #include "ash/common/new_window_delegate.h" | |
| 17 #include "ash/common/session/session_state_delegate.h" | 16 #include "ash/common/session/session_state_delegate.h" |
| 18 #include "ash/common/shelf/shelf_widget.h" | 17 #include "ash/common/shelf/shelf_widget.h" |
| 19 #include "ash/common/shelf/wm_shelf.h" | 18 #include "ash/common/shelf/wm_shelf.h" |
| 20 #include "ash/common/shell_delegate.h" | 19 #include "ash/common/shell_delegate.h" |
| 21 #include "ash/common/system/brightness_control_delegate.h" | 20 #include "ash/common/system/brightness_control_delegate.h" |
| 22 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 21 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 23 #include "ash/common/system/status_area_widget.h" | 22 #include "ash/common/system/status_area_widget.h" |
| 24 #include "ash/common/system/tray/system_tray_delegate.h" | 23 #include "ash/common/system/tray/system_tray_delegate.h" |
| 25 #include "ash/common/system/tray/system_tray_notifier.h" | 24 #include "ash/common/system/tray/system_tray_notifier.h" |
| 26 #include "ash/common/system/web_notification/web_notification_tray.h" | 25 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 27 #include "ash/common/wm/mru_window_tracker.h" | 26 #include "ash/common/wm/mru_window_tracker.h" |
| 28 #include "ash/common/wm/overview/window_selector_controller.h" | 27 #include "ash/common/wm/overview/window_selector_controller.h" |
| 29 #include "ash/common/wm/window_cycle_controller.h" | 28 #include "ash/common/wm/window_cycle_controller.h" |
| 30 #include "ash/common/wm/window_positioning_utils.h" | 29 #include "ash/common/wm/window_positioning_utils.h" |
| 31 #include "ash/common/wm/window_state.h" | 30 #include "ash/common/wm/window_state.h" |
| 32 #include "ash/common/wm/wm_event.h" | 31 #include "ash/common/wm/wm_event.h" |
| 33 #include "ash/common/wm_root_window_controller.h" | 32 #include "ash/common/wm_root_window_controller.h" |
| 34 #include "ash/common/wm_shell.h" | 33 #include "ash/common/wm_shell.h" |
| 35 #include "ash/common/wm_window.h" | 34 #include "ash/common/wm_window.h" |
| 35 #include "ash/public/interfaces/new_window.mojom.h" |
| 36 #include "base/metrics/histogram_macros.h" | 36 #include "base/metrics/histogram_macros.h" |
| 37 #include "base/metrics/user_metrics.h" | 37 #include "base/metrics/user_metrics.h" |
| 38 #include "services/service_manager/public/cpp/connector.h" | 38 #include "services/service_manager/public/cpp/connector.h" |
| 39 #include "ui/base/accelerators/accelerator.h" | 39 #include "ui/base/accelerators/accelerator.h" |
| 40 #include "ui/base/accelerators/accelerator_manager.h" | 40 #include "ui/base/accelerators/accelerator_manager.h" |
| 41 #include "ui/keyboard/keyboard_controller.h" | 41 #include "ui/keyboard/keyboard_controller.h" |
| 42 | 42 |
| 43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
| 44 #include "ash/common/palette_delegate.h" | 44 #include "ash/common/palette_delegate.h" |
| 45 #include "ash/common/shelf/wm_shelf.h" | 45 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void HandleMediaPrevTrack() { | 136 void HandleMediaPrevTrack() { |
| 137 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); | 137 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool CanHandleNewIncognitoWindow() { | 140 bool CanHandleNewIncognitoWindow() { |
| 141 return WmShell::Get()->delegate()->IsIncognitoAllowed(); | 141 return WmShell::Get()->delegate()->IsIncognitoAllowed(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void HandleNewIncognitoWindow() { | 144 void HandleNewIncognitoWindow() { |
| 145 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); | 145 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); |
| 146 WmShell::Get()->new_window_delegate()->NewWindow(true /* is_incognito */); | 146 WmShell::Get()->new_window_client()->NewWindow(true /* is_incognito */); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void HandleNewTab(const ui::Accelerator& accelerator) { | 149 void HandleNewTab(const ui::Accelerator& accelerator) { |
| 150 if (accelerator.key_code() == ui::VKEY_T) | 150 if (accelerator.key_code() == ui::VKEY_T) |
| 151 base::RecordAction(UserMetricsAction("Accel_NewTab_T")); | 151 base::RecordAction(UserMetricsAction("Accel_NewTab_T")); |
| 152 WmShell::Get()->new_window_delegate()->NewTab(); | 152 WmShell::Get()->new_window_client()->NewTab(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void HandleNewWindow() { | 155 void HandleNewWindow() { |
| 156 base::RecordAction(UserMetricsAction("Accel_New_Window")); | 156 base::RecordAction(UserMetricsAction("Accel_New_Window")); |
| 157 WmShell::Get()->new_window_delegate()->NewWindow(false /* is_incognito */); | 157 WmShell::Get()->new_window_client()->NewWindow(false /* is_incognito */); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { | 160 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { |
| 161 return ime_control_delegate && ime_control_delegate->CanCycleIme(); | 161 return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { | 164 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { |
| 165 // Don't do anything when Alt+Tab comes from a virtual keyboard. Touchscreen | 165 // Don't do anything when Alt+Tab comes from a virtual keyboard. Touchscreen |
| 166 // users have better window switching options. See http://crbug.com/638269 | 166 // users have better window switching options. See http://crbug.com/638269 |
| 167 keyboard::KeyboardController* keyboard_controller = | 167 keyboard::KeyboardController* keyboard_controller = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { | 193 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { |
| 194 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); | 194 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); |
| 195 ime_control_delegate->HandleNextIme(); | 195 ime_control_delegate->HandleNextIme(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void HandleOpenFeedbackPage() { | 198 void HandleOpenFeedbackPage() { |
| 199 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); | 199 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); |
| 200 WmShell::Get()->new_window_delegate()->OpenFeedbackPage(); | 200 WmShell::Get()->new_window_client()->OpenFeedbackPage(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { | 203 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { |
| 204 return ime_control_delegate && ime_control_delegate->CanCycleIme(); | 204 return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, | 207 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, |
| 208 const ui::Accelerator& accelerator) { | 208 const ui::Accelerator& accelerator) { |
| 209 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); | 209 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); |
| 210 if (accelerator.type() == ui::ET_KEY_PRESSED) | 210 if (accelerator.type() == ui::ET_KEY_PRESSED) |
| 211 ime_control_delegate->HandlePreviousIme(); | 211 ime_control_delegate->HandlePreviousIme(); |
| 212 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. | 212 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. |
| 213 } | 213 } |
| 214 | 214 |
| 215 void HandleRestoreTab() { | 215 void HandleRestoreTab() { |
| 216 base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); | 216 base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); |
| 217 WmShell::Get()->new_window_delegate()->RestoreTab(); | 217 WmShell::Get()->new_window_client()->RestoreTab(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void HandleShowKeyboardOverlay() { | 220 void HandleShowKeyboardOverlay() { |
| 221 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); | 221 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); |
| 222 WmShell::Get()->new_window_delegate()->ShowKeyboardOverlay(); | 222 WmShell::Get()->new_window_client()->ShowKeyboardOverlay(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool CanHandleShowMessageCenterBubble() { | 225 bool CanHandleShowMessageCenterBubble() { |
| 226 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); | 226 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); |
| 227 StatusAreaWidget* status_area_widget = | 227 StatusAreaWidget* status_area_widget = |
| 228 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); | 228 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); |
| 229 return status_area_widget && | 229 return status_area_widget && |
| 230 status_area_widget->web_notification_tray()->visible(); | 230 status_area_widget->web_notification_tray()->visible(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void HandleShowMessageCenterBubble() { | 233 void HandleShowMessageCenterBubble() { |
| 234 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); | 234 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); |
| 235 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); | 235 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); |
| 236 StatusAreaWidget* status_area_widget = | 236 StatusAreaWidget* status_area_widget = |
| 237 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); | 237 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); |
| 238 if (status_area_widget) { | 238 if (status_area_widget) { |
| 239 WebNotificationTray* notification_tray = | 239 WebNotificationTray* notification_tray = |
| 240 status_area_widget->web_notification_tray(); | 240 status_area_widget->web_notification_tray(); |
| 241 if (notification_tray->visible()) | 241 if (notification_tray->visible()) |
| 242 notification_tray->ShowMessageCenterBubble(); | 242 notification_tray->ShowMessageCenterBubble(); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 void HandleShowTaskManager() { | 246 void HandleShowTaskManager() { |
| 247 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); | 247 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); |
| 248 WmShell::Get()->new_window_delegate()->ShowTaskManager(); | 248 WmShell::Get()->new_window_client()->ShowTaskManager(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, | 251 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
| 252 const ui::Accelerator& accelerator) { | 252 const ui::Accelerator& accelerator) { |
| 253 return ime_control_delegate && | 253 return ime_control_delegate && |
| 254 ime_control_delegate->CanSwitchIme(accelerator); | 254 ime_control_delegate->CanSwitchIme(accelerator); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, | 257 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
| 258 const ui::Accelerator& accelerator) { | 258 const ui::Accelerator& accelerator) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 if (ime_menu_tray && ime_menu_tray->visible() && | 350 if (ime_menu_tray && ime_menu_tray->visible() && |
| 351 !ime_menu_tray->IsImeMenuBubbleShown()) { | 351 !ime_menu_tray->IsImeMenuBubbleShown()) { |
| 352 ime_menu_tray->ShowImeMenuBubble(); | 352 ime_menu_tray->ShowImeMenuBubble(); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 void HandleCrosh() { | 357 void HandleCrosh() { |
| 358 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); | 358 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); |
| 359 | 359 |
| 360 WmShell::Get()->new_window_delegate()->OpenCrosh(); | 360 WmShell::Get()->new_window_client()->OpenCrosh(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { | 363 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { |
| 364 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); | 364 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
| 365 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || | 365 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || |
| 366 (previous_key_code != ui::VKEY_LSHIFT && | 366 (previous_key_code != ui::VKEY_LSHIFT && |
| 367 previous_key_code != ui::VKEY_SHIFT && | 367 previous_key_code != ui::VKEY_SHIFT && |
| 368 previous_key_code != ui::VKEY_RSHIFT)) { | 368 previous_key_code != ui::VKEY_RSHIFT)) { |
| 369 // If something else was pressed between the Shift key being pressed | 369 // If something else was pressed between the Shift key being pressed |
| 370 // and released, then ignore the release of the Shift key. | 370 // and released, then ignore the release of the Shift key. |
| 371 return false; | 371 return false; |
| 372 } | 372 } |
| 373 chromeos::input_method::InputMethodManager* ime = | 373 chromeos::input_method::InputMethodManager* ime = |
| 374 chromeos::input_method::InputMethodManager::Get(); | 374 chromeos::input_method::InputMethodManager::Get(); |
| 375 chromeos::input_method::ImeKeyboard* keyboard = | 375 chromeos::input_method::ImeKeyboard* keyboard = |
| 376 ime ? ime->GetImeKeyboard() : NULL; | 376 ime ? ime->GetImeKeyboard() : NULL; |
| 377 return (keyboard && keyboard->CapsLockIsEnabled()); | 377 return (keyboard && keyboard->CapsLockIsEnabled()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void HandleDisableCapsLock() { | 380 void HandleDisableCapsLock() { |
| 381 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); | 381 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); |
| 382 chromeos::input_method::InputMethodManager* ime = | 382 chromeos::input_method::InputMethodManager* ime = |
| 383 chromeos::input_method::InputMethodManager::Get(); | 383 chromeos::input_method::InputMethodManager::Get(); |
| 384 ime->GetImeKeyboard()->SetCapsLockEnabled(false); | 384 ime->GetImeKeyboard()->SetCapsLockEnabled(false); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void HandleFileManager() { | 387 void HandleFileManager() { |
| 388 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 388 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
| 389 | 389 |
| 390 WmShell::Get()->new_window_delegate()->OpenFileManager(); | 390 WmShell::Get()->new_window_client()->OpenFileManager(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void HandleGetHelp() { | 393 void HandleGetHelp() { |
| 394 WmShell::Get()->new_window_delegate()->OpenGetHelp(); | 394 WmShell::Get()->new_window_client()->OpenGetHelp(); |
| 395 } | 395 } |
| 396 | 396 |
| 397 bool CanHandleLock() { | 397 bool CanHandleLock() { |
| 398 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); | 398 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void HandleLock() { | 401 void HandleLock() { |
| 402 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 402 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
| 403 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 403 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 404 } | 404 } |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 base::Unretained(this))); | 1134 base::Unretained(this))); |
| 1135 } | 1135 } |
| 1136 return volume_controller_.get(); | 1136 return volume_controller_.get(); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 void AcceleratorController::OnVolumeControllerConnectionError() { | 1139 void AcceleratorController::OnVolumeControllerConnectionError() { |
| 1140 volume_controller_.reset(); | 1140 volume_controller_.reset(); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 } // namespace ash | 1143 } // namespace ash |
| OLD | NEW |