| 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/common/system/chromeos/brightness/tray_brightness.h" | 5 #include "ash/common/system/chromeos/brightness/tray_brightness.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/dbus_thread_manager_ash.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 11 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/shell_observer.h" | 12 #include "ash/common/shell_observer.h" |
| 12 #include "ash/common/system/brightness_control_delegate.h" | 13 #include "ash/common/system/brightness_control_delegate.h" |
| 13 #include "ash/common/system/tray/fixed_sized_image_view.h" | 14 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 14 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 16 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 17 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 18 #include "ash/resources/vector_icons/vector_icons.h" | 19 #include "ash/resources/vector_icons/vector_icons.h" |
| 19 #include "base/bind.h" | 20 #include "base/bind.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "chromeos/dbus/dbus_thread_manager.h" | 23 // #include "chromeos/dbus/dbus_thread_manager.h" |
| 23 #include "chromeos/dbus/power_manager_client.h" | 24 #include "chromeos/dbus/power_manager_client.h" |
| 24 #include "grit/ash_resources.h" | 25 #include "grit/ash_resources.h" |
| 25 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/display/display.h" | 28 #include "ui/display/display.h" |
| 28 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 29 #include "ui/gfx/paint_vector_icon.h" | 30 #include "ui/gfx/paint_vector_icon.h" |
| 30 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
| 31 #include "ui/views/controls/image_view.h" | 32 #include "ui/views/controls/image_view.h" |
| 32 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 : SystemTrayItem(system_tray, UMA_DISPLAY_BRIGHTNESS), | 183 : SystemTrayItem(system_tray, UMA_DISPLAY_BRIGHTNESS), |
| 183 brightness_view_(NULL), | 184 brightness_view_(NULL), |
| 184 current_percent_(100.0), | 185 current_percent_(100.0), |
| 185 got_current_percent_(false), | 186 got_current_percent_(false), |
| 186 weak_ptr_factory_(this) { | 187 weak_ptr_factory_(this) { |
| 187 // Post a task to get the initial brightness; the BrightnessControlDelegate | 188 // Post a task to get the initial brightness; the BrightnessControlDelegate |
| 188 // isn't created yet. | 189 // isn't created yet. |
| 189 base::ThreadTaskRunnerHandle::Get()->PostTask( | 190 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 190 FROM_HERE, base::Bind(&TrayBrightness::GetInitialBrightness, | 191 FROM_HERE, base::Bind(&TrayBrightness::GetInitialBrightness, |
| 191 weak_ptr_factory_.GetWeakPtr())); | 192 weak_ptr_factory_.GetWeakPtr())); |
| 192 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( | 193 DBusThreadManagerAsh::Get()->GetPowerManagerClient()->AddObserver( |
| 193 this); | 194 this); |
| 194 } | 195 } |
| 195 | 196 |
| 196 TrayBrightness::~TrayBrightness() { | 197 TrayBrightness::~TrayBrightness() { |
| 197 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 198 DBusThreadManagerAsh::Get()->GetPowerManagerClient()->RemoveObserver( |
| 198 this); | 199 this); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void TrayBrightness::GetInitialBrightness() { | 202 void TrayBrightness::GetInitialBrightness() { |
| 202 BrightnessControlDelegate* brightness_control_delegate = | 203 BrightnessControlDelegate* brightness_control_delegate = |
| 203 WmShell::Get()->brightness_control_delegate(); | 204 WmShell::Get()->brightness_control_delegate(); |
| 204 // Worrisome, but happens in unit tests, so don't log anything. | 205 // Worrisome, but happens in unit tests, so don't log anything. |
| 205 if (!brightness_control_delegate) | 206 if (!brightness_control_delegate) |
| 206 return; | 207 return; |
| 207 brightness_control_delegate->GetBrightnessPercent( | 208 brightness_control_delegate->GetBrightnessPercent( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (!display::Display::HasInternalDisplay()) | 278 if (!display::Display::HasInternalDisplay()) |
| 278 return; | 279 return; |
| 279 | 280 |
| 280 if (brightness_view_) | 281 if (brightness_view_) |
| 281 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); | 282 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); |
| 282 else | 283 else |
| 283 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); | 284 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); |
| 284 } | 285 } |
| 285 | 286 |
| 286 } // namespace ash | 287 } // namespace ash |
| OLD | NEW |