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/common/system/update/tray_update.h" | 5 #include "ash/common/system/update/tray_update.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/metrics/user_metrics_action.h" | 8 #include "ash/common/metrics/user_metrics_action.h" |
9 #include "ash/common/system/tray/fixed_sized_image_view.h" | 9 #include "ash/common/system/tray/fixed_sized_image_view.h" |
10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); | 109 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); |
110 label_ = TrayPopupUtils::CreateDefaultLabel(); | 110 label_ = TrayPopupUtils::CreateDefaultLabel(); |
111 label_->SetText(label_text); | 111 label_->SetText(label_text); |
112 SetAccessibleName(label_text); | 112 SetAccessibleName(label_text); |
113 tri_view->AddView(TriView::Container::CENTER, label_); | 113 tri_view->AddView(TriView::Container::CENTER, label_); |
114 | 114 |
115 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 115 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
116 UpdateStyle(); | 116 UpdateStyle(); |
117 SetInkDropMode(InkDropHostView::InkDropMode::ON); | 117 SetInkDropMode(InkDropHostView::InkDropMode::ON); |
118 } | 118 } |
119 | |
120 component_update_required_ = info.component_update_required; | |
119 } | 121 } |
120 | 122 |
121 ~UpdateView() override {} | 123 ~UpdateView() override {} |
122 | 124 |
123 private: | 125 private: |
124 void UpdateStyle() { | 126 void UpdateStyle() { |
125 TrayPopupItemStyle style(GetNativeTheme(), | 127 TrayPopupItemStyle style(GetNativeTheme(), |
126 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | 128 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
127 style.SetupLabel(label_); | 129 style.SetupLabel(label_); |
128 } | 130 } |
129 | 131 |
130 // Overridden from ActionableView. | 132 // Overridden from ActionableView. |
131 bool PerformAction(const ui::Event& event) override { | 133 bool PerformAction(const ui::Event& event) override { |
132 WmShell::Get()->system_tray_controller()->RequestRestartForUpdate(); | 134 WmShell::Get()->system_tray_controller()->RequestRestartForUpdate( |
135 component_update_required_); | |
133 WmShell::Get()->RecordUserMetricsAction( | 136 WmShell::Get()->RecordUserMetricsAction( |
134 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); | 137 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); |
135 CloseSystemBubble(); | 138 CloseSystemBubble(); |
136 return true; | 139 return true; |
137 } | 140 } |
138 | 141 |
139 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 142 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
140 ActionableView::OnNativeThemeChanged(theme); | 143 ActionableView::OnNativeThemeChanged(theme); |
141 | 144 |
142 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 145 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
143 return; | 146 return; |
144 UpdateStyle(); | 147 UpdateStyle(); |
145 } | 148 } |
146 | 149 |
147 views::Label* label_; | 150 views::Label* label_; |
James Cook
2016/11/30 23:01:41
nit (if you keep this): either label_ = nullptr he
| |
151 bool component_update_required_ = false; | |
148 | 152 |
149 DISALLOW_COPY_AND_ASSIGN(UpdateView); | 153 DISALLOW_COPY_AND_ASSIGN(UpdateView); |
150 }; | 154 }; |
151 | 155 |
152 } // namespace | 156 } // namespace |
153 | 157 |
154 TrayUpdate::TrayUpdate(SystemTray* system_tray) | 158 TrayUpdate::TrayUpdate(SystemTray* system_tray) |
155 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) { | 159 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) { |
156 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this); | 160 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this); |
157 } | 161 } |
158 | 162 |
159 TrayUpdate::~TrayUpdate() { | 163 TrayUpdate::~TrayUpdate() { |
160 WmShell::Get()->system_tray_notifier()->RemoveUpdateObserver(this); | 164 WmShell::Get()->system_tray_notifier()->RemoveUpdateObserver(this); |
161 } | 165 } |
162 | 166 |
163 bool TrayUpdate::GetInitialVisibility() { | 167 bool TrayUpdate::GetInitialVisibility() { |
164 UpdateInfo info; | 168 UpdateInfo info; |
165 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 169 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
166 return info.update_required; | 170 return info.update_required; |
167 } | 171 } |
168 | 172 |
169 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { | 173 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { |
170 UpdateInfo info; | 174 UpdateInfo info; |
171 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 175 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
172 return info.update_required ? new UpdateView(this, info) : nullptr; | 176 return info.update_required || info.component_update_required |
177 ? new UpdateView(this, info) | |
178 : nullptr; | |
173 } | 179 } |
174 | 180 |
175 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { | 181 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { |
176 if (MaterialDesignController::UseMaterialDesignSystemIcons()) | 182 if (MaterialDesignController::UseMaterialDesignSystemIcons()) |
177 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); | 183 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); |
178 else | 184 else |
179 SetImageFromResourceId(DecideResource(info.severity, false)); | 185 SetImageFromResourceId(DecideResource(info.severity, false)); |
180 tray_view()->SetVisible(true); | 186 tray_view()->SetVisible(true); |
181 } | 187 } |
182 | 188 |
183 } // namespace ash | 189 } // namespace ash |
OLD | NEW |