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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_
10 #include "base/basictypes.h"
11 #include "chrome/browser/chromeos/login/screens/screen_context.h"
14 class DictionaryValue
;
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
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.
29 virtual ~BaseScreen();
31 // ---- Old implementation ----
33 virtual void PrepareToShow() = 0;
35 // Makes wizard screen visible.
36 virtual void Show() = 0;
38 // Makes wizard screen invisible.
39 virtual void Hide() = 0;
41 // Returns the screen name.
42 virtual std::string
GetName() const = 0;
44 // ---- New Implementation ----
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
);
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();
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
61 virtual void OnClose();
63 // Indicates whether status area should be displayed while this screen is
65 virtual bool IsStatusAreaDisplayed();
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();
71 // Returns the identifier of the screen.
72 virtual std::string
GetID() const;
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
);
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
);
83 // Called when context for the currenct screen was
84 // changed. Notification about this event comes from the JS
86 virtual void OnContextChanged(const base::DictionaryValue
* diff
);
89 friend class ScreenManager
;
90 void SetContext(ScreenContext
* context
);
92 DISALLOW_COPY_AND_ASSIGN(BaseScreen
);
95 } // namespace chromeos
97 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_BASE_SCREEN_H_