Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / first_run / first_run_controller.h
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_FIRST_RUN_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_CONTROLLER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "ash/first_run/first_run_helper.h"
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/time/time.h"
18 #include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
19
20 class Profile;
21
22 namespace content {
23 class WebContents;
24 }
25
26 namespace chromeos {
27
28 class FirstRunUIBrowserTest;
29
30 namespace first_run {
31 class Step;
32 }
33
34 // FirstRunController creates and manages first-run tutorial.
35 // Object manages its lifetime and deletes itself after completion of the
36 // tutorial.
37 class FirstRunController : public FirstRunActor::Delegate,
38                            public ash::FirstRunHelper::Observer {
39   typedef std::vector<linked_ptr<first_run::Step> > Steps;
40
41  public:
42   virtual ~FirstRunController();
43
44   // Creates first-run UI and starts tutorial.
45   static void Start();
46
47   // Finalizes first-run tutorial and destroys UI.
48   static void Stop();
49
50  private:
51   friend class FirstRunUIBrowserTest;
52
53   FirstRunController();
54   void Init();
55   void Finalize();
56
57   static FirstRunController* GetInstanceForTest();
58
59   // Overriden from FirstRunActor::Delegate.
60   virtual void OnActorInitialized() OVERRIDE;
61   virtual void OnNextButtonClicked(const std::string& step_name) OVERRIDE;
62   virtual void OnHelpButtonClicked() OVERRIDE;
63   virtual void OnStepShown(const std::string& step_name) OVERRIDE;
64   virtual void OnStepHidden(const std::string& step_name) OVERRIDE;
65   virtual void OnActorFinalized() OVERRIDE;
66   virtual void OnActorDestroyed() OVERRIDE;
67
68   // Overriden from ash::FirstRunHelper::Observer.
69   virtual void OnCancelled() OVERRIDE;
70
71   void RegisterSteps();
72   void ShowNextStep();
73   void AdvanceStep();
74   first_run::Step* GetCurrentStep() const;
75
76   // The object providing interface to UI layer. It's not directly owned by
77   // FirstRunController.
78   FirstRunActor* actor_;
79
80   // Helper for manipulating and retreiving information from Shell.
81   scoped_ptr<ash::FirstRunHelper> shell_helper_;
82
83   // List of all tutorial steps.
84   Steps steps_;
85
86   // Index of step that is currently shown.
87   size_t current_step_index_;
88
89   // Profile used for webui and help app.
90   Profile* user_profile_;
91
92   // The work that should be made after actor has been finalized.
93   base::Closure on_actor_finalized_;
94
95   // Web contents of WebUI.
96   content::WebContents* web_contents_for_tests_;
97
98   // Time when tutorial was started.
99   base::Time start_time_;
100
101   DISALLOW_COPY_AND_ASSIGN(FirstRunController);
102 };
103
104 }  // namespace chromeos
105
106 #endif  // CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_CONTROLLER_H_
107