OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 14 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 15 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 class WizardController; | 19 class WizardController; |
19 | 20 |
20 // Class that manages creation and ownership of screens. | 21 // Manages the overall creation and ownership of screens. This is the |
21 class ScreenManager { | 22 // CoreOobeView::Delegate instance which gets passed to the WebUI specific login |
| 23 // code. When a callback method is invoked, this class just dispatches it to |
| 24 // all registered delegates. |
| 25 class ScreenManager : public CoreOobeView::Delegate { |
22 public: | 26 public: |
23 // |wizard_controller| is not owned by this class. | 27 // |wizard_controller| is not owned by this class. |
24 explicit ScreenManager(WizardController* wizard_controller); | 28 explicit ScreenManager(WizardController* wizard_controller); |
25 ~ScreenManager(); | 29 ~ScreenManager() override; |
26 | 30 |
27 // Getter for screen with lazy initialization. | 31 // Getter for screen with lazy initialization. |
28 BaseScreen* GetScreen(OobeScreen screen); | 32 BaseScreen* GetScreen(OobeScreen screen); |
29 | 33 |
30 bool HasScreen(OobeScreen screen); | 34 bool HasScreen(OobeScreen screen); |
31 | 35 |
| 36 // Register a new delegate that will receive callbacks from UI-specific login |
| 37 // code. |
| 38 void AddDelegate(CoreOobeView::Delegate* delegate); |
| 39 |
32 private: | 40 private: |
33 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestCancel); | 41 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestCancel); |
34 FRIEND_TEST_ALL_PREFIXES(WizardControllerFlowTest, Accelerators); | 42 FRIEND_TEST_ALL_PREFIXES(WizardControllerFlowTest, Accelerators); |
35 friend class WizardControllerFlowTest; | 43 friend class WizardControllerFlowTest; |
36 friend class WizardControllerOobeResumeTest; | 44 friend class WizardControllerOobeResumeTest; |
37 friend class WizardInProcessBrowserTest; | 45 friend class WizardInProcessBrowserTest; |
38 friend class WizardControllerBrokenLocalStateTest; | 46 friend class WizardControllerBrokenLocalStateTest; |
39 | 47 |
| 48 // CoreOobeView::Delegate: |
| 49 void OnEnableDebuggingScreenViewExit(bool success) override; |
| 50 void OnViewDestroyed(CoreOobeView* view) override; |
| 51 |
40 // Created screens. | 52 // Created screens. |
41 std::map<OobeScreen, std::unique_ptr<BaseScreen>> screens_; | 53 std::map<OobeScreen, std::unique_ptr<BaseScreen>> screens_; |
42 | 54 |
| 55 // Unowned pointer to BaseScreen instances which implement |
| 56 // CoreOobeView::Delegate. The instances are owned by |screens_|. |
| 57 std::vector<CoreOobeView::Delegate*> delegates_; |
| 58 |
43 // Used to allocate BaseScreen instances. Unowned. | 59 // Used to allocate BaseScreen instances. Unowned. |
44 WizardController* wizard_controller_; | 60 WizardController* wizard_controller_; |
45 | 61 |
46 DISALLOW_COPY_AND_ASSIGN(ScreenManager); | 62 DISALLOW_COPY_AND_ASSIGN(ScreenManager); |
47 }; | 63 }; |
48 | 64 |
49 } // namespace chromeos | 65 } // namespace chromeos |
50 | 66 |
51 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ | 67 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ |
OLD | NEW |