1 // Copyright 2019 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_CHROMEOS_LOGIN_SCREENS_PACKAGED_LICENSE_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_PACKAGED_LICENSE_SCREEN_H_
7 
8 #include <string>
9 
10 #include "base/bind.h"
11 #include "base/macros.h"
12 #include "chrome/browser/chromeos/login/screens/base_screen.h"
13 
14 namespace chromeos {
15 
16 class PackagedLicenseView;
17 
18 // Screen which is shown before login and enterprise screens.
19 // It advertises the packaged license which allows user enroll device.
20 class PackagedLicenseScreen : public BaseScreen {
21  public:
22   enum class Result {
23     // Show login screen
24     DONT_ENROLL,
25     // Show enterprise enrollment screen
26     ENROLL,
27     // No information about license in the `enrollment_config_`
28     NOT_APPLICABLE
29   };
30 
31   static std::string GetResultString(Result result);
32 
33   using ScreenExitCallback = base::RepeatingCallback<void(Result result)>;
34   PackagedLicenseScreen(PackagedLicenseView* view,
35                         const ScreenExitCallback& exit_callback);
36   PackagedLicenseScreen(const PackagedLicenseScreen&) = delete;
37   PackagedLicenseScreen& operator=(const PackagedLicenseScreen&) = delete;
38   ~PackagedLicenseScreen() override;
39 
AddExitCallbackForTesting(const ScreenExitCallback & testing_callback)40   void AddExitCallbackForTesting(const ScreenExitCallback& testing_callback) {
41     exit_callback_ = base::BindRepeating(
42         [](const ScreenExitCallback& original_callback,
43            const ScreenExitCallback& testing_callback, Result result) {
44           original_callback.Run(result);
45           testing_callback.Run(result);
46         },
47         exit_callback_, testing_callback);
48   }
49 
50   // BaseScreen
51   bool MaybeSkip(WizardContext* context) override;
52 
53  protected:
54   // BaseScreen
55   void ShowImpl() override;
56   void HideImpl() override;
57   void OnUserAction(const std::string& action_id) override;
58 
59  private:
60   PackagedLicenseView* view_ = nullptr;
61 
62   ScreenExitCallback exit_callback_;
63 };
64 
65 }  // namespace chromeos
66 
67 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_PACKAGED_LICENSE_SCREEN_H_
68