diff --git a/ash/accelerators/accelerator_controller_delegate_aura.cc b/ash/accelerators/accelerator_controller_delegate_aura.cc index 538e4a43f44c18..d6e5258b255a09 100644 --- a/ash/accelerators/accelerator_controller_delegate_aura.cc +++ b/ash/accelerators/accelerator_controller_delegate_aura.cc @@ -35,7 +35,6 @@ #include "ash/host/ash_window_tree_host.h" #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" -#include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" #include "ash/rotator/screen_rotation_animator.h" #include "ash/rotator/window_rotation.h" @@ -180,38 +179,6 @@ void HandleMagnifyScreen(int delta_index) { } } -bool CanHandleNewIncognitoWindow() { - return WmShell::Get()->delegate()->IsIncognitoAllowed(); -} - -void HandleNewIncognitoWindow() { - base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); - Shell::GetInstance()->new_window_delegate()->NewWindow( - true /* is_incognito */); -} - -void HandleNewTab(const ui::Accelerator& accelerator) { - if (accelerator.key_code() == ui::VKEY_T) - base::RecordAction(UserMetricsAction("Accel_NewTab_T")); - Shell::GetInstance()->new_window_delegate()->NewTab(); -} - -void HandleNewWindow() { - base::RecordAction(UserMetricsAction("Accel_New_Window")); - Shell::GetInstance()->new_window_delegate()->NewWindow( - false /* is_incognito */); -} - -void HandleOpenFeedbackPage() { - base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); - Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); -} - -void HandleRestoreTab() { - base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); - Shell::GetInstance()->new_window_delegate()->RestoreTab(); -} - display::Display::Rotation GetNextRotation(display::Display::Rotation current) { switch (current) { case display::Display::ROTATE_0: @@ -260,11 +227,6 @@ void HandleRotateActiveWindow() { } } -void HandleShowKeyboardOverlay() { - base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); - Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); -} - bool CanHandleShowMessageCenterBubble() { RootWindowController* controller = RootWindowController::ForTargetRootWindow(); @@ -296,11 +258,6 @@ void HandleShowSystemTrayBubble() { controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); } -void HandleShowTaskManager() { - base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); - Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); -} - void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) { base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot")); DCHECK(screenshot_delegate); @@ -398,22 +355,6 @@ bool CanHandleUnpin() { } #if defined(OS_CHROMEOS) -void HandleCrosh() { - base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); - - Shell::GetInstance()->new_window_delegate()->OpenCrosh(); -} - -void HandleFileManager() { - base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); - - Shell::GetInstance()->new_window_delegate()->OpenFileManager(); -} - -void HandleGetHelp() { - Shell::GetInstance()->new_window_delegate()->OpenGetHelp(); -} - void HandleSwapPrimaryDisplay() { base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId( @@ -475,20 +416,13 @@ bool AcceleratorControllerDelegateAura::HandlesAction( case LAUNCH_LAST_APP: case MAGNIFY_SCREEN_ZOOM_IN: case MAGNIFY_SCREEN_ZOOM_OUT: - case NEW_INCOGNITO_WINDOW: - case NEW_TAB: - case NEW_WINDOW: - case OPEN_FEEDBACK_PAGE: - case RESTORE_TAB: case ROTATE_SCREEN: case ROTATE_WINDOW: case SCALE_UI_DOWN: case SCALE_UI_RESET: case SCALE_UI_UP: - case SHOW_KEYBOARD_OVERLAY: case SHOW_MESSAGE_CENTER_BUBBLE: case SHOW_SYSTEM_TRAY_BUBBLE: - case SHOW_TASK_MANAGER: case TAKE_PARTIAL_SCREENSHOT: case TAKE_SCREENSHOT: case TAKE_WINDOW_SCREENSHOT: @@ -502,9 +436,6 @@ bool AcceleratorControllerDelegateAura::HandlesAction( case DISABLE_GPU_WATCHDOG: case LOCK_PRESSED: case LOCK_RELEASED: - case OPEN_CROSH: - case OPEN_FILE_MANAGER: - case OPEN_GET_HELP: case POWER_PRESSED: case POWER_RELEASED: case SWAP_PRIMARY_DISPLAY: @@ -536,8 +467,6 @@ bool AcceleratorControllerDelegateAura::CanPerformAction( case MAGNIFY_SCREEN_ZOOM_IN: case MAGNIFY_SCREEN_ZOOM_OUT: return CanHandleMagnifyScreen(); - case NEW_INCOGNITO_WINDOW: - return CanHandleNewIncognitoWindow(); case SCALE_UI_DOWN: case SCALE_UI_RESET: case SCALE_UI_UP: @@ -560,15 +489,9 @@ bool AcceleratorControllerDelegateAura::CanPerformAction( case LAUNCH_APP_6: case LAUNCH_APP_7: case LAUNCH_LAST_APP: - case NEW_TAB: - case NEW_WINDOW: - case OPEN_FEEDBACK_PAGE: - case RESTORE_TAB: case ROTATE_SCREEN: case ROTATE_WINDOW: - case SHOW_KEYBOARD_OVERLAY: case SHOW_SYSTEM_TRAY_BUBBLE: - case SHOW_TASK_MANAGER: case TAKE_PARTIAL_SCREENSHOT: case TAKE_SCREENSHOT: case TAKE_WINDOW_SCREENSHOT: @@ -589,9 +512,6 @@ bool AcceleratorControllerDelegateAura::CanPerformAction( case DISABLE_GPU_WATCHDOG: case LOCK_PRESSED: case LOCK_RELEASED: - case OPEN_CROSH: - case OPEN_FILE_MANAGER: - case OPEN_GET_HELP: case POWER_PRESSED: case POWER_RELEASED: case TOGGLE_MIRROR_MODE: @@ -664,21 +584,6 @@ void AcceleratorControllerDelegateAura::PerformAction( case MAGNIFY_SCREEN_ZOOM_OUT: HandleMagnifyScreen(-1); break; - case NEW_INCOGNITO_WINDOW: - HandleNewIncognitoWindow(); - break; - case NEW_TAB: - HandleNewTab(accelerator); - break; - case NEW_WINDOW: - HandleNewWindow(); - break; - case OPEN_FEEDBACK_PAGE: - HandleOpenFeedbackPage(); - break; - case RESTORE_TAB: - HandleRestoreTab(); - break; case ROTATE_SCREEN: HandleRotateScreen(); break; @@ -694,18 +599,12 @@ void AcceleratorControllerDelegateAura::PerformAction( case SCALE_UI_UP: accelerators::ZoomInternalDisplay(true /* up */); break; - case SHOW_KEYBOARD_OVERLAY: - HandleShowKeyboardOverlay(); - break; case SHOW_MESSAGE_CENTER_BUBBLE: HandleShowMessageCenterBubble(); break; case SHOW_SYSTEM_TRAY_BUBBLE: HandleShowSystemTrayBubble(); break; - case SHOW_TASK_MANAGER: - HandleShowTaskManager(); - break; case TAKE_PARTIAL_SCREENSHOT: HandleTakePartialScreenshot(screenshot_delegate_.get()); break; @@ -737,15 +636,6 @@ void AcceleratorControllerDelegateAura::PerformAction( Shell::GetInstance()->power_button_controller()->OnLockButtonEvent( action == LOCK_PRESSED, base::TimeTicks()); break; - case OPEN_CROSH: - HandleCrosh(); - break; - case OPEN_FILE_MANAGER: - HandleFileManager(); - break; - case OPEN_GET_HELP: - HandleGetHelp(); - break; case POWER_PRESSED: // fallthrough case POWER_RELEASED: if (!base::SysInfo::IsRunningOnChromeOS()) { diff --git a/ash/common/accelerators/accelerator_controller.cc b/ash/common/accelerators/accelerator_controller.cc index b8be032df449ec..28afb1f0e9f136 100644 --- a/ash/common/accelerators/accelerator_controller.cc +++ b/ash/common/accelerators/accelerator_controller.cc @@ -13,6 +13,7 @@ #include "ash/common/ime_control_delegate.h" #include "ash/common/media_delegate.h" #include "ash/common/multi_profile_uma.h" +#include "ash/common/new_window_delegate.h" #include "ash/common/session/session_state_delegate.h" #include "ash/common/shell_delegate.h" #include "ash/common/system/brightness_control_delegate.h" @@ -105,6 +106,26 @@ void HandleMediaPrevTrack() { WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); } +bool CanHandleNewIncognitoWindow() { + return WmShell::Get()->delegate()->IsIncognitoAllowed(); +} + +void HandleNewIncognitoWindow() { + base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); + WmShell::Get()->new_window_delegate()->NewWindow(true /* is_incognito */); +} + +void HandleNewTab(const ui::Accelerator& accelerator) { + if (accelerator.key_code() == ui::VKEY_T) + base::RecordAction(UserMetricsAction("Accel_NewTab_T")); + WmShell::Get()->new_window_delegate()->NewTab(); +} + +void HandleNewWindow() { + base::RecordAction(UserMetricsAction("Accel_New_Window")); + WmShell::Get()->new_window_delegate()->NewWindow(false /* is_incognito */); +} + bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { return ime_control_delegate && ime_control_delegate->CanCycleIme(); } @@ -134,6 +155,11 @@ void HandleNextIme(ImeControlDelegate* ime_control_delegate) { ime_control_delegate->HandleNextIme(); } +void HandleOpenFeedbackPage() { + base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); + WmShell::Get()->new_window_delegate()->OpenFeedbackPage(); +} + bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { return ime_control_delegate && ime_control_delegate->CanCycleIme(); } @@ -146,6 +172,21 @@ void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. } +void HandleRestoreTab() { + base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); + WmShell::Get()->new_window_delegate()->RestoreTab(); +} + +void HandleShowKeyboardOverlay() { + base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); + WmShell::Get()->new_window_delegate()->ShowKeyboardOverlay(); +} + +void HandleShowTaskManager() { + base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); + WmShell::Get()->new_window_delegate()->ShowTaskManager(); +} + bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, const ui::Accelerator& accelerator) { return ime_control_delegate && @@ -211,6 +252,12 @@ void HandlePositionCenter() { } #if defined(OS_CHROMEOS) +void HandleCrosh() { + base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); + + WmShell::Get()->new_window_delegate()->OpenCrosh(); +} + bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); if (previous_accelerator.type() == ui::ET_KEY_RELEASED || @@ -235,6 +282,16 @@ void HandleDisableCapsLock() { ime->GetImeKeyboard()->SetCapsLockEnabled(false); } +void HandleFileManager() { + base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); + + WmShell::Get()->new_window_delegate()->OpenFileManager(); +} + +void HandleGetHelp() { + WmShell::Get()->new_window_delegate()->OpenGetHelp(); +} + bool CanHandleLock() { return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); } @@ -568,6 +625,8 @@ bool AcceleratorController::CanPerformAction( case DEBUG_PRINT_VIEW_HIERARCHY: case DEBUG_PRINT_WINDOW_HIERARCHY: return debug::DebugAcceleratorsEnabled(); + case NEW_INCOGNITO_WINDOW: + return CanHandleNewIncognitoWindow(); case NEXT_IME: return CanHandleNextIme(ime_control_delegate_.get()); case PREVIOUS_IME: @@ -603,7 +662,13 @@ bool AcceleratorController::CanPerformAction( case MEDIA_NEXT_TRACK: case MEDIA_PLAY_PAUSE: case MEDIA_PREV_TRACK: + case NEW_TAB: + case NEW_WINDOW: + case OPEN_FEEDBACK_PAGE: case PRINT_UI_HIERARCHIES: + case RESTORE_TAB: + case SHOW_KEYBOARD_OVERLAY: + case SHOW_TASK_MANAGER: case TOGGLE_FULLSCREEN: case TOGGLE_MAXIMIZED: case TOGGLE_OVERVIEW: @@ -613,6 +678,9 @@ bool AcceleratorController::CanPerformAction( case BRIGHTNESS_UP: case KEYBOARD_BRIGHTNESS_DOWN: case KEYBOARD_BRIGHTNESS_UP: + case OPEN_CROSH: + case OPEN_FILE_MANAGER: + case OPEN_GET_HELP: case SUSPEND: case TOGGLE_SPOKEN_FEEDBACK: case TOGGLE_WIFI: @@ -674,15 +742,36 @@ void AcceleratorController::PerformAction(AcceleratorAction action, case MEDIA_PREV_TRACK: HandleMediaPrevTrack(); break; + case NEW_INCOGNITO_WINDOW: + HandleNewIncognitoWindow(); + break; + case NEW_TAB: + HandleNewTab(accelerator); + break; + case NEW_WINDOW: + HandleNewWindow(); + break; case NEXT_IME: HandleNextIme(ime_control_delegate_.get()); break; + case OPEN_FEEDBACK_PAGE: + HandleOpenFeedbackPage(); + break; case PREVIOUS_IME: HandlePreviousIme(ime_control_delegate_.get(), accelerator); break; case PRINT_UI_HIERARCHIES: debug::PrintUIHierarchies(); break; + case RESTORE_TAB: + HandleRestoreTab(); + break; + case SHOW_KEYBOARD_OVERLAY: + HandleShowKeyboardOverlay(); + break; + case SHOW_TASK_MANAGER: + HandleShowTaskManager(); + break; case SWITCH_IME: HandleSwitchIme(ime_control_delegate_.get(), accelerator); break; @@ -746,6 +835,15 @@ void AcceleratorController::PerformAction(AcceleratorAction action, case LOCK_SCREEN: HandleLock(); break; + case OPEN_CROSH: + HandleCrosh(); + break; + case OPEN_FILE_MANAGER: + HandleFileManager(); + break; + case OPEN_GET_HELP: + HandleGetHelp(); + break; case SUSPEND: HandleSuspend(); break; diff --git a/ash/new_window_delegate.h b/ash/common/new_window_delegate.h similarity index 90% rename from ash/new_window_delegate.h rename to ash/common/new_window_delegate.h index dc88772bf0a0dd..3a8b764690ea65 100644 --- a/ash/new_window_delegate.h +++ b/ash/common/new_window_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_NEW_WINDOW_DELEGATE_H_ -#define ASH_NEW_WINDOW_DELEGATE_H_ +#ifndef ASH_COMMON_NEW_WINDOW_DELEGATE_H_ +#define ASH_COMMON_NEW_WINDOW_DELEGATE_H_ namespace ash { @@ -43,4 +43,4 @@ class NewWindowDelegate { } // namespace ash -#endif // ASH_NEW_WINDOW_DELEGATE_H_ +#endif // ASH_COMMON_NEW_WINDOW_DELEGATE_H_ diff --git a/ash/common/wm_shell.cc b/ash/common/wm_shell.cc index 53e4559bfe52d1..5ad467936d6084 100644 --- a/ash/common/wm_shell.cc +++ b/ash/common/wm_shell.cc @@ -11,6 +11,7 @@ #include "ash/common/accessibility_delegate.h" #include "ash/common/focus_cycler.h" #include "ash/common/keyboard/keyboard_ui.h" +#include "ash/common/new_window_delegate.h" #include "ash/common/session/session_state_delegate.h" #include "ash/common/shelf/app_list_shelf_item_delegate.h" #include "ash/common/shelf/shelf_delegate.h" @@ -67,6 +68,8 @@ void WmShell::Initialize() { // Install the custom factory early on so that views::FocusManagers for Tray, // Shelf, and WallPaper could be created by the factory. views::FocusManagerFactory::Install(new AshFocusManagerFactory); + + new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); } void WmShell::Shutdown() { diff --git a/ash/common/wm_shell.h b/ash/common/wm_shell.h index 38a91d04865a9b..79968ecf6f5c37 100644 --- a/ash/common/wm_shell.h +++ b/ash/common/wm_shell.h @@ -36,6 +36,7 @@ class KeyboardBrightnessControlDelegate; class KeyboardUI; class MaximizeModeController; class MruWindowTracker; +class NewWindowDelegate; class ScopedDisableInternalMouseAndKeyboard; class SessionStateDelegate; class ShelfDelegate; @@ -106,6 +107,10 @@ class ASH_EXPORT WmShell { MediaDelegate* media_delegate() { return media_delegate_.get(); } + NewWindowDelegate* new_window_delegate() { + return new_window_delegate_.get(); + } + ShelfDelegate* shelf_delegate() { return shelf_delegate_.get(); } ShelfModel* shelf_model() { return shelf_model_.get(); } @@ -333,6 +338,7 @@ class ASH_EXPORT WmShell { std::unique_ptr maximize_mode_controller_; std::unique_ptr media_delegate_; std::unique_ptr mru_window_tracker_; + std::unique_ptr new_window_delegate_; std::unique_ptr shelf_delegate_; std::unique_ptr shelf_model_; std::unique_ptr system_tray_notifier_; diff --git a/ash/display/display_util.cc b/ash/display/display_util.cc index bd1c2e326f2fc9..f5fba968680a11 100644 --- a/ash/display/display_util.cc +++ b/ash/display/display_util.cc @@ -7,10 +7,11 @@ #include #include "ash/common/display/display_info.h" +#include "ash/common/new_window_delegate.h" #include "ash/common/system/system_notifier.h" +#include "ash/common/wm_shell.h" #include "ash/display/display_manager.h" #include "ash/host/ash_window_tree_host.h" -#include "ash/new_window_delegate.h" #include "ash/shell.h" #include "base/strings/string_number_conversions.h" #include "grit/ash_resources.h" @@ -48,7 +49,7 @@ class DisplayErrorNotificationDelegate bool HasClickedListener() override { return true; } void Click() override { - Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); + WmShell::Get()->new_window_delegate()->OpenFeedbackPage(); } private: diff --git a/ash/mus/BUILD.gn b/ash/mus/BUILD.gn index 1eace08d72060d..9485de773d2865 100644 --- a/ash/mus/BUILD.gn +++ b/ash/mus/BUILD.gn @@ -56,6 +56,8 @@ source_set("lib") { "frame/non_client_frame_view_mash.h", "layout_manager.cc", "layout_manager.h", + "new_window_delegate_mus.cc", + "new_window_delegate_mus.h", "non_client_frame_controller.cc", "non_client_frame_controller.h", "property_util.cc", diff --git a/ash/mus/accelerators/accelerator_controller_delegate_mus.cc b/ash/mus/accelerators/accelerator_controller_delegate_mus.cc index fad534375ce5cf..099e1e6d6001ea 100644 --- a/ash/mus/accelerators/accelerator_controller_delegate_mus.cc +++ b/ash/mus/accelerators/accelerator_controller_delegate_mus.cc @@ -38,20 +38,13 @@ bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) { case LAUNCH_LAST_APP: case MAGNIFY_SCREEN_ZOOM_IN: case MAGNIFY_SCREEN_ZOOM_OUT: - case NEW_INCOGNITO_WINDOW: - case NEW_TAB: - case NEW_WINDOW: - case OPEN_FEEDBACK_PAGE: - case RESTORE_TAB: case ROTATE_SCREEN: case ROTATE_WINDOW: case SCALE_UI_DOWN: case SCALE_UI_RESET: case SCALE_UI_UP: - case SHOW_KEYBOARD_OVERLAY: case SHOW_MESSAGE_CENTER_BUBBLE: case SHOW_SYSTEM_TRAY_BUBBLE: - case SHOW_TASK_MANAGER: case TAKE_PARTIAL_SCREENSHOT: case TAKE_SCREENSHOT: case TAKE_WINDOW_SCREENSHOT: @@ -66,9 +59,6 @@ bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) { case DISABLE_GPU_WATCHDOG: case LOCK_PRESSED: case LOCK_RELEASED: - case OPEN_CROSH: - case OPEN_FILE_MANAGER: - case OPEN_GET_HELP: case POWER_PRESSED: case POWER_RELEASED: case SWAP_PRIMARY_DISPLAY: diff --git a/ash/mus/new_window_delegate_mus.cc b/ash/mus/new_window_delegate_mus.cc new file mode 100644 index 00000000000000..cb707461cb1baa --- /dev/null +++ b/ash/mus/new_window_delegate_mus.cc @@ -0,0 +1,63 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/mus/new_window_delegate_mus.h" + +#include "base/logging.h" +#include "services/shell/public/cpp/connector.h" + +namespace ash { +namespace mus { + +NewWindowDelegateMus::NewWindowDelegateMus() {} + +NewWindowDelegateMus::~NewWindowDelegateMus() {} + +void NewWindowDelegateMus::NewTab() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::NewWindow(bool incognito) { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::OpenFileManager() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::OpenCrosh() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::OpenGetHelp() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::RestoreTab() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::ShowKeyboardOverlay() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::ShowTaskManager() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +void NewWindowDelegateMus::OpenFeedbackPage() { + // TODO: http://crbug.com/631836. + NOTIMPLEMENTED(); +} + +} // namespace mus +} // namespace ash diff --git a/ash/mus/new_window_delegate_mus.h b/ash/mus/new_window_delegate_mus.h new file mode 100644 index 00000000000000..57dfb0223cefeb --- /dev/null +++ b/ash/mus/new_window_delegate_mus.h @@ -0,0 +1,37 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_MUS_NEW_WINDOW_DELEGATE_MUS_H_ +#define ASH_MUS_NEW_WINDOW_DELEGATE_MUS_H_ + +#include "ash/common/new_window_delegate.h" +#include "base/macros.h" + +namespace ash { +namespace mus { + +class NewWindowDelegateMus : public NewWindowDelegate { + public: + NewWindowDelegateMus(); + ~NewWindowDelegateMus() override; + + // NewWindowDelegate: + void NewTab() override; + void NewWindow(bool incognito) override; + void OpenFileManager() override; + void OpenCrosh() override; + void OpenGetHelp() override; + void RestoreTab() override; + void ShowKeyboardOverlay() override; + void ShowTaskManager() override; + void OpenFeedbackPage() override; + + private: + DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateMus); +}; + +} // namespace mus +} // namespace ash + +#endif // ASH_MUS_NEW_WINDOW_DELEGATE_MUS_H_ diff --git a/ash/mus/shell_delegate_mus.cc b/ash/mus/shell_delegate_mus.cc index 301f6157a9a78b..15c61802d1e1cb 100644 --- a/ash/mus/shell_delegate_mus.cc +++ b/ash/mus/shell_delegate_mus.cc @@ -12,6 +12,7 @@ #include "ash/common/session/session_state_delegate.h" #include "ash/common/system/tray/default_system_tray_delegate.h" #include "ash/mus/accessibility_delegate_mus.h" +#include "ash/mus/new_window_delegate_mus.h" #include "base/memory/ptr_util.h" #include "base/strings/string16.h" #include "components/user_manager/user_info_impl.h" @@ -187,8 +188,7 @@ AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() { } NewWindowDelegate* ShellDelegateMus::CreateNewWindowDelegate() { - NOTIMPLEMENTED(); - return nullptr; + return new mus::NewWindowDelegateMus; } MediaDelegate* ShellDelegateMus::CreateMediaDelegate() { diff --git a/ash/shell.cc b/ash/shell.cc index 9e2914b44a1aaf..7601bb0c045fa4 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -54,7 +54,6 @@ #include "ash/keyboard_uma_event_filter.h" #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" -#include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_widget.h" @@ -710,7 +709,6 @@ Shell::~Shell() { window_tree_host_manager_.reset(); focus_client_.reset(); screen_position_controller_.reset(); - new_window_delegate_.reset(); pointer_watcher_delegate_.reset(); keyboard::KeyboardController::ResetInstance(nullptr); @@ -951,7 +949,6 @@ void Shell::Init(const ShellInitParams& init_params) { session_state_delegate_.reset( wm_shell_->delegate()->CreateSessionStateDelegate()); - new_window_delegate_.reset(wm_shell_->delegate()->CreateNewWindowDelegate()); pointer_watcher_delegate_ = wm_shell_->delegate()->CreatePointerWatcherDelegate(); diff --git a/ash/shell.h b/ash/shell.h index 23c849be76d7a5..0aaffda7d26166 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -102,7 +102,6 @@ class LockStateController; enum class LoginStatus; class MagnificationController; class MouseCursorEventFilter; -class NewWindowDelegate; class OverlayEventFilter; class PartialMagnificationController; class PointerWatcherDelegate; @@ -343,10 +342,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, return session_state_delegate_.get(); } - NewWindowDelegate* new_window_delegate() { - return new_window_delegate_.get(); - } - HighContrastController* high_contrast_controller() { return high_contrast_controller_.get(); } @@ -549,7 +544,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, accelerator_controller_delegate_; std::unique_ptr user_wallpaper_delegate_; std::unique_ptr session_state_delegate_; - std::unique_ptr new_window_delegate_; std::unique_ptr pointer_watcher_delegate_; std::unique_ptr shelf_window_watcher_; std::unique_ptr window_positioner_; diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index e3fee20c9fe996..3bbc53e073f7a5 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -9,12 +9,12 @@ #include "ash/common/default_accessibility_delegate.h" #include "ash/common/gpu_support_stub.h" #include "ash/common/media_delegate.h" +#include "ash/common/new_window_delegate.h" #include "ash/common/session/session_state_delegate.h" #include "ash/common/shell_window_ids.h" #include "ash/common/system/tray/default_system_tray_delegate.h" #include "ash/common/wm/window_state.h" #include "ash/default_user_wallpaper_delegate.h" -#include "ash/new_window_delegate.h" #include "ash/pointer_watcher_delegate_aura.h" #include "ash/shell.h" #include "ash/shell/context_menu.h" diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index 07e7c185a05159..1bcca4aa636701 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -11,11 +11,11 @@ #include "ash/common/default_accessibility_delegate.h" #include "ash/common/gpu_support_stub.h" #include "ash/common/media_delegate.h" +#include "ash/common/new_window_delegate.h" #include "ash/common/session/session_state_delegate.h" #include "ash/common/shell_window_ids.h" #include "ash/common/wm/window_state.h" #include "ash/common/wm_shell.h" -#include "ash/new_window_delegate.h" #include "ash/pointer_watcher_delegate_aura.h" #include "ash/test/test_keyboard_ui.h" #include "ash/test/test_session_state_delegate.h" diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate.h b/chrome/browser/ui/ash/chrome_new_window_delegate.h index 5537a6ca3dab27..16701249310b9c 100644 --- a/chrome/browser/ui/ash/chrome_new_window_delegate.h +++ b/chrome/browser/ui/ash/chrome_new_window_delegate.h @@ -7,7 +7,7 @@ #include -#include "ash/new_window_delegate.h" +#include "ash/common/new_window_delegate.h" #include "base/compiler_specific.h" #include "base/macros.h" diff --git a/chrome/browser/ui/ash/chrome_new_window_delegate_browsertest.cc b/chrome/browser/ui/ash/chrome_new_window_delegate_browsertest.cc index 559678ed142b70..c05daebb4ad8f9 100644 --- a/chrome/browser/ui/ash/chrome_new_window_delegate_browsertest.cc +++ b/chrome/browser/ui/ash/chrome_new_window_delegate_browsertest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/new_window_delegate.h" -#include "ash/shell.h" +#include "ash/common/new_window_delegate.h" +#include "ash/common/wm_shell.h" #include "ash/wm/window_util.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser_finder.h" @@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest, Profile* profile1 = ProfileManager::GetActiveUserProfile(); Browser* browser1 = CreateBrowser(profile1); // The newly created window should be created for the current active profile. - ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false); + ash::WmShell::Get()->new_window_delegate()->NewWindow(false); EXPECT_EQ( chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow())->profile(), profile1); @@ -47,7 +47,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest, Browser* browser2 = CreateBrowser(profile2); // The newly created window should be created for the current active window's // profile, which is |profile2|. - ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false); + ash::WmShell::Get()->new_window_delegate()->NewWindow(false); EXPECT_EQ( chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow())->profile(), profile2); @@ -55,7 +55,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest, // After activating |browser1|, the newly created window should be created // against |browser1|'s profile. browser1->window()->Show(); - ash::Shell::GetInstance()->new_window_delegate()->NewWindow(false); + ash::WmShell::Get()->new_window_delegate()->NewWindow(false); EXPECT_EQ( chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow())->profile(), profile1); @@ -64,7 +64,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest, // The newly created incoginito window should be created against the current // active |browser1|'s profile. browser1->window()->Show(); - ash::Shell::GetInstance()->new_window_delegate()->NewWindow(true); + ash::WmShell::Get()->new_window_delegate()->NewWindow(true); EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()) ->profile() ->GetOriginalProfile(), @@ -73,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(ChromeNewWindowDelegateBrowserTest, // The newly created incoginito window should be created against the current // active |browser2|'s profile. browser2->window()->Show(); - ash::Shell::GetInstance()->new_window_delegate()->NewWindow(true); + ash::WmShell::Get()->new_window_delegate()->NewWindow(true); EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()) ->profile() ->GetOriginalProfile(), diff --git a/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc b/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc index 0429a44a16ddeb..b234d695179ec9 100644 --- a/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc @@ -6,8 +6,8 @@ #include -#include "ash/new_window_delegate.h" -#include "ash/shell.h" +#include "ash/common/new_window_delegate.h" +#include "ash/common/wm_shell.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" @@ -175,7 +175,7 @@ void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() { } void KeyboardHandler::HandleShowKeyboardShortcuts(const base::ListValue* args) { - ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); + ash::WmShell::Get()->new_window_delegate()->ShowKeyboardOverlay(); } void KeyboardHandler::UpdateCapsLockOptions() const { diff --git a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc index 84867f5e947ed4..d2e5704758a7ab 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc @@ -4,8 +4,8 @@ #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" -#include "ash/new_window_delegate.h" -#include "ash/shell.h" +#include "ash/common/new_window_delegate.h" +#include "ash/common/wm_shell.h" #include "base/bind.h" #include "base/command_line.h" #include "base/values.h" @@ -67,7 +67,7 @@ void KeyboardHandler::HandleInitialize(const base::ListValue* args) { void KeyboardHandler::HandleShowKeyboardShortcutsOverlay( const base::ListValue* args) const { - ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); + ash::WmShell::Get()->new_window_delegate()->ShowKeyboardOverlay(); } void KeyboardHandler::UpdateShowKeys() { diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc index 47098175db9a85..c18ef79fc0c8e6 100644 --- a/components/arc/intent_helper/arc_intent_helper_bridge.cc +++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc @@ -7,10 +7,10 @@ #include #include +#include "ash/common/new_window_delegate.h" #include "ash/common/shell_delegate.h" #include "ash/common/wm_shell.h" #include "ash/desktop_background/user_wallpaper_delegate.h" -#include "ash/new_window_delegate.h" #include "ash/shell.h" #include "base/memory/weak_ptr.h" #include "components/arc/intent_helper/activity_icon_loader.h" @@ -71,7 +71,7 @@ void ArcIntentHelperBridge::OnOpenDownloads() { // downloads by default, which is what we want. However if it is open it will // simply be brought to the forgeground without forcibly being navigated to // downloads, which is probably not ideal. - ash::Shell::GetInstance()->new_window_delegate()->OpenFileManager(); + ash::WmShell::Get()->new_window_delegate()->OpenFileManager(); } void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) {