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_SCREENS_BASE_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 class ModelViewChannel; | 22 class ModelViewChannel; |
23 | 23 |
24 // Base class for the all OOBE/login/before-session screens. | 24 // Base class for the all OOBE/login/before-session screens. |
25 // Screens are identified by ID, screen and it's JS counterpart must have same | 25 // Screens are identified by ID, screen and it's JS counterpart must have same |
26 // id. | 26 // id. |
27 // Most of the screens will be re-created for each appearance with Initialize() | 27 // Most of the screens will be re-created for each appearance with Initialize() |
28 // method called just once. | 28 // method called just once. |
29 class BaseScreen { | 29 class BaseScreen { |
30 public: | 30 public: |
31 explicit BaseScreen(BaseScreenDelegate* base_screen_delegate); | 31 explicit BaseScreen(BaseScreenDelegate* base_screen_delegate, |
32 const std::string& screen_id); | |
32 virtual ~BaseScreen(); | 33 virtual ~BaseScreen(); |
33 | 34 |
34 // ---- Old implementation ---- | 35 // ---- Old implementation ---- |
35 | 36 |
36 // Makes wizard screen visible. | 37 // Makes wizard screen visible. |
37 virtual void Show() = 0; | 38 virtual void Show() = 0; |
38 | 39 |
39 // Makes wizard screen invisible. | 40 // Makes wizard screen invisible. |
40 virtual void Hide() = 0; | 41 virtual void Hide() = 0; |
41 | 42 |
42 // Returns the screen name. | |
43 virtual std::string GetName() const = 0; | |
44 | |
45 // ---- New Implementation ---- | 43 // ---- New Implementation ---- |
46 | 44 |
47 // Called to perform initialization of the screen. UI is guaranteed to exist | 45 // Called to perform initialization of the screen. UI is guaranteed to exist |
48 // at this point. Screen can alter context, resulting context will be passed | 46 // at this point. Screen can alter context, resulting context will be passed |
49 // to JS. This method will be called once per instance of the Screen object. | 47 // to JS. This method will be called once per instance of the Screen object. |
50 virtual void Initialize(::login::ScreenContext* context); | 48 virtual void Initialize(::login::ScreenContext* context); |
51 | 49 |
52 // Called when screen appears. | 50 // Called when screen appears. |
53 virtual void OnShow(); | 51 virtual void OnShow(); |
54 // Called when screen disappears, either because it finished it's work, or | 52 // Called when screen disappears, either because it finished it's work, or |
55 // because some other screen pops up. | 53 // because some other screen pops up. |
56 virtual void OnHide(); | 54 virtual void OnHide(); |
57 | 55 |
58 // Called when we navigate from screen so that we will never return to it. | 56 // Called when we navigate from screen so that we will never return to it. |
59 // This is a last chance to call JS counterpart, this object will be deleted | 57 // This is a last chance to call JS counterpart, this object will be deleted |
60 // soon. | 58 // soon. |
61 virtual void OnClose(); | 59 virtual void OnClose(); |
62 | 60 |
63 // Indicates whether status area should be displayed while this screen is | 61 // Indicates whether status area should be displayed while this screen is |
64 // displayed. | 62 // displayed. |
65 virtual bool IsStatusAreaDisplayed(); | 63 virtual bool IsStatusAreaDisplayed(); |
66 | 64 |
67 // Returns the identifier of the screen. | 65 // Returns the identifier of the screen. |
68 virtual std::string GetID() const; | 66 std::string screen_id() const { return screen_id_; } |
achuithb
2017/01/03 23:20:30
return const reference.
Why screen_id instead of
jdufault
2017/01/04 21:49:27
Done.
| |
69 | 67 |
70 // Called when user action event with |event_id| | 68 // Called when user action event with |event_id| |
71 // happened. Notification about this event comes from the JS | 69 // happened. Notification about this event comes from the JS |
72 // counterpart. | 70 // counterpart. |
73 virtual void OnUserAction(const std::string& action_id); | 71 virtual void OnUserAction(const std::string& action_id); |
74 | 72 |
75 void set_model_view_channel(ModelViewChannel* channel) { channel_ = channel; } | 73 void set_model_view_channel(ModelViewChannel* channel) { channel_ = channel; } |
76 | 74 |
77 protected: | 75 protected: |
78 // Scoped context editor, which automatically commits all pending | 76 // Scoped context editor, which automatically commits all pending |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 friend class ScreenManager; | 140 friend class ScreenManager; |
143 friend class UpdateScreenTest; | 141 friend class UpdateScreenTest; |
144 | 142 |
145 void SetContext(::login::ScreenContext* context); | 143 void SetContext(::login::ScreenContext* context); |
146 | 144 |
147 // Called when context for the current screen was | 145 // Called when context for the current screen was |
148 // changed. Notification about this event comes from the JS | 146 // changed. Notification about this event comes from the JS |
149 // counterpart. | 147 // counterpart. |
150 void OnContextChanged(const base::DictionaryValue& diff); | 148 void OnContextChanged(const base::DictionaryValue& diff); |
151 | 149 |
152 ModelViewChannel* channel_; | 150 ModelViewChannel* channel_ = nullptr; |
153 | 151 |
154 BaseScreenDelegate* base_screen_delegate_; | 152 BaseScreenDelegate* base_screen_delegate_ = nullptr; |
153 | |
154 std::string screen_id_; | |
achuithb
2017/01/03 23:20:30
make this const as well?
jdufault
2017/01/04 21:49:27
Done.
| |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(BaseScreen); | 156 DISALLOW_COPY_AND_ASSIGN(BaseScreen); |
157 }; | 157 }; |
158 | 158 |
159 } // namespace chromeos | 159 } // namespace chromeos |
160 | 160 |
161 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_ | 161 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_ |
OLD | NEW |