[go: nahoru, domu]

blob: 0fd5490e557db48a869ba71a2f3d1237d4d41c23 [file] [log] [blame]
Tetsui Ohkubo03e47762018-05-18 06:01:521// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_
6#define ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_
7
8#include "ash/ash_export.h"
9#include "ash/system/model/update_model.h"
Karthikeyan Ramasubramanian893ca922020-01-29 18:49:0710#include "base/files/file_path.h"
Tetsui Ohkubo03e47762018-05-18 06:01:5211#include "base/macros.h"
12
13namespace ash {
14
Karthikeyan Ramasubramanian3e698a62020-01-30 02:02:4115class ShutdownConfirmationDialog;
16
Tetsui Ohkubo03e47762018-05-18 06:01:5217// Controller class to manage update notification.
18class ASH_EXPORT UpdateNotificationController : public UpdateObserver {
19 public:
20 UpdateNotificationController();
21 ~UpdateNotificationController() override;
22
23 // UpdateObserver:
24 void OnUpdateAvailable() override;
25
Karthikeyan Ramasubramanian3e698a62020-01-30 02:02:4126 // Callback functions for Shutdown Confirmation Dialog which is generated
27 // when the device bootup process is occasionally slow - eg. memory training
28 // during the bootup due to a system firmware update.
29 void RestartForUpdate();
30 void RestartCancelled();
31
Tetsui Ohkubo03e47762018-05-18 06:01:5232 private:
33 friend class UpdateNotificationControllerTest;
34
35 bool ShouldShowUpdate() const;
Jan Wilken Dörrie85285b02021-03-11 23:38:4736 std::u16string GetNotificationTitle() const;
37 std::u16string GetNotificationMessage() const;
Tatsuhisa Yamaguchia48648422018-06-11 05:08:4238 void HandleNotificationClick(base::Optional<int> index);
Karthikeyan Ramasubramanian893ca922020-01-29 18:49:0739 void GenerateUpdateNotification(
40 base::Optional<bool> slow_boot_file_path_exists);
Tetsui Ohkubo03e47762018-05-18 06:01:5241
Tetsui Ohkubo03e47762018-05-18 06:01:5242 UpdateModel* const model_;
43
Karthikeyan Ramasubramanian893ca922020-01-29 18:49:0744 base::FilePath slow_boot_file_path_;
45 bool slow_boot_file_path_exists_ = false;
Karthikeyan Ramasubramanian3e698a62020-01-30 02:02:4146 ShutdownConfirmationDialog* confirmation_dialog_ = nullptr;
Karthikeyan Ramasubramanian893ca922020-01-29 18:49:0747
Tetsui Ohkubo03e47762018-05-18 06:01:5248 base::WeakPtrFactory<UpdateNotificationController> weak_ptr_factory_{this};
49
50 DISALLOW_COPY_AND_ASSIGN(UpdateNotificationController);
51};
52
53} // namespace ash
54
55#endif // ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_