Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 1 | // 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 Ramasubramanian | 893ca92 | 2020-01-29 18:49:07 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 11 | #include "base/macros.h" |
| 12 | |
| 13 | namespace ash { |
| 14 | |
Karthikeyan Ramasubramanian | 3e698a6 | 2020-01-30 02:02:41 | [diff] [blame] | 15 | class ShutdownConfirmationDialog; |
| 16 | |
Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 17 | // Controller class to manage update notification. |
| 18 | class ASH_EXPORT UpdateNotificationController : public UpdateObserver { |
| 19 | public: |
| 20 | UpdateNotificationController(); |
| 21 | ~UpdateNotificationController() override; |
| 22 | |
| 23 | // UpdateObserver: |
| 24 | void OnUpdateAvailable() override; |
| 25 | |
Karthikeyan Ramasubramanian | 3e698a6 | 2020-01-30 02:02:41 | [diff] [blame] | 26 | // 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 Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 32 | private: |
| 33 | friend class UpdateNotificationControllerTest; |
| 34 | |
| 35 | bool ShouldShowUpdate() const; |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 36 | std::u16string GetNotificationTitle() const; |
| 37 | std::u16string GetNotificationMessage() const; |
Tatsuhisa Yamaguchi | a4864842 | 2018-06-11 05:08:42 | [diff] [blame] | 38 | void HandleNotificationClick(base::Optional<int> index); |
Karthikeyan Ramasubramanian | 893ca92 | 2020-01-29 18:49:07 | [diff] [blame] | 39 | void GenerateUpdateNotification( |
| 40 | base::Optional<bool> slow_boot_file_path_exists); |
Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 41 | |
Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 42 | UpdateModel* const model_; |
| 43 | |
Karthikeyan Ramasubramanian | 893ca92 | 2020-01-29 18:49:07 | [diff] [blame] | 44 | base::FilePath slow_boot_file_path_; |
| 45 | bool slow_boot_file_path_exists_ = false; |
Karthikeyan Ramasubramanian | 3e698a6 | 2020-01-30 02:02:41 | [diff] [blame] | 46 | ShutdownConfirmationDialog* confirmation_dialog_ = nullptr; |
Karthikeyan Ramasubramanian | 893ca92 | 2020-01-29 18:49:07 | [diff] [blame] | 47 | |
Tetsui Ohkubo | 03e4776 | 2018-05-18 06:01:52 | [diff] [blame] | 48 | 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_ |