update_notification_controller.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_
  5. #define ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/model/update_model.h"
  8. #include "base/files/file_path.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace gfx {
  11. struct VectorIcon;
  12. }
  13. namespace message_center {
  14. enum class SystemNotificationWarningLevel;
  15. }
  16. namespace ash {
  17. class ShutdownConfirmationDialog;
  18. // Controller class to manage update notification.
  19. class ASH_EXPORT UpdateNotificationController : public UpdateObserver {
  20. public:
  21. UpdateNotificationController();
  22. UpdateNotificationController(const UpdateNotificationController&) = delete;
  23. UpdateNotificationController& operator=(const UpdateNotificationController&) =
  24. delete;
  25. ~UpdateNotificationController() override;
  26. // UpdateObserver:
  27. void OnUpdateAvailable() override;
  28. // Callback functions for Shutdown Confirmation Dialog which is generated
  29. // when the device bootup process is occasionally slow - eg. memory training
  30. // during the bootup due to a system firmware update.
  31. void RestartForUpdate();
  32. void RestartCancelled();
  33. private:
  34. friend class UpdateNotificationControllerTest;
  35. bool ShouldShowUpdate() const;
  36. bool ShouldShowDeferredUpdate() const;
  37. std::u16string GetTitle() const;
  38. std::u16string GetMessage() const;
  39. const gfx::VectorIcon& GetIcon() const;
  40. message_center::SystemNotificationWarningLevel GetWarningLevel() const;
  41. void HandleNotificationClick(absl::optional<int> index);
  42. void GenerateUpdateNotification(
  43. absl::optional<bool> slow_boot_file_path_exists);
  44. UpdateModel* const model_;
  45. base::FilePath slow_boot_file_path_;
  46. bool slow_boot_file_path_exists_ = false;
  47. ShutdownConfirmationDialog* confirmation_dialog_ = nullptr;
  48. base::WeakPtrFactory<UpdateNotificationController> weak_ptr_factory_{this};
  49. };
  50. } // namespace ash
  51. #endif // ASH_SYSTEM_UPDATE_UPDATE_NOTIFICATION_CONTROLLER_H_