| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300; | 74 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300; |
| 75 default: | 75 default: |
| 76 NOTREACHED(); | 76 NOTREACHED(); |
| 77 break; | 77 break; |
| 78 } | 78 } |
| 79 return default_color; | 79 return default_color; |
| 80 } | 80 } |
| 81 | 81 |
| 82 class UpdateView : public ActionableView { | 82 class UpdateView : public ActionableView { |
| 83 public: | 83 public: |
| 84 explicit UpdateView(const UpdateInfo& info) : label_(nullptr) { | 84 UpdateView(SystemTrayItem* owner, const UpdateInfo& info) |
| 85 : ActionableView(owner), label_(nullptr) { |
| 85 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 86 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 86 kTrayPopupPaddingHorizontal, 0, | 87 kTrayPopupPaddingHorizontal, 0, |
| 87 kTrayPopupPaddingBetweenItems)); | 88 kTrayPopupPaddingBetweenItems)); |
| 88 | 89 |
| 89 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 90 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 90 views::ImageView* image = | 91 views::ImageView* image = |
| 91 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 92 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 93 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 93 image->SetImage(gfx::CreateVectorIcon( | 94 image->SetImage(gfx::CreateVectorIcon( |
| 94 kSystemMenuUpdateIcon, | 95 kSystemMenuUpdateIcon, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 } | 111 } |
| 111 | 112 |
| 112 ~UpdateView() override {} | 113 ~UpdateView() override {} |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 // Overridden from ActionableView. | 116 // Overridden from ActionableView. |
| 116 bool PerformAction(const ui::Event& event) override { | 117 bool PerformAction(const ui::Event& event) override { |
| 117 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); | 118 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); |
| 118 WmShell::Get()->RecordUserMetricsAction( | 119 WmShell::Get()->RecordUserMetricsAction( |
| 119 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); | 120 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); |
| 121 CloseSystemBubble(); |
| 120 return true; | 122 return true; |
| 121 } | 123 } |
| 122 | 124 |
| 123 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 125 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
| 124 ActionableView::OnNativeThemeChanged(theme); | 126 ActionableView::OnNativeThemeChanged(theme); |
| 125 | 127 |
| 126 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 128 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 127 return; | 129 return; |
| 128 | 130 |
| 129 TrayPopupItemStyle style(GetNativeTheme(), | 131 TrayPopupItemStyle style(GetNativeTheme(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 149 | 151 |
| 150 bool TrayUpdate::GetInitialVisibility() { | 152 bool TrayUpdate::GetInitialVisibility() { |
| 151 UpdateInfo info; | 153 UpdateInfo info; |
| 152 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 154 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 153 return info.update_required; | 155 return info.update_required; |
| 154 } | 156 } |
| 155 | 157 |
| 156 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { | 158 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { |
| 157 UpdateInfo info; | 159 UpdateInfo info; |
| 158 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 160 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 159 return info.update_required ? new UpdateView(info) : nullptr; | 161 return info.update_required ? new UpdateView(this, info) : nullptr; |
| 160 } | 162 } |
| 161 | 163 |
| 162 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { | 164 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { |
| 163 if (MaterialDesignController::UseMaterialDesignSystemIcons()) | 165 if (MaterialDesignController::UseMaterialDesignSystemIcons()) |
| 164 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); | 166 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); |
| 165 else | 167 else |
| 166 SetImageFromResourceId(DecideResource(info.severity, false)); | 168 SetImageFromResourceId(DecideResource(info.severity, false)); |
| 167 tray_view()->SetVisible(true); | 169 tray_view()->SetVisible(true); |
| 168 } | 170 } |
| 169 | 171 |
| 170 } // namespace ash | 172 } // namespace ash |
| OLD | NEW |