| 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/brightness/tray_brightness.h" | 5 #include "ash/system/brightness/tray_brightness.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/resources/grit/ash_resources.h" | 9 #include "ash/resources/grit/ash_resources.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_observer.h" | 12 #include "ash/shell_observer.h" |
| 13 #include "ash/shell_port.h" |
| 13 #include "ash/strings/grit/ash_strings.h" | 14 #include "ash/strings/grit/ash_strings.h" |
| 14 #include "ash/system/brightness_control_delegate.h" | 15 #include "ash/system/brightness_control_delegate.h" |
| 15 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
| 16 #include "ash/system/tray/tray_popup_utils.h" | 17 #include "ash/system/tray/tray_popup_utils.h" |
| 17 #include "ash/system/tray/tri_view.h" | 18 #include "ash/system/tray/tri_view.h" |
| 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 19 #include "ash/wm_shell.h" | |
| 20 #include "base/bind.h" | 20 #include "base/bind.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/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 "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 27 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
| 28 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
| 29 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 views::View* TrayBrightness::CreateDefaultView(LoginStatus status) { | 217 views::View* TrayBrightness::CreateDefaultView(LoginStatus status) { |
| 218 CHECK(brightness_view_ == NULL); | 218 CHECK(brightness_view_ == NULL); |
| 219 brightness_view_ = new tray::BrightnessView(true, current_percent_); | 219 brightness_view_ = new tray::BrightnessView(true, current_percent_); |
| 220 return brightness_view_; | 220 return brightness_view_; |
| 221 } | 221 } |
| 222 | 222 |
| 223 views::View* TrayBrightness::CreateDetailedView(LoginStatus status) { | 223 views::View* TrayBrightness::CreateDetailedView(LoginStatus status) { |
| 224 CHECK(brightness_view_ == NULL); | 224 CHECK(brightness_view_ == NULL); |
| 225 WmShell::Get()->RecordUserMetricsAction( | 225 ShellPort::Get()->RecordUserMetricsAction( |
| 226 UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW); | 226 UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW); |
| 227 brightness_view_ = new tray::BrightnessView(false, current_percent_); | 227 brightness_view_ = new tray::BrightnessView(false, current_percent_); |
| 228 return brightness_view_; | 228 return brightness_view_; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void TrayBrightness::DestroyTrayView() {} | 231 void TrayBrightness::DestroyTrayView() {} |
| 232 | 232 |
| 233 void TrayBrightness::DestroyDefaultView() { | 233 void TrayBrightness::DestroyDefaultView() { |
| 234 if (brightness_view_ && brightness_view_->is_default_view()) | 234 if (brightness_view_ && brightness_view_->is_default_view()) |
| 235 brightness_view_ = NULL; | 235 brightness_view_ = NULL; |
| 236 } | 236 } |
| 237 | 237 |
| 238 void TrayBrightness::DestroyDetailedView() { | 238 void TrayBrightness::DestroyDetailedView() { |
| 239 if (brightness_view_ && !brightness_view_->is_default_view()) | 239 if (brightness_view_ && !brightness_view_->is_default_view()) |
| 240 brightness_view_ = NULL; | 240 brightness_view_ = NULL; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void TrayBrightness::UpdateAfterLoginStatusChange(LoginStatus status) {} | 243 void TrayBrightness::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 244 | 244 |
| 245 bool TrayBrightness::ShouldShowShelf() const { | 245 bool TrayBrightness::ShouldShowShelf() const { |
| 246 return false; | 246 return false; |
| 247 } | 247 } |
| 248 | 248 |
| 249 void TrayBrightness::BrightnessChanged(int level, bool user_initiated) { | 249 void TrayBrightness::BrightnessChanged(int level, bool user_initiated) { |
| 250 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_BRIGHTNESS_CHANGED); | 250 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_BRIGHTNESS_CHANGED); |
| 251 double percent = static_cast<double>(level); | 251 double percent = static_cast<double>(level); |
| 252 HandleBrightnessChanged(percent, user_initiated); | 252 HandleBrightnessChanged(percent, user_initiated); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void TrayBrightness::HandleBrightnessChanged(double percent, | 255 void TrayBrightness::HandleBrightnessChanged(double percent, |
| 256 bool user_initiated) { | 256 bool user_initiated) { |
| 257 current_percent_ = percent; | 257 current_percent_ = percent; |
| 258 got_current_percent_ = true; | 258 got_current_percent_ = true; |
| 259 | 259 |
| 260 if (brightness_view_) | 260 if (brightness_view_) |
| 261 brightness_view_->SetBrightnessPercent(percent); | 261 brightness_view_->SetBrightnessPercent(percent); |
| 262 | 262 |
| 263 if (!user_initiated) | 263 if (!user_initiated) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 // Never show the bubble on systems that lack internal displays: if an | 266 // Never show the bubble on systems that lack internal displays: if an |
| 267 // external display's brightness is changed, it may already display the new | 267 // external display's brightness is changed, it may already display the new |
| 268 // level via an on-screen display. | 268 // level via an on-screen display. |
| 269 if (!display::Display::HasInternalDisplay()) | 269 if (!display::Display::HasInternalDisplay()) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 if (brightness_view_ && brightness_view_->visible()) | 272 if (brightness_view_ && brightness_view_->visible()) |
| 273 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); | 273 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); |
| 274 else | 274 else |
| 275 ShowDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); | 275 ShowDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace ash | 278 } // namespace ash |
| OLD | NEW |