1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
ash / quick_insert / views / quick_insert_feature_tour.h [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_QUICK_INSERT_VIEWS_QUICK_INSERT_FEATURE_TOUR_H_
#define ASH_QUICK_INSERT_VIEWS_QUICK_INSERT_FEATURE_TOUR_H_
#include "ash/ash_export.h"
#include "base/functional/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/widget/unique_widget_ptr.h"
#include "ui/wm/public/activation_change_observer.h"
class PrefRegistrySimple;
class PrefService;
namespace aura {
class Window;
}
namespace views {
class Widget;
class Button;
} // namespace views
namespace wm {
class ActivationClient;
}
namespace ash {
class ASH_EXPORT QuickInsertFeatureTour : public wm::ActivationChangeObserver {
public:
enum class EditorStatus {
kEligible,
kNotEligible,
};
QuickInsertFeatureTour();
QuickInsertFeatureTour(const QuickInsertFeatureTour&) = delete;
QuickInsertFeatureTour& operator=(const QuickInsertFeatureTour&) = delete;
~QuickInsertFeatureTour() override;
// Registers Quick Insert feature tour prefs to the provided `registry`.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Disables the feature tour for tests.
static void DisableFeatureTourForTesting();
// Shows the feature tour dialog if the tour has not been shown before.
// `learn_more_callback` is called when the user has asked for more
// information. `completion_callback` is called when the user has completed
// the feature tour. Returns whether the feature tour dialog was shown or not.
// Both callbacks are guaranteed to be shown after the originally
// focused/activated (possibly-null) window regains focus/activation.
bool MaybeShowForFirstUse(PrefService* prefs,
EditorStatus editor_status,
base::RepeatingClosure learn_more_callback,
base::RepeatingClosure completion_callback);
// wm::ActivationChangeObserver overrides:
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
views::Widget* widget_for_testing();
// Returns the button to learn more.
const views::Button* learn_more_button_for_testing() const;
// Returns the button to complete the tour.
const views::Button* complete_button_for_testing() const;
// Returns the title of the feature tour.
std::u16string_view GetTitleTextForTesting() const;
// Returns the description of the feature tour.
std::u16string_view GetDescriptionForTesting() const;
private:
void SetOnWindowDeactivatedCallback(base::OnceClosure callback);
void RunOnWindowDeactivatedIfNeeded();
views::UniqueWidgetPtr widget_;
base::OnceClosure on_window_deactivated_callback_;
base::ScopedObservation<wm::ActivationClient, wm::ActivationChangeObserver>
obs_{this};
base::WeakPtrFactory<QuickInsertFeatureTour> weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_QUICK_INSERT_VIEWS_QUICK_INSERT_FEATURE_TOUR_H_