| 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/update/tray_update.h" | 5 #include "ash/system/update/tray_update.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_action.h" | 7 #include "ash/metrics/user_metrics_action.h" |
| 8 #include "ash/public/interfaces/update.mojom.h" | 8 #include "ash/public/interfaces/update.mojom.h" |
| 9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 bool TrayUpdate::update_required_ = false; | 58 bool TrayUpdate::update_required_ = false; |
| 59 // static | 59 // static |
| 60 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE; | 60 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE; |
| 61 // static | 61 // static |
| 62 bool TrayUpdate::factory_reset_required_ = false; | 62 bool TrayUpdate::factory_reset_required_ = false; |
| 63 mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::NONE; |
| 63 | 64 |
| 64 // The "restart to update" item in the system tray menu. | 65 // The "restart to update" item in the system tray menu. |
| 65 class TrayUpdate::UpdateView : public ActionableView { | 66 class TrayUpdate::UpdateView : public ActionableView { |
| 66 public: | 67 public: |
| 67 explicit UpdateView(TrayUpdate* owner) | 68 explicit UpdateView(TrayUpdate* owner) |
| 68 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { | 69 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { |
| 69 SetLayoutManager(new views::FillLayout); | 70 SetLayoutManager(new views::FillLayout); |
| 70 | 71 |
| 71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 72 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 72 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | 73 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); |
| 73 AddChildView(tri_view); | 74 AddChildView(tri_view); |
| 74 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); | 75 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); |
| 75 image->SetImage(gfx::CreateVectorIcon( | 76 image->SetImage(gfx::CreateVectorIcon( |
| 76 kSystemMenuUpdateIcon, | 77 kSystemMenuUpdateIcon, |
| 77 IconColorForUpdateSeverity(owner->severity_, true))); | 78 IconColorForUpdateSeverity(owner->severity_, true))); |
| 78 tri_view->AddView(TriView::Container::START, image); | 79 tri_view->AddView(TriView::Container::START, image); |
| 79 | 80 |
| 80 base::string16 label_text = | 81 base::string16 label_text; |
| 81 owner->factory_reset_required_ | 82 if (owner->factory_reset_required_) { |
| 82 ? bundle.GetLocalizedString( | 83 label_text = bundle.GetLocalizedString( |
| 83 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) | 84 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE); |
| 84 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); | 85 } else if (owner->update_type_ == mojom::UpdateType::FLASH) { |
| 86 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH); |
| 87 } else { |
| 88 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); |
| 89 } |
| 90 |
| 85 SetAccessibleName(label_text); | 91 SetAccessibleName(label_text); |
| 86 auto* label = TrayPopupUtils::CreateDefaultLabel(); | 92 auto* label = TrayPopupUtils::CreateDefaultLabel(); |
| 87 label->SetText(label_text); | 93 label->SetText(label_text); |
| 88 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | 94 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 89 style.SetupLabel(label); | 95 style.SetupLabel(label); |
| 90 tri_view->AddView(TriView::Container::CENTER, label); | 96 tri_view->AddView(TriView::Container::CENTER, label); |
| 91 | 97 |
| 92 SetInkDropMode(InkDropHostView::InkDropMode::ON); | 98 SetInkDropMode(InkDropHostView::InkDropMode::ON); |
| 93 } | 99 } |
| 94 | 100 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 // If chrome tells ash there is an update available before this item's system | 122 // If chrome tells ash there is an update available before this item's system |
| 117 // tray is constructed then show the icon. | 123 // tray is constructed then show the icon. |
| 118 return update_required_; | 124 return update_required_; |
| 119 } | 125 } |
| 120 | 126 |
| 121 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { | 127 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { |
| 122 return update_required_ ? new UpdateView(this) : nullptr; | 128 return update_required_ ? new UpdateView(this) : nullptr; |
| 123 } | 129 } |
| 124 | 130 |
| 125 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity, | 131 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity, |
| 126 bool factory_reset_required) { | 132 bool factory_reset_required, |
| 133 mojom::UpdateType update_type) { |
| 127 // Cache update info so we can create the default view when the menu opens. | 134 // Cache update info so we can create the default view when the menu opens. |
| 128 update_required_ = true; | 135 update_required_ = true; |
| 129 severity_ = severity; | 136 severity_ = severity; |
| 130 factory_reset_required_ = factory_reset_required; | 137 factory_reset_required_ = factory_reset_required; |
| 138 update_type_ = update_type; |
| 131 | 139 |
| 132 // Show the icon in the tray. | 140 // Show the icon in the tray. |
| 133 SetIconColor(IconColorForUpdateSeverity(severity_, false)); | 141 SetIconColor(IconColorForUpdateSeverity(severity_, false)); |
| 134 tray_view()->SetVisible(true); | 142 tray_view()->SetVisible(true); |
| 135 } | 143 } |
| 136 | 144 |
| 137 } // namespace ash | 145 } // namespace ash |
| OLD | NEW |