| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/dbus/chrome_display_power_service_provider_del
egate.h" | 5 #include "chrome/browser/chromeos/dbus/chrome_display_power_service_provider_del
egate.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/screen_dimmer.h" | 8 #include "ash/wm/screen_dimmer.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "ui/base/user_activity/user_activity_detector.h" | 10 #include "ui/base/user_activity/user_activity_detector.h" |
| 10 #include "ui/display/chromeos/display_configurator.h" | 11 #include "ui/display/chromeos/display_configurator.h" |
| 11 | 12 |
| 12 namespace chromeos { | 13 namespace chromeos { |
| 13 | 14 |
| 14 ChromeDisplayPowerServiceProviderDelegate:: | 15 ChromeDisplayPowerServiceProviderDelegate:: |
| 15 ChromeDisplayPowerServiceProviderDelegate() { | 16 ChromeDisplayPowerServiceProviderDelegate() { |
| 16 } | 17 } |
| 17 | 18 |
| 18 ChromeDisplayPowerServiceProviderDelegate:: | 19 ChromeDisplayPowerServiceProviderDelegate:: |
| 19 ~ChromeDisplayPowerServiceProviderDelegate() { | 20 ~ChromeDisplayPowerServiceProviderDelegate() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower( | 23 void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower( |
| 23 DisplayPowerState power_state, | 24 DisplayPowerState power_state, |
| 24 const ResponseCallback& callback) { | 25 const ResponseCallback& callback) { |
| 25 // Turning displays off when the device becomes idle or on just before | 26 // Turning displays off when the device becomes idle or on just before |
| 26 // we suspend may trigger a mouse move, which would then be incorrectly | 27 // we suspend may trigger a mouse move, which would then be incorrectly |
| 27 // reported as user activity. Let the UserActivityDetector | 28 // reported as user activity. Let the UserActivityDetector |
| 28 // know so that it can ignore such events. | 29 // know so that it can ignore such events. |
| 29 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); | 30 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); |
| 30 | 31 |
| 31 ash::Shell::GetInstance()->display_configurator()->SetDisplayPower( | 32 ash::Shell::GetInstance()->display_configurator()->SetDisplayPower( |
| 32 power_state, ui::DisplayConfigurator::kSetDisplayPowerNoFlags, callback); | 33 power_state, ui::DisplayConfigurator::kSetDisplayPowerNoFlags, callback); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void ChromeDisplayPowerServiceProviderDelegate::SetDimming(bool dimmed) { | 36 void ChromeDisplayPowerServiceProviderDelegate::SetDimming(bool dimmed) { |
| 36 ash::ScreenDimmer::GetForRoot()->SetDimming(dimmed); | 37 if (!screen_dimmer_) { |
| 38 screen_dimmer_ = |
| 39 base::MakeUnique<ash::ScreenDimmer>(ash::ScreenDimmer::Container::ROOT); |
| 40 } |
| 41 screen_dimmer_->SetDimming(dimmed); |
| 37 } | 42 } |
| 38 | 43 |
| 39 } // namespace chromeos | 44 } // namespace chromeos |
| OLD | NEW |