| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/power/tray_power.h" | 5 #include "ash/system/chromeos/power/tray_power.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/chromeos/power/power_status_view.h" | 10 #include "ash/system/chromeos/power/power_status_view.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 if (battery_alert) { | 71 if (battery_alert) { |
| 72 accessible_name_ = PowerStatus::Get()->GetAccessibleNameString(true); | 72 accessible_name_ = PowerStatus::Get()->GetAccessibleNameString(true); |
| 73 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 73 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SetupNotifyBadCharger() { | 77 void SetupNotifyBadCharger() { |
| 78 // Poll with a shorter duration timer to notify the charger issue | 78 // Poll with a shorter duration timer to notify the charger issue |
| 79 // for the first time after the charger dialog is displayed. | 79 // for the first time after the charger dialog is displayed. |
| 80 spring_charger_accessility_timer_.Start( | 80 spring_charger_accessibility_timer_.Start( |
| 81 FROM_HERE, base::TimeDelta::FromSeconds( | 81 FROM_HERE, base::TimeDelta::FromSeconds( |
| 82 kSpringChargerAccessibilityTimerFirstTimeNotifyInSeconds), | 82 kSpringChargerAccessibilityTimerFirstTimeNotifyInSeconds), |
| 83 this, &PowerTrayView::NotifyChargerIssue); | 83 this, &PowerTrayView::NotifyChargerIssue); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 void UpdateImage() { | 87 void UpdateImage() { |
| 88 SetImage(PowerStatus::Get()->GetBatteryImage(PowerStatus::ICON_LIGHT)); | 88 SetImage(PowerStatus::Get()->GetBatteryImage(PowerStatus::ICON_LIGHT)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void NotifyChargerIssue() { | 91 void NotifyChargerIssue() { |
| 92 if (!Shell::GetInstance()->accessibility_delegate()-> | 92 if (!Shell::GetInstance()->accessibility_delegate()-> |
| 93 IsSpokenFeedbackEnabled()) | 93 IsSpokenFeedbackEnabled()) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 if (!Shell::GetInstance()->system_tray_delegate()-> | 96 if (!Shell::GetInstance()->system_tray_delegate()-> |
| 97 IsSpringChargerReplacementDialogVisible()) { | 97 IsSpringChargerReplacementDialogVisible()) { |
| 98 spring_charger_accessility_timer_.Stop(); | 98 spring_charger_accessibility_timer_.Stop(); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 accessible_name_ = ui::ResourceBundle::GetSharedInstance(). | 102 accessible_name_ = ui::ResourceBundle::GetSharedInstance(). |
| 103 GetLocalizedString(IDS_CHARGER_REPLACEMENT_ACCESSIBILTY_NOTIFICATION); | 103 GetLocalizedString(IDS_CHARGER_REPLACEMENT_ACCESSIBILITY_NOTIFICATION); |
| 104 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 104 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 105 ++spring_charger_spoken_notification_count_; | 105 ++spring_charger_spoken_notification_count_; |
| 106 | 106 |
| 107 if (spring_charger_spoken_notification_count_ == 1) { | 107 if (spring_charger_spoken_notification_count_ == 1) { |
| 108 // After notify the charger issue for the first time, repeat the | 108 // After notify the charger issue for the first time, repeat the |
| 109 // notification with a longer duration timer. | 109 // notification with a longer duration timer. |
| 110 spring_charger_accessility_timer_.Stop(); | 110 spring_charger_accessibility_timer_.Stop(); |
| 111 spring_charger_accessility_timer_.Start( | 111 spring_charger_accessibility_timer_.Start( |
| 112 FROM_HERE, base::TimeDelta::FromMinutes( | 112 FROM_HERE, base::TimeDelta::FromMinutes( |
| 113 kSpringChargerAccessibilityTimerRepeatInMinutes), | 113 kSpringChargerAccessibilityTimerRepeatInMinutes), |
| 114 this, &PowerTrayView::NotifyChargerIssue); | 114 this, &PowerTrayView::NotifyChargerIssue); |
| 115 } else if (spring_charger_spoken_notification_count_ >= | 115 } else if (spring_charger_spoken_notification_count_ >= |
| 116 kMaxSpringChargerAccessibilityNotifyCount) { | 116 kMaxSpringChargerAccessibilityNotifyCount) { |
| 117 spring_charger_accessility_timer_.Stop(); | 117 spring_charger_accessibility_timer_.Stop(); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 base::string16 accessible_name_; | 121 base::string16 accessible_name_; |
| 122 | 122 |
| 123 // Tracks how many times the original spring charger accessibility | 123 // Tracks how many times the original spring charger accessibility |
| 124 // notification has been spoken. | 124 // notification has been spoken. |
| 125 int spring_charger_spoken_notification_count_; | 125 int spring_charger_spoken_notification_count_; |
| 126 | 126 |
| 127 base::RepeatingTimer<PowerTrayView> spring_charger_accessility_timer_; | 127 base::RepeatingTimer<PowerTrayView> spring_charger_accessibility_timer_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(PowerTrayView); | 129 DISALLOW_COPY_AND_ASSIGN(PowerTrayView); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 class PowerNotificationView : public TrayNotificationView { | 132 class PowerNotificationView : public TrayNotificationView { |
| 133 public: | 133 public: |
| 134 explicit PowerNotificationView(TrayPower* owner) | 134 explicit PowerNotificationView(TrayPower* owner) |
| 135 : TrayNotificationView(owner, 0) { | 135 : TrayNotificationView(owner, 0) { |
| 136 power_status_view_ = | 136 power_status_view_ = |
| 137 new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION, true); | 137 new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION, true); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 if (current_charger != UNKNOWN_CHARGER) { | 391 if (current_charger != UNKNOWN_CHARGER) { |
| 392 UMA_HISTOGRAM_ENUMERATION("Power.ChargerType", | 392 UMA_HISTOGRAM_ENUMERATION("Power.ChargerType", |
| 393 current_charger, | 393 current_charger, |
| 394 CHARGER_TYPE_COUNT); | 394 CHARGER_TYPE_COUNT); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace ash | 398 } // namespace ash |
| OLD | NEW |