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_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_ACTOR_H_
6#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_ACTOR_H_
7
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
11
12namespace base {
13class DictionaryValue;
14}
15
16namespace chromeos {
17
18class FirstRunActor {
19 public:
20  class Delegate {
21   public:
22    virtual ~Delegate() {}
23
24    // Called after actor was initialized.
25    virtual void OnActorInitialized() = 0;
26
27    // Called when user clicked "Next" button in step with name |step_name|.
28    virtual void OnNextButtonClicked(const std::string& step_name) = 0;
29
30    // Called when user clicked "Keep exploring" button.
31    virtual void OnHelpButtonClicked() = 0;
32
33    // Called after step with |step_name| has been shown.
34    virtual void OnStepShown(const std::string& step_name) = 0;
35
36    // Called after step with |step_name| has been shown.
37    virtual void OnStepHidden(const std::string& step_name) = 0;
38
39    // Called in answer to Finalize() call.
40    virtual void OnActorFinalized() = 0;
41
42    // Notifies about about actor destruction.
43    virtual void OnActorDestroyed() = 0;
44  };
45
46  class StepPosition {
47   public:
48    // Initializes fields in "non-set" state.
49    StepPosition();
50
51    // Setters for properties. Return |*this|.
52    StepPosition& SetTop(int top);
53    StepPosition& SetRight(int right);
54    StepPosition& SetBottom(int bottom);
55    StepPosition& SetLeft(int left);
56
57    // Returns DictionaryValue containing set properties.
58    scoped_ptr<base::DictionaryValue> AsValue() const;
59
60   private:
61    int top_;
62    int right_;
63    int bottom_;
64    int left_;
65  };
66
67  FirstRunActor();
68  virtual ~FirstRunActor();
69
70  // Returns |true| if actor is initialized. Other public methods can be called
71  // only if |IsInitialized| returns |true|.
72  virtual bool IsInitialized() = 0;
73
74  // Changes background visibility.
75  virtual void SetBackgroundVisible(bool visible) = 0;
76
77  // Adds rectangular hole to background with given position and dimensions.
78  virtual void AddRectangularHole(int x, int y, int width, int height) = 0;
79
80  // Adds round hole to background with given position and dimensions.
81  virtual void AddRoundHole(int x, int y, float radius) = 0;
82
83  // Removes all holes from background.
84  virtual void RemoveBackgroundHoles() = 0;
85
86  // Shows step with given name and position.
87  virtual void ShowStepPositioned(const std::string& name,
88                                  const StepPosition& position) = 0;
89
90  // Shows step with given name that points to given point.
91  virtual void ShowStepPointingTo(const std::string& name,
92                                  int x,
93                                  int y,
94                                  int offset) = 0;
95
96  // Hides currently shown step.
97  virtual void HideCurrentStep() = 0;
98
99  // Hides all the UI.
100  virtual void Finalize() = 0;
101
102  // Whether actor is finalizing now.
103  virtual bool IsFinalizing() = 0;
104
105  void set_delegate(Delegate* delegate) { delegate_ = delegate; }
106  Delegate* delegate() const { return delegate_; }
107
108 private:
109  Delegate* delegate_;
110};
111
112}  // namespace chromeos
113
114#endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_ACTOR_H_
115
116