Chromium Code Reviews| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300; | 73 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300; |
| 74 default: | 74 default: |
| 75 NOTREACHED(); | 75 NOTREACHED(); |
| 76 break; | 76 break; |
| 77 } | 77 } |
| 78 return default_color; | 78 return default_color; |
| 79 } | 79 } |
| 80 | 80 |
| 81 class UpdateView : public ActionableView { | 81 class UpdateView : public ActionableView { |
| 82 public: | 82 public: |
| 83 explicit UpdateView(const UpdateInfo& info) { | 83 explicit UpdateView(SystemTrayItem* owner, const UpdateInfo& info) |
|
James Cook
2016/09/22 21:17:17
no explicit
oshima
2016/09/23 09:37:20
Done.
| |
| 84 : ActionableView(owner) { | |
| 84 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 85 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 85 kTrayPopupPaddingHorizontal, 0, | 86 kTrayPopupPaddingHorizontal, 0, |
| 86 kTrayPopupPaddingBetweenItems)); | 87 kTrayPopupPaddingBetweenItems)); |
| 87 | 88 |
| 88 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 89 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 89 views::ImageView* image = | 90 views::ImageView* image = |
| 90 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 91 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 91 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 92 image->SetImage(gfx::CreateVectorIcon( | 93 image->SetImage(gfx::CreateVectorIcon( |
| 93 kSystemMenuUpdateIcon, | 94 kSystemMenuUpdateIcon, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 108 } | 109 } |
| 109 | 110 |
| 110 ~UpdateView() override {} | 111 ~UpdateView() override {} |
| 111 | 112 |
| 112 private: | 113 private: |
| 113 // Overridden from ActionableView. | 114 // Overridden from ActionableView. |
| 114 bool PerformAction(const ui::Event& event) override { | 115 bool PerformAction(const ui::Event& event) override { |
| 115 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); | 116 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); |
| 116 WmShell::Get()->RecordUserMetricsAction( | 117 WmShell::Get()->RecordUserMetricsAction( |
| 117 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); | 118 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); |
| 119 CloseSystemBubble(); | |
| 118 return true; | 120 return true; |
| 119 } | 121 } |
| 120 | 122 |
| 121 DISALLOW_COPY_AND_ASSIGN(UpdateView); | 123 DISALLOW_COPY_AND_ASSIGN(UpdateView); |
| 122 }; | 124 }; |
| 123 | 125 |
| 124 } // namespace | 126 } // namespace |
| 125 | 127 |
| 126 TrayUpdate::TrayUpdate(SystemTray* system_tray) | 128 TrayUpdate::TrayUpdate(SystemTray* system_tray) |
| 127 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) { | 129 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) { |
| 128 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this); | 130 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this); |
| 129 } | 131 } |
| 130 | 132 |
| 131 TrayUpdate::~TrayUpdate() { | 133 TrayUpdate::~TrayUpdate() { |
| 132 WmShell::Get()->system_tray_notifier()->RemoveUpdateObserver(this); | 134 WmShell::Get()->system_tray_notifier()->RemoveUpdateObserver(this); |
| 133 } | 135 } |
| 134 | 136 |
| 135 bool TrayUpdate::GetInitialVisibility() { | 137 bool TrayUpdate::GetInitialVisibility() { |
| 136 UpdateInfo info; | 138 UpdateInfo info; |
| 137 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 139 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 138 return info.update_required; | 140 return info.update_required; |
| 139 } | 141 } |
| 140 | 142 |
| 141 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { | 143 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { |
| 142 UpdateInfo info; | 144 UpdateInfo info; |
| 143 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 145 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 144 return info.update_required ? new UpdateView(info) : nullptr; | 146 return info.update_required ? new UpdateView(this, info) : nullptr; |
| 145 } | 147 } |
| 146 | 148 |
| 147 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { | 149 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { |
| 148 if (MaterialDesignController::UseMaterialDesignSystemIcons()) | 150 if (MaterialDesignController::UseMaterialDesignSystemIcons()) |
| 149 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); | 151 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); |
| 150 else | 152 else |
| 151 SetImageFromResourceId(DecideResource(info.severity, false)); | 153 SetImageFromResourceId(DecideResource(info.severity, false)); |
| 152 tray_view()->SetVisible(true); | 154 tray_view()->SetVisible(true); |
| 153 } | 155 } |
| 154 | 156 |
| 155 } // namespace ash | 157 } // namespace ash |
| OLD | NEW |