1 // Copyright 2013 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_FIRST_RUN_STEP_H_
6 #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEP_H_
7 
8 #include <string>
9 
10 #include "base/macros.h"
11 #include "base/time/time.h"
12 
13 namespace chromeos {
14 
15 class FirstRunActor;
16 class FirstRunController;
17 
18 namespace first_run {
19 
20 class Step {
21  public:
22   Step(const std::string& name,
23        FirstRunController* controller,
24        FirstRunActor* actor);
25   virtual ~Step();
26 
27   // Step shows its content. Return whether the step was successfully shown.
28   // Returns false if the step should be skipped.
29   bool Show();
30 
31   // Called before hiding step.
32   void OnBeforeHide();
33 
34   // Called after step has been hidden.
35   void OnAfterHide();
36 
name()37   const std::string& name() const { return name_; }
38 
39  protected:
first_run_controller()40   FirstRunController* first_run_controller() { return first_run_controller_; }
actor()41   FirstRunActor* actor() const { return actor_; }
42 
43   // Called from Show method. Returns false if the step should be skipped, true
44   // otherwise.
45   virtual bool DoShow() = 0;
46 
47   // Called from OnBeforeHide. Step implementation could override this method to
48   // react on corresponding event.
DoOnBeforeHide()49   virtual void DoOnBeforeHide() {}
50 
51   // Called from OnAfterHide. Step implementation could override this method to
52   // react on event.
DoOnAfterHide()53   virtual void DoOnAfterHide() {}
54 
55  private:
56   // Records time spent on step to UMA.
57   void RecordCompletion();
58 
59   std::string name_;
60   FirstRunController* first_run_controller_;
61   FirstRunActor* actor_;
62   base::Time show_time_;
63 
64   DISALLOW_COPY_AND_ASSIGN(Step);
65 };
66 
67 }  // namespace first_run
68 }  // namespace chromeos
69 
70 #endif  // CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEP_H_
71