File: user_education_service.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (109 lines) | stat: -rw-r--r-- 4,761 bytes parent folder | download | duplicates (6)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_SERVICE_H_
#define CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_SERVICE_H_

#include <memory>

#include "base/feature_list.h"
#include "chrome/browser/user_education/browser_tutorial_service.h"
#include "chrome/browser/user_education/browser_user_education_storage_service.h"
#include "chrome/browser/user_education/recent_session_observer.h"
#include "chrome/browser/user_education/recent_session_tracker.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/user_education/common/feature_promo/feature_promo_registry.h"
#include "components/user_education/common/feature_promo/feature_promo_session_policy.h"
#include "components/user_education/common/help_bubble/help_bubble_factory_registry.h"
#include "components/user_education/common/new_badge/new_badge_controller.h"
#include "components/user_education/common/product_messaging_controller.h"
#include "components/user_education/common/session/user_education_session_manager.h"
#include "components/user_education/common/tutorial/tutorial.h"
#include "components/user_education/common/tutorial/tutorial_registry.h"
#include "components/user_education/common/user_education_storage_service.h"
#include "content/public/browser/browser_context.h"

// Kill switch for recent session tracking. Enabled by default.
BASE_DECLARE_FEATURE(kAllowRecentSessionTracking);

class UserEducationService : public KeyedService {
 public:
  explicit UserEducationService(
      std::unique_ptr<BrowserUserEducationStorageService> storage_service,
      bool allows_promos);
  ~UserEducationService() override;

  user_education::TutorialRegistry& tutorial_registry() {
    return tutorial_registry_;
  }
  user_education::TutorialService& tutorial_service() {
    return tutorial_service_;
  }
  user_education::HelpBubbleFactoryRegistry& help_bubble_factory_registry() {
    return help_bubble_factory_registry_;
  }
  user_education::FeaturePromoRegistry& feature_promo_registry() {
    return feature_promo_registry_;
  }
  user_education::ProductMessagingController& product_messaging_controller() {
    return product_messaging_controller_;
  }
  user_education::UserEducationStorageService&
  user_education_storage_service() {
    return *user_education_storage_service_;
  }
  user_education::UserEducationSessionManager&
  user_education_session_manager() {
    return user_education_session_manager_;
  }
  user_education::FeaturePromoSessionPolicy& feature_promo_session_policy() {
    return *feature_promo_session_policy_;
  }
  user_education::NewBadgeRegistry* new_badge_registry() {
    return new_badge_registry_.get();
  }
  user_education::NewBadgeController* new_badge_controller() {
    return new_badge_controller_.get();
  }
  RecentSessionTracker* recent_session_tracker() {
    return recent_session_tracker_.get();
  }
  RecentSessionObserver* recent_session_observer() {
    return recent_session_observer_.get();
  }

  // Utility methods for when a browser [window] isn't available; for example,
  // when only a WebContents is available:

  // Checks if a "New" Badge should be shown for the given `context` (or
  // profile), for `feature`.
  static user_education::DisplayNewBadge MaybeShowNewBadge(
      content::BrowserContext* context,
      const base::Feature& feature);

  // Notifies that a feature associated with a "New" Badge was used in `context`
  // (or profile), if the context supports User Education.
  static void MaybeNotifyNewBadgeFeatureUsed(content::BrowserContext* context,
                                             const base::Feature& feature);

 private:
  friend class UserEducationServiceFactory;

  user_education::TutorialRegistry tutorial_registry_;
  user_education::HelpBubbleFactoryRegistry help_bubble_factory_registry_;
  user_education::FeaturePromoRegistry feature_promo_registry_;
  BrowserTutorialService tutorial_service_;
  std::unique_ptr<BrowserUserEducationStorageService>
      user_education_storage_service_;
  user_education::UserEducationSessionManager user_education_session_manager_;
  std::unique_ptr<user_education::FeaturePromoSessionPolicy>
      feature_promo_session_policy_;
  user_education::ProductMessagingController product_messaging_controller_;
  std::unique_ptr<user_education::NewBadgeRegistry> new_badge_registry_;
  std::unique_ptr<user_education::NewBadgeController> new_badge_controller_;
  std::unique_ptr<RecentSessionTracker> recent_session_tracker_;
  std::unique_ptr<RecentSessionObserver> recent_session_observer_;
};

#endif  // CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_SERVICE_H_