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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_
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"
17 class PrefRegistrySimple;
21 // WebUI implementation of ResetScreenActor.
22 class ResetScreenHandler : public ResetScreenActor,
23 public BaseScreenHandler,
24 public UpdateEngineClient::Observer {
27 virtual ~ResetScreenHandler();
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;
35 // BaseScreenHandler implementation:
36 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
37 virtual void Initialize() OVERRIDE;
39 // WebUIMessageHandler implementation:
40 virtual void RegisterMessages() OVERRIDE;
42 // UpdateEngineClient::Observer implementation:
43 virtual void UpdateStatusChanged(
44 const UpdateEngineClient::Status& status) OVERRIDE;
46 void OnRollbackCheck(bool can_rollback);
48 // Registers Local State preferences.
49 static void RegisterPrefs(PrefRegistrySimple* registry);
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();
61 void ChooseAndApplyShowScenario();
62 void ShowWithParams();
66 // Help application used for help dialogs.
67 scoped_refptr<HelpAppLauncher> help_app_;
69 // Keeps whether screen should be shown right after initialization.
72 // Keeps whether restart is required before reset.
73 // False if first exec after boot.
74 bool restart_required_;
76 // Keeps whether previous reboot was requested from reset screen. Makes sense
77 // for first exec after boot situation.
78 bool reboot_was_requested_;
80 // Keeps whether rollback option is available.
81 bool rollback_available_;
83 // Keeps whether rollback option is active at the screen.
84 bool rollback_checked_;
86 // Whether rollback is initiated. Prevents screen-hide.
87 bool preparing_for_rollback_;
89 base::WeakPtrFactory<ResetScreenHandler> weak_ptr_factory_;
91 DISALLOW_COPY_AND_ASSIGN(ResetScreenHandler);
94 } // namespace chromeos
96 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_