[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
James Cook | 346c8c6 | 2017-07-18 19:38:37 | [diff] [blame] | 5 | #include "ash/shell_test_api.h" |
sky | 5ad143a | 2017-03-22 04:31:23 | [diff] [blame] | 6 | |
xiyuan | 317fdbe | 2017-05-31 15:02:02 | [diff] [blame] | 7 | #include <utility> |
8 | |||||
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 9 | #include "ash/root_window_controller.h" |
10 | #include "ash/shell.h" | ||||
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 11 | #include "ash/system/power/backlights_forced_off_setter.h" |
Qiang Xu | 0a86020f | 2017-10-12 08:34:54 | [diff] [blame] | 12 | #include "ash/system/power/power_button_controller.h" |
Evan Stade | d689b33 | 2018-08-02 01:17:22 | [diff] [blame^] | 13 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame] | 14 | #include "components/prefs/testing_pref_service.h" |
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 15 | #include "mojo/public/cpp/bindings/strong_binding.h" |
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 16 | |
17 | namespace ash { | ||||
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 18 | |
sky | cb4be5b | 2017-04-06 17:52:45 | [diff] [blame] | 19 | ShellTestApi::ShellTestApi() : ShellTestApi(Shell::Get()) {} |
sky | 07a24d4 | 2017-03-09 23:57:30 | [diff] [blame] | 20 | |
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 21 | ShellTestApi::ShellTestApi(Shell* shell) : shell_(shell) {} |
22 | |||||
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 23 | // static |
24 | void ShellTestApi::BindRequest(mojom::ShellTestApiRequest request) { | ||||
25 | mojo::MakeStrongBinding(std::make_unique<ShellTestApi>(), std::move(request)); | ||||
26 | } | ||||
27 | |||||
James Cook | 459354b3 | 2017-09-27 23:18:01 | [diff] [blame] | 28 | MessageCenterController* ShellTestApi::message_center_controller() { |
29 | return shell_->message_center_controller_.get(); | ||||
30 | } | ||||
31 | |||||
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 32 | SystemGestureEventFilter* ShellTestApi::system_gesture_event_filter() { |
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 33 | return shell_->system_gesture_filter_.get(); |
34 | } | ||||
35 | |||||
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 36 | WorkspaceController* ShellTestApi::workspace_controller() { |
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 37 | return shell_->GetPrimaryRootWindowController()->workspace_controller(); |
38 | } | ||||
39 | |||||
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 40 | ScreenPositionController* ShellTestApi::screen_position_controller() { |
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 41 | return shell_->screen_position_controller_.get(); |
42 | } | ||||
43 | |||||
erg | 36cfb95 | 2017-06-21 19:41:45 | [diff] [blame] | 44 | NativeCursorManagerAsh* ShellTestApi::native_cursor_manager_ash() { |
[email protected] | c0ff034 | 2013-02-27 00:41:29 | [diff] [blame] | 45 | return shell_->native_cursor_manager_; |
46 | } | ||||
47 | |||||
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 48 | DragDropController* ShellTestApi::drag_drop_controller() { |
[email protected] | c086bab | 2013-06-06 21:46:44 | [diff] [blame] | 49 | return shell_->drag_drop_controller_.get(); |
50 | } | ||||
51 | |||||
Qiang Xu | 36234e53 | 2018-04-11 04:54:02 | [diff] [blame] | 52 | PowerPrefs* ShellTestApi::power_prefs() { |
53 | return shell_->power_prefs_.get(); | ||||
54 | } | ||||
55 | |||||
James Cook | bbe5cb1 | 2017-08-08 18:32:21 | [diff] [blame] | 56 | void ShellTestApi::OnLocalStatePrefServiceInitialized( |
57 | std::unique_ptr<PrefService> pref_service) { | ||||
58 | shell_->OnLocalStatePrefServiceInitialized(std::move(pref_service)); | ||||
59 | } | ||||
60 | |||||
Qiang Xu | 50c6f8c | 2017-08-31 20:55:24 | [diff] [blame] | 61 | void ShellTestApi::ResetPowerButtonControllerForTest() { |
Toni Barzic | 9d0c82f4 | 2017-12-06 00:53:52 | [diff] [blame] | 62 | shell_->backlights_forced_off_setter_->ResetForTest(); |
63 | shell_->power_button_controller_ = std::make_unique<PowerButtonController>( | ||||
64 | shell_->backlights_forced_off_setter_.get()); | ||||
Qiang Xu | 50c6f8c | 2017-08-31 20:55:24 | [diff] [blame] | 65 | } |
66 | |||||
James Cook | 7b7c6a5 | 2018-01-04 23:40:03 | [diff] [blame] | 67 | void ShellTestApi::SimulateModalWindowOpenForTest(bool modal_window_open) { |
68 | shell_->simulate_modal_window_open_for_test_ = modal_window_open; | ||||
69 | } | ||||
70 | |||||
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 71 | void ShellTestApi::IsSystemModalWindowOpen(IsSystemModalWindowOpenCallback cb) { |
72 | std::move(cb).Run(Shell::IsSystemModalWindowOpen()); | ||||
73 | } | ||||
74 | |||||
Evan Stade | d689b33 | 2018-08-02 01:17:22 | [diff] [blame^] | 75 | void ShellTestApi::EnableTabletModeWindowManager(bool enable) { |
76 | shell_->tablet_mode_controller()->EnableTabletModeWindowManager(enable); | ||||
77 | } | ||||
78 | |||||
[email protected] | 0c68e89 | 2012-12-08 16:54:53 | [diff] [blame] | 79 | } // namespace ash |