| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system/chromeos/brightness/tray_brightness.h" | 5 #include "ash/system/chromeos/brightness/tray_brightness.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/accelerators/accelerator_controller.h" | 9 #include "ash/accelerators/accelerator_controller.h" |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| 11 #include "ash/metrics/user_metrics_recorder.h" | 11 #include "ash/metrics/user_metrics_recorder.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_observer.h" | 13 #include "ash/shell_observer.h" |
| 14 #include "ash/system/brightness_control_delegate.h" | 14 #include "ash/system/brightness_control_delegate.h" |
| 15 #include "ash/system/tray/fixed_sized_image_view.h" | 15 #include "ash/system/tray/fixed_sized_image_view.h" |
| 16 #include "ash/system/tray/system_tray_delegate.h" | 16 #include "ash/system/tray/system_tray_delegate.h" |
| 17 #include "ash/system/tray/system_tray_notifier.h" | 17 #include "ash/system/tray/system_tray_notifier.h" |
| 18 #include "ash/system/tray/tray_constants.h" | 18 #include "ash/system/tray/tray_constants.h" |
| 19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 20 #include "base/bind.h" | 20 #include "base/bind.h" |
| 21 #include "base/message_loop/message_loop.h" | |
| 22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/thread_task_runner_handle.h" |
| 23 #include "chromeos/dbus/dbus_thread_manager.h" | 23 #include "chromeos/dbus/dbus_thread_manager.h" |
| 24 #include "chromeos/dbus/power_manager_client.h" | 24 #include "chromeos/dbus/power_manager_client.h" |
| 25 #include "grit/ash_resources.h" | 25 #include "grit/ash_resources.h" |
| 26 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/display.h" | 28 #include "ui/gfx/display.h" |
| 29 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 30 #include "ui/views/controls/button/image_button.h" | 30 #include "ui/views/controls/button/image_button.h" |
| 31 #include "ui/views/controls/image_view.h" | 31 #include "ui/views/controls/image_view.h" |
| 32 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } // namespace tray | 173 } // namespace tray |
| 174 | 174 |
| 175 TrayBrightness::TrayBrightness(SystemTray* system_tray) | 175 TrayBrightness::TrayBrightness(SystemTray* system_tray) |
| 176 : SystemTrayItem(system_tray), | 176 : SystemTrayItem(system_tray), |
| 177 brightness_view_(NULL), | 177 brightness_view_(NULL), |
| 178 current_percent_(100.0), | 178 current_percent_(100.0), |
| 179 got_current_percent_(false), | 179 got_current_percent_(false), |
| 180 weak_ptr_factory_(this) { | 180 weak_ptr_factory_(this) { |
| 181 // Post a task to get the initial brightness; the BrightnessControlDelegate | 181 // Post a task to get the initial brightness; the BrightnessControlDelegate |
| 182 // isn't created yet. | 182 // isn't created yet. |
| 183 base::MessageLoopForUI::current()->PostTask( | 183 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 184 FROM_HERE, | 184 FROM_HERE, base::Bind(&TrayBrightness::GetInitialBrightness, |
| 185 base::Bind(&TrayBrightness::GetInitialBrightness, | 185 weak_ptr_factory_.GetWeakPtr())); |
| 186 weak_ptr_factory_.GetWeakPtr())); | |
| 187 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 186 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 188 AddObserver(this); | 187 AddObserver(this); |
| 189 } | 188 } |
| 190 | 189 |
| 191 TrayBrightness::~TrayBrightness() { | 190 TrayBrightness::~TrayBrightness() { |
| 192 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 191 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 193 RemoveObserver(this); | 192 RemoveObserver(this); |
| 194 } | 193 } |
| 195 | 194 |
| 196 void TrayBrightness::GetInitialBrightness() { | 195 void TrayBrightness::GetInitialBrightness() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if (!gfx::Display::HasInternalDisplay()) | 275 if (!gfx::Display::HasInternalDisplay()) |
| 277 return; | 276 return; |
| 278 | 277 |
| 279 if (brightness_view_) | 278 if (brightness_view_) |
| 280 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); | 279 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); |
| 281 else | 280 else |
| 282 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); | 281 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); |
| 283 } | 282 } |
| 284 | 283 |
| 285 } // namespace ash | 284 } // namespace ash |
| OLD | NEW |