Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2704)

Unified Diff: ash/system/update/tray_update.cc

Issue 2882933002: Add update available icon in system tray (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/update/tray_update.cc
diff --git a/ash/system/update/tray_update.cc b/ash/system/update/tray_update.cc
index a88ae9c671d86f174fbb3b2a2568b7e6361fe6a6..bdb4501e6682f19ac690e593591eb6d2f211eae5 100644
--- a/ash/system/update/tray_update.cc
+++ b/ash/system/update/tray_update.cc
@@ -55,11 +55,14 @@ SkColor IconColorForUpdateSeverity(mojom::UpdateSeverity severity,
} // namespace
// static
-bool TrayUpdate::update_required_ = false;
+bool TrayUpdate::upgrade_required_ = false;
// static
mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE;
// static
bool TrayUpdate::factory_reset_required_ = false;
+// static
+bool TrayUpdate::update_over_cellular_available_ = false;
+
mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::SYSTEM;
// The "restart to update" item in the system tray menu.
@@ -85,6 +88,10 @@ class TrayUpdate::UpdateView : public ActionableView {
IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE);
} else if (owner->update_type_ == mojom::UpdateType::FLASH) {
label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH);
+ } else if (!owner->upgrade_required_ &&
+ owner->update_over_cellular_available_) {
+ label_text = bundle.GetLocalizedString(
+ IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE);
} else {
label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
}
@@ -106,10 +113,17 @@ class TrayUpdate::UpdateView : public ActionableView {
private:
// Overridden from ActionableView.
- bool PerformAction(const ui::Event& event) override {
- Shell::Get()->system_tray_controller()->RequestRestartForUpdate();
- ShellPort::Get()->RecordUserMetricsAction(
- UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED);
+ bool PerformAction(const ui::Event& /* event */) override {
+ DCHECK(upgrade_required_ || update_over_cellular_available_);
+ if (upgrade_required_) {
+ Shell::Get()->system_tray_controller()->RequestRestartForUpdate();
+ ShellPort::Get()->RecordUserMetricsAction(
+ UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED);
+ } else {
+ // Opens about Chrome OS page, after which checks for update.
+ Shell::Get()->system_tray_controller()->ShowAboutChromeOS();
weidongg 2017/05/15 04:54:13 Here I want to show the about Chrome OS page first
stevenjb 2017/05/15 18:06:45 What is the reason for wanting to show the about p
weidongg 2017/05/15 20:06:57 In the design doc, clicking this icon will bring u
+ Shell::Get()->system_tray_controller()->RequestUpdateCheck();
+ }
CloseSystemBubble();
return true;
}
@@ -125,11 +139,11 @@ TrayUpdate::~TrayUpdate() {}
bool TrayUpdate::GetInitialVisibility() {
// If chrome tells ash there is an update available before this item's system
// tray is constructed then show the icon.
- return update_required_;
+ return upgrade_required_ || update_over_cellular_available_;
}
views::View* TrayUpdate::CreateDefaultView(LoginStatus status) {
- if (update_required_) {
+ if (upgrade_required_ || update_over_cellular_available_) {
update_view_ = new UpdateView(this);
return update_view_;
}
@@ -144,7 +158,7 @@ void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity,
bool factory_reset_required,
mojom::UpdateType update_type) {
// Cache update info so we can create the default view when the menu opens.
- update_required_ = true;
+ upgrade_required_ = true;
stevenjb 2017/05/15 18:06:45 Switching to 'upgrade' just seems confusing to me.
weidongg 2017/05/15 20:06:57 Ok, I see, I will refactor it back.
severity_ = severity;
factory_reset_required_ = factory_reset_required;
update_type_ = update_type;
@@ -158,4 +172,14 @@ views::Label* TrayUpdate::GetLabelForTesting() {
return update_view_ ? update_view_->update_label_ : nullptr;
}
+void TrayUpdate::ShowUpdateOverCellularAvailableIcon() {
+ update_over_cellular_available_ = true;
+
+ // TODO(weidongg/691108): adjust severity according the amount of time passing
+ // after update is available over cellular connection.
+ // Use low severity for update available over cellular connection.
+ SetIconColor(IconColorForUpdateSeverity(mojom::UpdateSeverity::LOW, false));
+ tray_view()->SetVisible(true);
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698