- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / screens / base_screen.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_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/chromeos/login/screens/screen_context.h"
12
13 namespace base {
14 class DictionaryValue;
15 }
16
17 namespace chromeos {
18
19 // Base class for the all OOBE/login/before-session screens.
20 // Screens are identified by ID, screen and it's JS counterpart must have same
21 // id.
22 // Most of the screens will be re-created for each appearance with Initialize()
23 // method called just once. However if initialization is too expensive, screen
24 // can override result of IsPermanent() method, and do clean-up upon subsequent
25 // Initialize() method calls.
26 class BaseScreen {
27  public:
28   BaseScreen();
29   virtual ~BaseScreen();
30
31   // ---- Old implementation ----
32
33   virtual void PrepareToShow() = 0;
34
35   // Makes wizard screen visible.
36   virtual void Show() = 0;
37
38   // Makes wizard screen invisible.
39   virtual void Hide() = 0;
40
41   // Returns the screen name.
42   virtual std::string GetName() const = 0;
43
44   // ---- New Implementation ----
45
46   // Called to perform initialization of the screen. UI is guaranteed to exist
47   // at this point. Screen can alter context, resulting context will be passed
48   // to JS. This method will be called once per instance of the Screen object,
49   // unless |IsPermanent()| returns |true|.
50   virtual void Initialize(ScreenContext* context);
51
52   // Called when screen appears.
53   virtual void OnShow();
54   // Called when screen disappears, either because it finished it's work, or
55   // because some other screen pops up.
56   virtual void OnHide();
57
58   // 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
60   // soon.
61   virtual void OnClose();
62
63   // Indicates whether status area should be displayed while this screen is
64   // displayed.
65   virtual bool IsStatusAreaDisplayed();
66
67   // If this method returns |true|, screen will not be deleted once we leave it.
68   // However, Initialize() might be called several times in this case.
69   virtual bool IsPermanent();
70
71   // Returns the identifier of the screen.
72   virtual std::string GetID() const;
73
74  protected:
75   // Screen can call this method to notify framework that it have finished
76   // it's work with |outcome|.
77   void Finish(const std::string& outcome);
78
79   // Called when button with |button_id| was pressed. Notification
80   // about this event comes from the JS counterpart.
81   virtual void OnButtonPressed(const std::string& button_id);
82
83   // Called when context for the currenct screen was
84   // changed. Notification about this event comes from the JS
85   // counterpart.
86   virtual void OnContextChanged(const base::DictionaryValue* diff);
87
88  private:
89   friend class ScreenManager;
90   void SetContext(ScreenContext* context);
91
92   DISALLOW_COPY_AND_ASSIGN(BaseScreen);
93 };
94
95 }  // namespace chromeos
96
97 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_