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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_UPDATE_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_UPDATE_SCREEN_HANDLER_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/compiler_specific.h" 12 #include "base/macros.h" 13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 14 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 15 16 namespace chromeos { 17 18 class UpdateScreen; 19 20 // Interface for dependency injection between WelcomeScreen and its actual 21 // representation. Owned by UpdateScreen. 22 class UpdateView { 23 public: 24 // The screen name must never change. It's stored into local state as a 25 // pending screen during OOBE update. So the value should be the same between 26 // versions. 27 constexpr static StaticOobeScreenId kScreenId{"oobe-update"}; 28 29 // Enumeration of UI states. These values must be kept in sync with 30 // UpdateUIState in JS code. 31 enum class UIState { 32 kCheckingForUpdate = 0, 33 KUpdateInProgress = 1, 34 kRestartInProgress = 2, 35 kManualReboot = 3, 36 }; 37 ~UpdateView()38 virtual ~UpdateView() {} 39 40 // Shows the contents of the screen. 41 virtual void Show() = 0; 42 43 // Hides the contents of the screen. 44 virtual void Hide() = 0; 45 46 // Binds `screen` to the view. 47 virtual void Bind(UpdateScreen* screen) = 0; 48 49 // Unbinds the screen from the view. 50 virtual void Unbind() = 0; 51 52 virtual void SetUIState(UIState value) = 0; 53 virtual void SetUpdateStatus(int percent, 54 const base::string16& percent_message, 55 const base::string16& timeleft_message) = 0; 56 // Set the estimated time left, in seconds. 57 virtual void SetEstimatedTimeLeft(int value) = 0; 58 virtual void SetShowEstimatedTimeLeft(bool value) = 0; 59 virtual void SetUpdateCompleted(bool value) = 0; 60 virtual void SetShowCurtain(bool value) = 0; 61 virtual void SetProgressMessage(const base::string16& value) = 0; 62 virtual void SetProgress(int value) = 0; 63 virtual void SetRequiresPermissionForCellular(bool value) = 0; 64 virtual void SetCancelUpdateShortcutEnabled(bool value) = 0; 65 virtual void ShowLowBatteryWarningMessage(bool value) = 0; 66 }; 67 68 class UpdateScreenHandler : public UpdateView, public BaseScreenHandler { 69 public: 70 using TView = UpdateView; 71 72 explicit UpdateScreenHandler(JSCallsContainer* js_calls_container); 73 ~UpdateScreenHandler() override; 74 75 private: 76 // UpdateView: 77 void Show() override; 78 void Hide() override; 79 void Bind(UpdateScreen* screen) override; 80 void Unbind() override; 81 82 void SetUIState(UpdateView::UIState value) override; 83 void SetUpdateStatus(int percent, 84 const base::string16& percent_message, 85 const base::string16& timeleft_message) override; 86 void SetEstimatedTimeLeft(int value) override; 87 void SetShowEstimatedTimeLeft(bool value) override; 88 void SetUpdateCompleted(bool value) override; 89 void SetShowCurtain(bool value) override; 90 void SetProgressMessage(const base::string16& value) override; 91 void SetProgress(int value) override; 92 void SetRequiresPermissionForCellular(bool value) override; 93 void SetCancelUpdateShortcutEnabled(bool value) override; 94 void ShowLowBatteryWarningMessage(bool value) override; 95 96 // Notification of a change in the accessibility settings. 97 void OnAccessibilityStatusChanged( 98 const AccessibilityStatusEventDetails& details); 99 100 // BaseScreenHandler: 101 void DeclareLocalizedValues( 102 ::login::LocalizedValuesBuilder* builder) override; 103 void GetAdditionalParameters(base::DictionaryValue* dict) override; 104 void Initialize() override; 105 106 UpdateScreen* screen_ = nullptr; 107 108 std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_; 109 110 // If true, Initialize() will call Show(). 111 bool show_on_init_ = false; 112 113 DISALLOW_COPY_AND_ASSIGN(UpdateScreenHandler); 114 }; 115 116 } // namespace chromeos 117 118 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_UPDATE_SCREEN_HANDLER_H_ 119