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_RESET_SCREEN_HANDLER_H_ 6#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_ 7 8#include "base/compiler_specific.h" 9#include "base/memory/ref_counted.h" 10#include "base/memory/weak_ptr.h" 11#include "chrome/browser/chromeos/login/help_app_launcher.h" 12#include "chrome/browser/chromeos/login/screens/reset_screen_actor.h" 13#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 14#include "chromeos/dbus/update_engine_client.h" 15#include "content/public/browser/web_ui.h" 16 17class PrefRegistrySimple; 18 19namespace chromeos { 20 21// WebUI implementation of ResetScreenActor. 22class ResetScreenHandler : public ResetScreenActor, 23 public BaseScreenHandler, 24 public UpdateEngineClient::Observer { 25 public: 26 ResetScreenHandler(); 27 virtual ~ResetScreenHandler(); 28 29 // ResetScreenActor implementation: 30 virtual void PrepareToShow() OVERRIDE; 31 virtual void Show() OVERRIDE; 32 virtual void Hide() OVERRIDE; 33 virtual void SetDelegate(Delegate* delegate) OVERRIDE; 34 35 // BaseScreenHandler implementation: 36 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; 37 virtual void Initialize() OVERRIDE; 38 39 // WebUIMessageHandler implementation: 40 virtual void RegisterMessages() OVERRIDE; 41 42 // UpdateEngineClient::Observer implementation: 43 virtual void UpdateStatusChanged( 44 const UpdateEngineClient::Status& status) OVERRIDE; 45 46 void OnRollbackCheck(bool can_rollback); 47 48 // Registers Local State preferences. 49 static void RegisterPrefs(PrefRegistrySimple* registry); 50 51 private: 52 // JS messages handlers. 53 void HandleOnCancel(); 54 void HandleOnRestart(); 55 void HandleOnPowerwash(bool rollback_checked); 56 void HandleOnLearnMore(); 57 void HandleOnShowRollback(); 58 void HandleOnHideRollback(); 59 void HandleOnShowConfirm(); 60 61 void ChooseAndApplyShowScenario(); 62 void ShowWithParams(); 63 64 Delegate* delegate_; 65 66 // Help application used for help dialogs. 67 scoped_refptr<HelpAppLauncher> help_app_; 68 69 // Keeps whether screen should be shown right after initialization. 70 bool show_on_init_; 71 72 // Keeps whether restart is required before reset. 73 // False if first exec after boot. 74 bool restart_required_; 75 76 // Keeps whether previous reboot was requested from reset screen. Makes sense 77 // for first exec after boot situation. 78 bool reboot_was_requested_; 79 80 // Keeps whether rollback option is available. 81 bool rollback_available_; 82 83 // Keeps whether rollback option is active at the screen. 84 bool rollback_checked_; 85 86 // Whether rollback is initiated. Prevents screen-hide. 87 bool preparing_for_rollback_; 88 89 base::WeakPtrFactory<ResetScreenHandler> weak_ptr_factory_; 90 91 DISALLOW_COPY_AND_ASSIGN(ResetScreenHandler); 92}; 93 94} // namespace chromeos 95 96#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_ 97