| 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/tray_update.h" | 5 #include "ash/system/tray_update.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 base::string16 label = | 79 base::string16 label = |
| 80 info.factory_reset_required | 80 info.factory_reset_required |
| 81 ? bundle.GetLocalizedString( | 81 ? bundle.GetLocalizedString( |
| 82 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) | 82 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) |
| 83 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); | 83 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); |
| 84 AddChildView(new views::Label(label)); | 84 AddChildView(new views::Label(label)); |
| 85 SetAccessibleName(label); | 85 SetAccessibleName(label); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual ~UpdateView() {} | 88 ~UpdateView() override {} |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 // Overridden from ActionableView. | 91 // Overridden from ActionableView. |
| 92 virtual bool PerformAction(const ui::Event& event) override { | 92 bool PerformAction(const ui::Event& event) override { |
| 93 ash::Shell::GetInstance()-> | 93 ash::Shell::GetInstance()-> |
| 94 system_tray_delegate()->RequestRestartForUpdate(); | 94 system_tray_delegate()->RequestRestartForUpdate(); |
| 95 return true; | 95 return true; |
| 96 } | 96 } |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(UpdateView); | 98 DISALLOW_COPY_AND_ASSIGN(UpdateView); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } | 101 } |
| 102 | 102 |
| 103 namespace ash { | 103 namespace ash { |
| 104 namespace tray { | 104 namespace tray { |
| 105 | 105 |
| 106 class UpdateNagger : public ui::LayerAnimationObserver { | 106 class UpdateNagger : public ui::LayerAnimationObserver { |
| 107 public: | 107 public: |
| 108 explicit UpdateNagger(SystemTrayItem* owner) | 108 explicit UpdateNagger(SystemTrayItem* owner) |
| 109 : owner_(owner) { | 109 : owner_(owner) { |
| 110 RestartTimer(); | 110 RestartTimer(); |
| 111 owner_->system_tray()->GetWidget()->GetNativeView()->layer()-> | 111 owner_->system_tray()->GetWidget()->GetNativeView()->layer()-> |
| 112 GetAnimator()->AddObserver(this); | 112 GetAnimator()->AddObserver(this); |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual ~UpdateNagger() { | 115 ~UpdateNagger() override { |
| 116 StatusAreaWidget* status_area = | 116 StatusAreaWidget* status_area = |
| 117 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); | 117 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
| 118 if (status_area) { | 118 if (status_area) { |
| 119 status_area->system_tray()->GetWidget()->GetNativeView()->layer()-> | 119 status_area->system_tray()->GetWidget()->GetNativeView()->layer()-> |
| 120 GetAnimator()->RemoveObserver(this); | 120 GetAnimator()->RemoveObserver(this); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 void RestartTimer() { | 124 void RestartTimer() { |
| 125 timer_.Stop(); | 125 timer_.Stop(); |
| 126 timer_.Start(FROM_HERE, | 126 timer_.Start(FROM_HERE, |
| 127 base::TimeDelta::FromSeconds(kUpdateNaggingTimeSeconds), | 127 base::TimeDelta::FromSeconds(kUpdateNaggingTimeSeconds), |
| 128 this, | 128 this, |
| 129 &UpdateNagger::Nag); | 129 &UpdateNagger::Nag); |
| 130 } | 130 } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 void Nag() { | 133 void Nag() { |
| 134 owner_->PopupDetailedView(kShowUpdateNaggerForSeconds, false); | 134 owner_->PopupDetailedView(kShowUpdateNaggerForSeconds, false); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Overridden from ui::LayerAnimationObserver. | 137 // Overridden from ui::LayerAnimationObserver. |
| 138 virtual void OnLayerAnimationEnded( | 138 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override { |
| 139 ui::LayerAnimationSequence* sequence) override { | |
| 140 // TODO(oshima): Find out if the updator will be shown on non | 139 // TODO(oshima): Find out if the updator will be shown on non |
| 141 // primary display. | 140 // primary display. |
| 142 if (Shell::GetPrimaryRootWindowController()->shelf()->IsVisible()) | 141 if (Shell::GetPrimaryRootWindowController()->shelf()->IsVisible()) |
| 143 timer_.Stop(); | 142 timer_.Stop(); |
| 144 else if (!timer_.IsRunning()) | 143 else if (!timer_.IsRunning()) |
| 145 RestartTimer(); | 144 RestartTimer(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 virtual void OnLayerAnimationAborted( | 147 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {} |
| 149 ui::LayerAnimationSequence* sequence) override {} | |
| 150 | 148 |
| 151 virtual void OnLayerAnimationScheduled( | 149 void OnLayerAnimationScheduled( |
| 152 ui::LayerAnimationSequence* sequence) override {} | 150 ui::LayerAnimationSequence* sequence) override {} |
| 153 | 151 |
| 154 SystemTrayItem* owner_; | 152 SystemTrayItem* owner_; |
| 155 base::OneShotTimer<UpdateNagger> timer_; | 153 base::OneShotTimer<UpdateNagger> timer_; |
| 156 | 154 |
| 157 DISALLOW_COPY_AND_ASSIGN(UpdateNagger); | 155 DISALLOW_COPY_AND_ASSIGN(UpdateNagger); |
| 158 }; | 156 }; |
| 159 | 157 |
| 160 } // namespace tray | 158 } // namespace tray |
| 161 | 159 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 SetImageFromResourceId(DecideResource(info.severity, false)); | 196 SetImageFromResourceId(DecideResource(info.severity, false)); |
| 199 tray_view()->SetVisible(true); | 197 tray_view()->SetVisible(true); |
| 200 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() && | 198 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() && |
| 201 !nagger_.get()) { | 199 !nagger_.get()) { |
| 202 // The shelf is not visible, and there is no nagger scheduled. | 200 // The shelf is not visible, and there is no nagger scheduled. |
| 203 nagger_.reset(new tray::UpdateNagger(this)); | 201 nagger_.reset(new tray::UpdateNagger(this)); |
| 204 } | 202 } |
| 205 } | 203 } |
| 206 | 204 |
| 207 } // namespace ash | 205 } // namespace ash |
| OLD | NEW |