| 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/tray_update.h" | 5 #include "ash/system/tray_update.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/fixed_sized_image_view.h" | 7 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 8 #include "ash/common/system/tray/system_tray_delegate.h" | 8 #include "ash/common/system/tray/system_tray_delegate.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ash/common/wm_shell.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/system/tray/system_tray_notifier.h" | 13 #include "ash/system/tray/system_tray_notifier.h" |
| 13 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 14 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 18 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); | 69 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); |
| 69 AddChildView(new views::Label(label)); | 70 AddChildView(new views::Label(label)); |
| 70 SetAccessibleName(label); | 71 SetAccessibleName(label); |
| 71 } | 72 } |
| 72 | 73 |
| 73 ~UpdateView() override {} | 74 ~UpdateView() override {} |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 // Overridden from ActionableView. | 77 // Overridden from ActionableView. |
| 77 bool PerformAction(const ui::Event& event) override { | 78 bool PerformAction(const ui::Event& event) override { |
| 78 ash::Shell::GetInstance()-> | 79 ash::WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); |
| 79 system_tray_delegate()->RequestRestartForUpdate(); | |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(UpdateView); | 83 DISALLOW_COPY_AND_ASSIGN(UpdateView); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } | 86 } |
| 87 | 87 |
| 88 namespace ash { | 88 namespace ash { |
| 89 | 89 |
| 90 TrayUpdate::TrayUpdate(SystemTray* system_tray) | 90 TrayUpdate::TrayUpdate(SystemTray* system_tray) |
| 91 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE) { | 91 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE) { |
| 92 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this); | 92 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TrayUpdate::~TrayUpdate() { | 95 TrayUpdate::~TrayUpdate() { |
| 96 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this); | 96 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool TrayUpdate::GetInitialVisibility() { | 99 bool TrayUpdate::GetInitialVisibility() { |
| 100 UpdateInfo info; | 100 UpdateInfo info; |
| 101 Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 101 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 102 return info.update_required; | 102 return info.update_required; |
| 103 } | 103 } |
| 104 | 104 |
| 105 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { | 105 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { |
| 106 UpdateInfo info; | 106 UpdateInfo info; |
| 107 Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info); | 107 WmShell::Get()->system_tray_delegate()->GetSystemUpdateInfo(&info); |
| 108 return info.update_required ? new UpdateView(info) : nullptr; | 108 return info.update_required ? new UpdateView(info) : nullptr; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { | 111 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { |
| 112 SetImageFromResourceId(DecideResource(info.severity, false)); | 112 SetImageFromResourceId(DecideResource(info.severity, false)); |
| 113 tray_view()->SetVisible(true); | 113 tray_view()->SetVisible(true); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace ash | 116 } // namespace ash |
| OLD | NEW |