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 <string>
9 
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
13 
14 namespace chromeos {
15 
16 class UpdateScreen;
17 
18 // Interface for dependency injection between WelcomeScreen and its actual
19 // representation. Owned by UpdateScreen.
20 class UpdateView {
21  public:
22   constexpr static StaticOobeScreenId kScreenId{"update"};
23 
~UpdateView()24   virtual ~UpdateView() {}
25 
26   // Shows the contents of the screen.
27   virtual void Show() = 0;
28 
29   // Hides the contents of the screen.
30   virtual void Hide() = 0;
31 
32   // Binds |screen| to the view.
33   virtual void Bind(UpdateScreen* screen) = 0;
34 
35   // Unbinds the screen from the view.
36   virtual void Unbind() = 0;
37 
38   // Set the estimated time left, in seconds.
39   virtual void SetEstimatedTimeLeft(int value) = 0;
40   virtual void SetShowEstimatedTimeLeft(bool value) = 0;
41   virtual void SetUpdateCompleted(bool value) = 0;
42   virtual void SetShowCurtain(bool value) = 0;
43   virtual void SetProgressMessage(const base::string16& value) = 0;
44   virtual void SetProgress(int value) = 0;
45   virtual void SetRequiresPermissionForCellular(bool value) = 0;
46   virtual void SetCancelUpdateShortcutEnabled(bool value) = 0;
47 };
48 
49 class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
50  public:
51   using TView = UpdateView;
52 
53   explicit UpdateScreenHandler(JSCallsContainer* js_calls_container);
54   ~UpdateScreenHandler() override;
55 
56  private:
57   // UpdateView:
58   void Show() override;
59   void Hide() override;
60   void Bind(UpdateScreen* screen) override;
61   void Unbind() override;
62   void SetEstimatedTimeLeft(int value) override;
63   void SetShowEstimatedTimeLeft(bool value) override;
64   void SetUpdateCompleted(bool value) override;
65   void SetShowCurtain(bool value) override;
66   void SetProgressMessage(const base::string16& value) override;
67   void SetProgress(int value) override;
68   void SetRequiresPermissionForCellular(bool value) override;
69   void SetCancelUpdateShortcutEnabled(bool value) override;
70 
71   // BaseScreenHandler:
72   void DeclareLocalizedValues(
73       ::login::LocalizedValuesBuilder* builder) override;
74   void Initialize() override;
75 
76   UpdateScreen* screen_ = nullptr;
77 
78   // If true, Initialize() will call Show().
79   bool show_on_init_ = false;
80 
81   DISALLOW_COPY_AND_ASSIGN(UpdateScreenHandler);
82 };
83 
84 }  // namespace chromeos
85 
86 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_UPDATE_SCREEN_HANDLER_H_
87