Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / login / reset_screen_handler.h
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
17 class PrefRegistrySimple;
18
19 namespace chromeos {
20
21 // WebUI implementation of ResetScreenActor.
22 class 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(bool should_rollback);
55   void HandleOnPowerwash(bool rollback_checked);
56   void HandleOnLearnMore();
57
58   void ChooseAndApplyShowScenario();
59   void ShowWithParams();
60
61   Delegate* delegate_;
62
63   // Help application used for help dialogs.
64   scoped_refptr<HelpAppLauncher> help_app_;
65
66   // Keeps whether screen should be shown right after initialization.
67   bool show_on_init_;
68
69   // Keeps whether restart is required before reset.
70   // False if first exec after boot.
71   bool restart_required_;
72
73   // Keeps whether previous reboot was requested from reset screen. Makes sense
74   // for first exec after boot situation.
75   bool reboot_was_requested_;
76
77   // Keeps whether rollback option is available fo.
78   bool rollback_available_;
79
80   // Whether rollback is initiated.
81   bool preparing_for_rollback_;
82
83   base::WeakPtrFactory<ResetScreenHandler> weak_ptr_factory_;
84
85   DISALLOW_COPY_AND_ASSIGN(ResetScreenHandler);
86 };
87
88 }  // namespace chromeos
89
90 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_