Commit 308af393 authored by msw's avatar msw Committed by Commit bot

mash: Migrate [Keyboard]Brightness code to ash/common.

Move BrightnessControlDelegate ownership to WmShell.
(it is not closely related to AcceleratorController)

tools/git/move_source_file.py ash/system/brightness_control_delegate.h ash/common/system
tools/git/move_source_file.py ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h ash/common/system
tools/git/move_source_file.py ash/system/chromeos/keyboard_brightness_controller* ash/common/system/chromeos
tools/git/move_source_file.py ash/system/chromeos/brightness/* ash/common/system/chromeos/brightness

BUG=619636
TEST=compiles; unit tests; no behavior changes.
R=jamescook@chromium.org

Review-Url: https://codereview.chromium.org/2131733002
Cr-Commit-Position: refs/heads/master@{#404439}
parent a63ec959
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "ash/common/shelf/shelf_model.h" #include "ash/common/shelf/shelf_model.h"
#include "ash/common/shell_delegate.h" #include "ash/common/shell_delegate.h"
#include "ash/common/shell_window_ids.h" #include "ash/common/shell_window_ids.h"
#include "ash/common/system/brightness_control_delegate.h"
#include "ash/common/system/keyboard_brightness_control_delegate.h"
#include "ash/common/system/system_notifier.h" #include "ash/common/system/system_notifier.h"
#include "ash/common/system/tray/system_tray_delegate.h" #include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/system_tray_notifier.h" #include "ash/common/system/tray/system_tray_notifier.h"
...@@ -48,8 +50,6 @@ ...@@ -48,8 +50,6 @@
#include "ash/shelf/shelf_delegate.h" #include "ash/shelf/shelf_delegate.h"
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/brightness_control_delegate.h"
#include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/touch/touch_hud_debug.h" #include "ash/touch/touch_hud_debug.h"
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ash/display/display_configuration_controller.h" #include "ash/display/display_configuration_controller.h"
#include "ash/system/chromeos/keyboard_brightness_controller.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/power_manager_client.h"
...@@ -554,18 +553,6 @@ void HandleUnpin() { ...@@ -554,18 +553,6 @@ void HandleUnpin() {
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
void HandleBrightnessDown(BrightnessControlDelegate* delegate,
const ui::Accelerator& accelerator) {
if (delegate)
delegate->HandleBrightnessDown(accelerator);
}
void HandleBrightnessUp(BrightnessControlDelegate* delegate,
const ui::Accelerator& accelerator) {
if (delegate)
delegate->HandleBrightnessUp(accelerator);
}
bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) {
ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
if (previous_accelerator.type() == ui::ET_KEY_RELEASED || if (previous_accelerator.type() == ui::ET_KEY_RELEASED ||
...@@ -590,18 +577,6 @@ void HandleDisableCapsLock() { ...@@ -590,18 +577,6 @@ void HandleDisableCapsLock() {
ime->GetImeKeyboard()->SetCapsLockEnabled(false); ime->GetImeKeyboard()->SetCapsLockEnabled(false);
} }
void HandleKeyboardBrightnessDown(KeyboardBrightnessControlDelegate* delegate,
const ui::Accelerator& accelerator) {
if (delegate)
delegate->HandleKeyboardBrightnessDown(accelerator);
}
void HandleKeyboardBrightnessUp(KeyboardBrightnessControlDelegate* delegate,
const ui::Accelerator& accelerator) {
if (delegate)
delegate->HandleKeyboardBrightnessUp(accelerator);
}
bool CanHandleLock() { bool CanHandleLock() {
return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen();
} }
...@@ -807,11 +782,6 @@ AcceleratorController::GetCurrentAcceleratorRestriction() { ...@@ -807,11 +782,6 @@ AcceleratorController::GetCurrentAcceleratorRestriction() {
return GetAcceleratorProcessingRestriction(-1); return GetAcceleratorProcessingRestriction(-1);
} }
void AcceleratorController::SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate) {
brightness_control_delegate_ = std::move(brightness_control_delegate);
}
void AcceleratorController::SetImeControlDelegate( void AcceleratorController::SetImeControlDelegate(
std::unique_ptr<ImeControlDelegate> ime_control_delegate) { std::unique_ptr<ImeControlDelegate> ime_control_delegate) {
ime_control_delegate_ = std::move(ime_control_delegate); ime_control_delegate_ = std::move(ime_control_delegate);
...@@ -928,11 +898,6 @@ void AcceleratorController::Init() { ...@@ -928,11 +898,6 @@ void AcceleratorController::Init() {
for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
reserved_actions_.insert(kDebugAcceleratorData[i].action); reserved_actions_.insert(kDebugAcceleratorData[i].action);
} }
#if defined(OS_CHROMEOS)
keyboard_brightness_control_delegate_.reset(
new KeyboardBrightnessController());
#endif
} }
void AcceleratorController::RegisterAccelerators( void AcceleratorController::RegisterAccelerators(
...@@ -1280,12 +1245,20 @@ void AcceleratorController::PerformAction(AcceleratorAction action, ...@@ -1280,12 +1245,20 @@ void AcceleratorController::PerformAction(AcceleratorAction action,
HandleUnpin(); HandleUnpin();
break; break;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
case BRIGHTNESS_DOWN: case BRIGHTNESS_DOWN: {
HandleBrightnessDown(brightness_control_delegate_.get(), accelerator); BrightnessControlDelegate* delegate =
WmShell::Get()->brightness_control_delegate();
if (delegate)
delegate->HandleBrightnessDown(accelerator);
break; break;
case BRIGHTNESS_UP: }
HandleBrightnessUp(brightness_control_delegate_.get(), accelerator); case BRIGHTNESS_UP: {
BrightnessControlDelegate* delegate =
WmShell::Get()->brightness_control_delegate();
if (delegate)
delegate->HandleBrightnessUp(accelerator);
break; break;
}
case DEBUG_ADD_REMOVE_DISPLAY: case DEBUG_ADD_REMOVE_DISPLAY:
case DEBUG_SHOW_TOAST: case DEBUG_SHOW_TOAST:
case DEBUG_TOGGLE_TOUCH_PAD: case DEBUG_TOGGLE_TOUCH_PAD:
...@@ -1300,14 +1273,20 @@ void AcceleratorController::PerformAction(AcceleratorAction action, ...@@ -1300,14 +1273,20 @@ void AcceleratorController::PerformAction(AcceleratorAction action,
case DISABLE_GPU_WATCHDOG: case DISABLE_GPU_WATCHDOG:
Shell::GetInstance()->gpu_support()->DisableGpuWatchdog(); Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
break; break;
case KEYBOARD_BRIGHTNESS_DOWN: case KEYBOARD_BRIGHTNESS_DOWN: {
HandleKeyboardBrightnessDown(keyboard_brightness_control_delegate_.get(), KeyboardBrightnessControlDelegate* delegate =
accelerator); WmShell::Get()->keyboard_brightness_control_delegate();
if (delegate)
delegate->HandleKeyboardBrightnessDown(accelerator);
break; break;
case KEYBOARD_BRIGHTNESS_UP: }
HandleKeyboardBrightnessUp(keyboard_brightness_control_delegate_.get(), case KEYBOARD_BRIGHTNESS_UP: {
accelerator); KeyboardBrightnessControlDelegate* delegate =
WmShell::Get()->keyboard_brightness_control_delegate();
if (delegate)
delegate->HandleKeyboardBrightnessUp(accelerator);
break; break;
}
case LOCK_PRESSED: case LOCK_PRESSED:
case LOCK_RELEASED: case LOCK_RELEASED:
Shell::GetInstance()->power_button_controller()->OnLockButtonEvent( Shell::GetInstance()->power_button_controller()->OnLockButtonEvent(
...@@ -1435,11 +1414,4 @@ AcceleratorController::GetAcceleratorProcessingRestriction(int action) { ...@@ -1435,11 +1414,4 @@ AcceleratorController::GetAcceleratorProcessingRestriction(int action) {
return RESTRICTION_NONE; return RESTRICTION_NONE;
} }
void AcceleratorController::SetKeyboardBrightnessControlDelegate(
std::unique_ptr<KeyboardBrightnessControlDelegate>
keyboard_brightness_control_delegate) {
keyboard_brightness_control_delegate_ =
std::move(keyboard_brightness_control_delegate);
}
} // namespace ash } // namespace ash
...@@ -27,10 +27,8 @@ class AcceleratorManager; ...@@ -27,10 +27,8 @@ class AcceleratorManager;
namespace ash { namespace ash {
struct AcceleratorData; struct AcceleratorData;
class BrightnessControlDelegate;
class ExitWarningHandler; class ExitWarningHandler;
class ImeControlDelegate; class ImeControlDelegate;
class KeyboardBrightnessControlDelegate;
class ScreenshotDelegate; class ScreenshotDelegate;
class VolumeControlDelegate; class VolumeControlDelegate;
...@@ -101,15 +99,10 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -101,15 +99,10 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
// Returns the restriction for the current context. // Returns the restriction for the current context.
AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction();
void SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate);
void SetImeControlDelegate( void SetImeControlDelegate(
std::unique_ptr<ImeControlDelegate> ime_control_delegate); std::unique_ptr<ImeControlDelegate> ime_control_delegate);
void SetScreenshotDelegate( void SetScreenshotDelegate(
std::unique_ptr<ScreenshotDelegate> screenshot_delegate); std::unique_ptr<ScreenshotDelegate> screenshot_delegate);
BrightnessControlDelegate* brightness_control_delegate() const {
return brightness_control_delegate_.get();
}
ScreenshotDelegate* screenshot_delegate() { ScreenshotDelegate* screenshot_delegate() {
return screenshot_delegate_.get(); return screenshot_delegate_.get();
} }
...@@ -166,21 +159,12 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -166,21 +159,12 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction(
int action); int action);
void SetKeyboardBrightnessControlDelegate(
std::unique_ptr<KeyboardBrightnessControlDelegate>
keyboard_brightness_control_delegate);
std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; std::unique_ptr<ui::AcceleratorManager> accelerator_manager_;
// A tracker for the current and previous accelerators. // A tracker for the current and previous accelerators.
std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; std::unique_ptr<ui::AcceleratorHistory> accelerator_history_;
// TODO(derat): BrightnessControlDelegate is also used by the system tray;
// move it outside of this class.
std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_;
std::unique_ptr<ImeControlDelegate> ime_control_delegate_; std::unique_ptr<ImeControlDelegate> ime_control_delegate_;
std::unique_ptr<KeyboardBrightnessControlDelegate>
keyboard_brightness_control_delegate_;
std::unique_ptr<ScreenshotDelegate> screenshot_delegate_; std::unique_ptr<ScreenshotDelegate> screenshot_delegate_;
// Handles the exit accelerator which requires a double press to exit and // Handles the exit accelerator which requires a double press to exit and
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
#include "ash/aura/wm_window_aura.h" #include "ash/aura/wm_window_aura.h"
#include "ash/common/accessibility_delegate.h" #include "ash/common/accessibility_delegate.h"
#include "ash/common/accessibility_types.h" #include "ash/common/accessibility_types.h"
#include "ash/common/ash_switches.h" #include "ash/common/session/session_state_delegate.h"
#include "ash/common/shell_window_ids.h" #include "ash/common/shell_window_ids.h"
#include "ash/common/system/brightness_control_delegate.h"
#include "ash/common/system/keyboard_brightness_control_delegate.h"
#include "ash/common/system/tray/system_tray_delegate.h" #include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/volume_control_delegate.h" #include "ash/common/system/volume_control_delegate.h"
#include "ash/common/wm/panels/panel_layout_manager.h" #include "ash/common/wm/panels/panel_layout_manager.h"
...@@ -19,21 +21,16 @@ ...@@ -19,21 +21,16 @@
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/display/display_manager.h" #include "ash/display/display_manager.h"
#include "ash/ime_control_delegate.h" #include "ash/ime_control_delegate.h"
#include "ash/screen_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/brightness_control_delegate.h"
#include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/display_manager_test_api.h" #include "ash/test/display_manager_test_api.h"
#include "ash/test/test_screenshot_delegate.h" #include "ash/test/test_screenshot_delegate.h"
#include "ash/test/test_session_state_animator.h" #include "ash/test/test_session_state_animator.h"
#include "ash/test/test_shelf_delegate.h" #include "ash/test/test_shelf_delegate.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/test/test_volume_control_delegate.h" #include "ash/test/test_volume_control_delegate.h"
#include "ash/wm/lock_state_controller.h" #include "ash/wm/lock_state_controller.h"
#include "ash/wm/window_state_aura.h" #include "ash/wm/window_state_aura.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h" #include "ui/aura/test/test_windows.h"
...@@ -266,6 +263,16 @@ class AcceleratorControllerTest : public test::AshTestBase { ...@@ -266,6 +263,16 @@ class AcceleratorControllerTest : public test::AshTestBase {
return window; return window;
} }
void SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate> delegate) {
WmShell::Get()->brightness_control_delegate_ = std::move(delegate);
}
void SetKeyboardBrightnessControlDelegate(
std::unique_ptr<KeyboardBrightnessControlDelegate> delegate) {
WmShell::Get()->keyboard_brightness_control_delegate_ = std::move(delegate);
}
private: private:
DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest); DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest);
}; };
...@@ -859,7 +866,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { ...@@ -859,7 +866,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
{ {
DummyBrightnessControlDelegate* delegate = DummyBrightnessControlDelegate* delegate =
new DummyBrightnessControlDelegate; new DummyBrightnessControlDelegate;
GetController()->SetBrightnessControlDelegate( SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate>(delegate)); std::unique_ptr<BrightnessControlDelegate>(delegate));
EXPECT_EQ(0, delegate->handle_brightness_down_count()); EXPECT_EQ(0, delegate->handle_brightness_down_count());
EXPECT_TRUE(ProcessInController(brightness_down)); EXPECT_TRUE(ProcessInController(brightness_down));
...@@ -881,7 +888,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { ...@@ -881,7 +888,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
EXPECT_TRUE(ProcessInController(alt_brightness_up)); EXPECT_TRUE(ProcessInController(alt_brightness_up));
DummyKeyboardBrightnessControlDelegate* delegate = DummyKeyboardBrightnessControlDelegate* delegate =
new DummyKeyboardBrightnessControlDelegate; new DummyKeyboardBrightnessControlDelegate;
GetController()->SetKeyboardBrightnessControlDelegate( SetKeyboardBrightnessControlDelegate(
std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate));
EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count());
EXPECT_TRUE(ProcessInController(alt_brightness_down)); EXPECT_TRUE(ProcessInController(alt_brightness_down));
...@@ -1237,7 +1244,7 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { ...@@ -1237,7 +1244,7 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
{ {
DummyBrightnessControlDelegate* delegate = DummyBrightnessControlDelegate* delegate =
new DummyBrightnessControlDelegate; new DummyBrightnessControlDelegate;
GetController()->SetBrightnessControlDelegate( SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate>(delegate)); std::unique_ptr<BrightnessControlDelegate>(delegate));
EXPECT_EQ(0, delegate->handle_brightness_down_count()); EXPECT_EQ(0, delegate->handle_brightness_down_count());
EXPECT_TRUE(ProcessInController(brightness_down)); EXPECT_TRUE(ProcessInController(brightness_down));
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
'common/system/audio/tray_audio_delegate.h', 'common/system/audio/tray_audio_delegate.h',
'common/system/audio/volume_view.cc', 'common/system/audio/volume_view.cc',
'common/system/audio/volume_view.h', 'common/system/audio/volume_view.h',
'common/system/brightness_control_delegate.h',
'common/system/cast/tray_cast.cc', 'common/system/cast/tray_cast.cc',
'common/system/cast/tray_cast.h', 'common/system/cast/tray_cast.h',
'common/system/chromeos/audio/audio_detailed_view.cc', 'common/system/chromeos/audio/audio_detailed_view.cc',
...@@ -127,11 +128,17 @@ ...@@ -127,11 +128,17 @@
'common/system/chromeos/bluetooth/bluetooth_observer.h', 'common/system/chromeos/bluetooth/bluetooth_observer.h',
'common/system/chromeos/bluetooth/tray_bluetooth.cc', 'common/system/chromeos/bluetooth/tray_bluetooth.cc',
'common/system/chromeos/bluetooth/tray_bluetooth.h', 'common/system/chromeos/bluetooth/tray_bluetooth.h',
'common/system/chromeos/brightness/brightness_controller_chromeos.cc',
'common/system/chromeos/brightness/brightness_controller_chromeos.h',
'common/system/chromeos/brightness/tray_brightness.cc',
'common/system/chromeos/brightness/tray_brightness.h',
'common/system/chromeos/devicetype_utils.cc', 'common/system/chromeos/devicetype_utils.cc',
'common/system/chromeos/devicetype_utils.h', 'common/system/chromeos/devicetype_utils.h',
'common/system/chromeos/enterprise/enterprise_domain_observer.h', 'common/system/chromeos/enterprise/enterprise_domain_observer.h',
'common/system/chromeos/enterprise/tray_enterprise.cc', 'common/system/chromeos/enterprise/tray_enterprise.cc',
'common/system/chromeos/enterprise/tray_enterprise.h', 'common/system/chromeos/enterprise/tray_enterprise.h',
'common/system/chromeos/keyboard_brightness_controller.cc',
'common/system/chromeos/keyboard_brightness_controller.h',
'common/system/chromeos/media_security/media_capture_observer.h', 'common/system/chromeos/media_security/media_capture_observer.h',
'common/system/chromeos/network/network_detailed_view.h', 'common/system/chromeos/network/network_detailed_view.h',
'common/system/chromeos/network/network_observer.h', 'common/system/chromeos/network/network_observer.h',
...@@ -204,6 +211,7 @@ ...@@ -204,6 +211,7 @@
'common/system/ime/ime_observer.h', 'common/system/ime/ime_observer.h',
'common/system/ime/tray_ime_chromeos.cc', 'common/system/ime/tray_ime_chromeos.cc',
'common/system/ime/tray_ime_chromeos.h', 'common/system/ime/tray_ime_chromeos.h',
'common/system/keyboard_brightness_control_delegate.h',
'common/system/locale/locale_notification_controller.cc', 'common/system/locale/locale_notification_controller.cc',
'common/system/locale/locale_notification_controller.h', 'common/system/locale/locale_notification_controller.h',
'common/system/locale/locale_observer.h', 'common/system/locale/locale_observer.h',
...@@ -612,13 +620,6 @@ ...@@ -612,13 +620,6 @@
'sticky_keys/sticky_keys_overlay.cc', 'sticky_keys/sticky_keys_overlay.cc',
'sticky_keys/sticky_keys_overlay.h', 'sticky_keys/sticky_keys_overlay.h',
'sticky_keys/sticky_keys_state.h', 'sticky_keys/sticky_keys_state.h',
'system/brightness_control_delegate.h',
'system/chromeos/brightness/brightness_controller_chromeos.cc',
'system/chromeos/brightness/brightness_controller_chromeos.h',
'system/chromeos/brightness/tray_brightness.cc',
'system/chromeos/brightness/tray_brightness.h',
'system/chromeos/keyboard_brightness_controller.cc',
'system/chromeos/keyboard_brightness_controller.h',
'system/chromeos/media_security/multi_profile_media_tray_item.cc', 'system/chromeos/media_security/multi_profile_media_tray_item.cc',
'system/chromeos/media_security/multi_profile_media_tray_item.h', 'system/chromeos/media_security/multi_profile_media_tray_item.h',
'system/chromeos/multi_user/user_switch_util.cc', 'system/chromeos/multi_user/user_switch_util.cc',
...@@ -631,7 +632,6 @@ ...@@ -631,7 +632,6 @@
'system/chromeos/rotation/tray_rotation_lock.h', 'system/chromeos/rotation/tray_rotation_lock.h',
'system/chromeos/tray_display.cc', 'system/chromeos/tray_display.cc',
'system/chromeos/tray_display.h', 'system/chromeos/tray_display.h',
'system/keyboard_brightness/keyboard_brightness_control_delegate.h',
'system/status_area_widget.cc', 'system/status_area_widget.cc',
'system/status_area_widget.h', 'system/status_area_widget.h',
'system/toast/toast_data.cc', 'system/toast/toast_data.cc',
...@@ -899,6 +899,7 @@ ...@@ -899,6 +899,7 @@
'common/material_design/material_design_controller_unittest.cc', 'common/material_design/material_design_controller_unittest.cc',
'common/popup_message_unittest.cc', 'common/popup_message_unittest.cc',
'common/shelf/shelf_model_unittest.cc', 'common/shelf/shelf_model_unittest.cc',
'common/system/chromeos/brightness/tray_brightness_unittest.cc',
'common/system/chromeos/power/power_status_unittest.cc', 'common/system/chromeos/power/power_status_unittest.cc',
'common/system/chromeos/power/power_status_view_unittest.cc', 'common/system/chromeos/power/power_status_view_unittest.cc',
'common/system/chromeos/power/tray_power_unittest.cc', 'common/system/chromeos/power/tray_power_unittest.cc',
...@@ -963,7 +964,6 @@ ...@@ -963,7 +964,6 @@
'shell_unittest.cc', 'shell_unittest.cc',
'sticky_keys/sticky_keys_overlay_unittest.cc', 'sticky_keys/sticky_keys_overlay_unittest.cc',
'sticky_keys/sticky_keys_unittest.cc', 'sticky_keys/sticky_keys_unittest.cc',
'system/chromeos/brightness/tray_brightness_unittest.cc',
'system/chromeos/media_security/multi_profile_media_tray_item_unittest.cc', 'system/chromeos/media_security/multi_profile_media_tray_item_unittest.cc',
'system/chromeos/multi_user/user_switch_util_unittest.cc', 'system/chromeos/multi_user/user_switch_util_unittest.cc',
'system/chromeos/power/power_event_observer_unittest.cc', 'system/chromeos/power/power_event_observer_unittest.cc',
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_ #ifndef ASH_COMMON_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_
#define ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_ #define ASH_COMMON_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_
#include "base/callback.h" #include "base/callback.h"
...@@ -36,4 +36,4 @@ class BrightnessControlDelegate { ...@@ -36,4 +36,4 @@ class BrightnessControlDelegate {
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_ #endif // ASH_COMMON_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/system/chromeos/brightness/brightness_controller_chromeos.h" #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_ #ifndef ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_
#define ASH_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_ #define ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/brightness_control_delegate.h" #include "ash/common/system/brightness_control_delegate.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -35,4 +35,4 @@ class ASH_EXPORT BrightnessControllerChromeos ...@@ -35,4 +35,4 @@ class ASH_EXPORT BrightnessControllerChromeos
} // namespace system } // namespace system
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_ #endif // ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_BRIGHTNESS_CONTROLLER_CHROMEOS_H_
...@@ -2,20 +2,18 @@ ...@@ -2,20 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/system/chromeos/brightness/tray_brightness.h" #include "ash/common/system/chromeos/brightness/tray_brightness.h"
#include <algorithm> #include <algorithm>
#include "ash/accelerators/accelerator_controller.h"
#include "ash/common/ash_constants.h" #include "ash/common/ash_constants.h"
#include "ash/common/shell_observer.h" #include "ash/common/shell_observer.h"
#include "ash/common/system/brightness_control_delegate.h"
#include "ash/common/system/tray/fixed_sized_image_view.h" #include "ash/common/system/tray/fixed_sized_image_view.h"
#include "ash/common/system/tray/system_tray_delegate.h" #include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/tray_constants.h" #include "ash/common/system/tray/tray_constants.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shell.h"
#include "ash/system/brightness_control_delegate.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
...@@ -151,10 +149,11 @@ void BrightnessView::SliderValueChanged(views::Slider* sender, ...@@ -151,10 +149,11 @@ void BrightnessView::SliderValueChanged(views::Slider* sender,
DCHECK_EQ(sender, slider_); DCHECK_EQ(sender, slider_);
if (reason != views::VALUE_CHANGED_BY_USER) if (reason != views::VALUE_CHANGED_BY_USER)
return; return;
AcceleratorController* ac = Shell::GetInstance()->accelerator_controller(); BrightnessControlDelegate* brightness_control_delegate =
if (ac->brightness_control_delegate()) { WmShell::Get()->brightness_control_delegate();
if (brightness_control_delegate) {
double percent = std::max(value * 100.0, kMinBrightnessPercent); double percent = std::max(value * 100.0, kMinBrightnessPercent);
ac->brightness_control_delegate()->SetBrightnessPercent(percent, true); brightness_control_delegate->SetBrightnessPercent(percent, true);
} }
} }
...@@ -192,13 +191,12 @@ TrayBrightness::~TrayBrightness() { ...@@ -192,13 +191,12 @@ TrayBrightness::~TrayBrightness() {
} }
void TrayBrightness::GetInitialBrightness() { void TrayBrightness::GetInitialBrightness() {
BrightnessControlDelegate* delegate = Shell::GetInstance() BrightnessControlDelegate* brightness_control_delegate =
->accelerator_controller() WmShell::Get()->brightness_control_delegate();
->brightness_control_delegate();
// Worrisome, but happens in unit tests, so don't log anything. // Worrisome, but happens in unit tests, so don't log anything.
if (!delegate) if (!brightness_control_delegate)
return; return;
delegate->GetBrightnessPercent( brightness_control_delegate->GetBrightnessPercent(
base::Bind(&TrayBrightness::HandleInitialBrightness, base::Bind(&TrayBrightness::HandleInitialBrightness,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ #ifndef ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_
#define ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ #define ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_
#include "ash/common/system/tray/system_tray_item.h" #include "ash/common/system/tray/system_tray_item.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -66,4 +66,4 @@ class ASH_EXPORT TrayBrightness ...@@ -66,4 +66,4 @@ class ASH_EXPORT TrayBrightness
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ #endif // ASH_COMMON_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/system/chromeos/brightness/tray_brightness.h" #include "ash/common/system/chromeos/brightness/tray_brightness.h"
#include <memory> #include <memory>
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "ash/common/system/tray/system_tray_item.h" #include "ash/common/system/tray/system_tray_item.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h" #include "ash/test/status_area_widget_test_helper.h"
#include "ui/views/view.h" #include "ui/views/view.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/system/chromeos/keyboard_brightness_controller.h" #include "ash/common/system/chromeos/keyboard_brightness_controller.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_ #ifndef ASH_COMMON_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_
#define ASH_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_ #define ASH_COMMON_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" #include "ash/common/system/keyboard_brightness_control_delegate.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -31,4 +31,4 @@ class ASH_EXPORT KeyboardBrightnessController ...@@ -31,4 +31,4 @@ class ASH_EXPORT KeyboardBrightnessController
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_ #endif // ASH_COMMON_SYSTEM_CHROMEOS_KEYBOARD_BRIGHTNESS_CONTROLLER_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_ #ifndef ASH_COMMON_SYSTEM_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_
#define ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_ #define ASH_COMMON_SYSTEM_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_
namespace ui { namespace ui {
class Accelerator; class Accelerator;
...@@ -26,4 +26,4 @@ class KeyboardBrightnessControlDelegate { ...@@ -26,4 +26,4 @@ class KeyboardBrightnessControlDelegate {
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_ #endif // ASH_COMMON_SYSTEM_KEYBOARD_BRIGHTNESS_CONTROL_DELEGATE_H_
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "ash/common/keyboard/keyboard_ui.h" #include "ash/common/keyboard/keyboard_ui.h"
#include "ash/common/shell_delegate.h" #include "ash/common/shell_delegate.h"
#include "ash/common/shell_window_ids.h" #include "ash/common/shell_window_ids.h"
#include "ash/common/system/chromeos/session/logout_confirmation_controller.h" #include "ash/common/system/brightness_control_delegate.h"
#include "ash/common/system/keyboard_brightness_control_delegate.h"
#include "ash/common/system/tray/system_tray_delegate.h" #include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/system_tray_notifier.h" #include "ash/common/system/tray/system_tray_notifier.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
...@@ -18,6 +19,12 @@ ...@@ -18,6 +19,12 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h"
#include "ash/common/system/chromeos/keyboard_brightness_controller.h"
#include "ash/common/system/chromeos/session/logout_confirmation_controller.h"
#endif
namespace ash { namespace ash {
// static // static
...@@ -58,7 +65,12 @@ WmShell::WmShell(ShellDelegate* delegate) ...@@ -58,7 +65,12 @@ WmShell::WmShell(ShellDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
focus_cycler_(new FocusCycler), focus_cycler_(new FocusCycler),
system_tray_notifier_(new SystemTrayNotifier), system_tray_notifier_(new SystemTrayNotifier),
window_selector_controller_(new WindowSelectorController()) {} window_selector_controller_(new WindowSelectorController) {
#if defined(OS_CHROMEOS)
brightness_control_delegate_.reset(new system::BrightnessControllerChromeos);
keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController);
#endif
}
WmShell::~WmShell() {} WmShell::~WmShell() {}
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#include "ash/common/metrics/user_metrics_action.h" #include "ash/common/metrics/user_metrics_action.h"
#include "base/observer_list.h" #include "base/observer_list.h"
namespace gfx {
class Rect;
}
namespace views { namespace views {
class PointerWatcher; class PointerWatcher;
} }
...@@ -26,8 +22,10 @@ class PointerWatcher; ...@@ -26,8 +22,10 @@ class PointerWatcher;
namespace ash { namespace ash {
class AccessibilityDelegate; class AccessibilityDelegate;
class BrightnessControlDelegate;
class DisplayInfo; class DisplayInfo;
class FocusCycler; class FocusCycler;
class KeyboardBrightnessControlDelegate;
class KeyboardUI; class KeyboardUI;
class MaximizeModeController; class MaximizeModeController;
class MruWindowTracker; class MruWindowTracker;
...@@ -41,7 +39,6 @@ class WindowResizer; ...@@ -41,7 +39,6 @@ class WindowResizer;
class WindowSelectorController; class WindowSelectorController;
class WmActivationObserver; class WmActivationObserver;
class WmDisplayObserver; class WmDisplayObserver;
class WmRootWindowController;
class WmWindow; class WmWindow;
namespace wm { namespace wm {
...@@ -64,8 +61,16 @@ class ASH_EXPORT WmShell { ...@@ -64,8 +61,16 @@ class ASH_EXPORT WmShell {
ShellDelegate* delegate() { return delegate_.get(); } ShellDelegate* delegate() { return delegate_.get(); }
BrightnessControlDelegate* brightness_control_delegate() {
return brightness_control_delegate_.get();
}
FocusCycler* focus_cycler() { return focus_cycler_.get(); } FocusCycler* focus_cycler() { return focus_cycler_.get(); }
KeyboardBrightnessControlDelegate* keyboard_brightness_control_delegate() {
return keyboard_brightness_control_delegate_.get();
}
KeyboardUI* keyboard_ui() { return keyboard_ui_.get(); } KeyboardUI* keyboard_ui() { return keyboard_ui_.get(); }
MaximizeModeController* maximize_mode_controller() { MaximizeModeController* maximize_mode_controller() {
...@@ -234,13 +239,18 @@ class ASH_EXPORT WmShell { ...@@ -234,13 +239,18 @@ class ASH_EXPORT WmShell {
void DeleteMruWindowTracker(); void DeleteMruWindowTracker();
private: private:
friend class AcceleratorControllerTest;
friend class Shell; friend class Shell;
static WmShell* instance_; static WmShell* instance_;
base::ObserverList<ShellObserver> shell_observers_; base::ObserverList<ShellObserver> shell_observers_;
std::unique_ptr<ShellDelegate> delegate_; std::unique_ptr<ShellDelegate> delegate_;
std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_;
std::unique_ptr<FocusCycler> focus_cycler_; std::unique_ptr<FocusCycler> focus_cycler_;
std::unique_ptr<KeyboardBrightnessControlDelegate>
keyboard_brightness_control_delegate_;
std::unique_ptr<KeyboardUI> keyboard_ui_; std::unique_ptr<KeyboardUI> keyboard_ui_;
std::unique_ptr<MaximizeModeController> maximize_mode_controller_; std::unique_ptr<MaximizeModeController> maximize_mode_controller_;
std::unique_ptr<MediaDelegate> media_delegate_; std::unique_ptr<MediaDelegate> media_delegate_;
......
...@@ -134,7 +134,6 @@ ...@@ -134,7 +134,6 @@
#include "ash/display/resolution_notification_controller.h" #include "ash/display/resolution_notification_controller.h"
#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/display/screen_orientation_controller_chromeos.h"
#include "ash/sticky_keys/sticky_keys_controller.h" #include "ash/sticky_keys/sticky_keys_controller.h"
#include "ash/system/chromeos/brightness/brightness_controller_chromeos.h"
#include "ash/system/chromeos/power/power_event_observer.h" #include "ash/system/chromeos/power/power_event_observer.h"
#include "ash/system/chromeos/power/video_activity_notifier.h" #include "ash/system/chromeos/power/video_activity_notifier.h"
#include "ash/touch/touch_transformer_controller.h" #include "ash/touch/touch_transformer_controller.h"
...@@ -1073,11 +1072,6 @@ void Shell::Init(const ShellInitParams& init_params) { ...@@ -1073,11 +1072,6 @@ void Shell::Init(const ShellInitParams& init_params) {
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Set accelerator controller delegates.
accelerator_controller_->SetBrightnessControlDelegate(
std::unique_ptr<BrightnessControlDelegate>(
new system::BrightnessControllerChromeos));
power_event_observer_.reset(new PowerEventObserver()); power_event_observer_.reset(new PowerEventObserver());
user_activity_notifier_.reset( user_activity_notifier_.reset(
new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/audio/tray_audio_chromeos.h" #include "ash/common/system/chromeos/audio/tray_audio_chromeos.h"
#include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h"
#include "ash/common/system/chromeos/brightness/tray_brightness.h"
#include "ash/common/system/chromeos/enterprise/tray_enterprise.h" #include "ash/common/system/chromeos/enterprise/tray_enterprise.h"
#include "ash/common/system/chromeos/network/tray_network.h" #include "ash/common/system/chromeos/network/tray_network.h"
#include "ash/common/system/chromeos/network/tray_sms.h" #include "ash/common/system/chromeos/network/tray_sms.h"
...@@ -60,7 +61,6 @@ ...@@ -60,7 +61,6 @@
#include "ash/common/system/chromeos/tray_caps_lock.h" #include "ash/common/system/chromeos/tray_caps_lock.h"
#include "ash/common/system/chromeos/tray_tracing.h" #include "ash/common/system/chromeos/tray_tracing.h"
#include "ash/common/system/ime/tray_ime_chromeos.h" #include "ash/common/system/ime/tray_ime_chromeos.h"
#include "ash/system/chromeos/brightness/tray_brightness.h"
#include "ash/system/chromeos/media_security/multi_profile_media_tray_item.h" #include "ash/system/chromeos/media_security/multi_profile_media_tray_item.h"
#include "ash/system/chromeos/rotation/tray_rotation_lock.h" #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
#include "ash/system/chromeos/tray_display.h" #include "ash/system/chromeos/tray_display.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment