File: campaigns_manager_client.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (102 lines) | stat: -rw-r--r-- 3,523 bytes parent folder | download | duplicates (7)
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
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_GROWTH_CAMPAIGNS_MANAGER_CLIENT_H_
#define CHROMEOS_ASH_COMPONENTS_GROWTH_CAMPAIGNS_MANAGER_CLIENT_H_

#include <map>
#include <memory>
#include <optional>
#include <variant>

#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "chromeos/ash/components/growth/action_performer.h"
#include "chromeos/ash/components/growth/campaigns_constants.h"

namespace base {
class Version;
}  // namespace base

namespace signin {
class IdentityManager;
}  // namespace signin

namespace growth {

using CampaignComponentLoadedCallback = base::OnceCallback<void(
    const std::optional<const base::FilePath>& file_path)>;

using OnTrackerInitializedCallback =
    base::OnceCallback<void(bool init_success)>;

using ActionMap = std::map<ActionType, std::unique_ptr<ActionPerformer>>;

class CampaignsManagerClient {
 public:
  CampaignsManagerClient() = default;
  CampaignsManagerClient(const CampaignsManagerClient&) = delete;
  CampaignsManagerClient& operator=(const CampaignsManagerClient&) = delete;
  virtual ~CampaignsManagerClient() = default;

  // Loads campaigns component and trigger the `CampaignComponentLoadedCallback`
  // when loaded.
  virtual void LoadCampaignsComponent(
      CampaignComponentLoadedCallback callback) = 0;

  virtual void AddOnTrackerInitializedCallback(
      OnTrackerInitializedCallback callback) = 0;

  // True if the device is in demo mode.
  virtual bool IsDeviceInDemoMode() const = 0;

  // True if the device is cloud gaming device.
  virtual bool IsCloudGamingDevice() const = 0;

  // True if the device is feature aware device.
  virtual bool IsFeatureAwareDevice() const = 0;

  // True if the app icon is available on shelf.
  virtual bool IsAppIconOnShelf(const std::string& app_id) const = 0;

  // Returns application locale.
  virtual const std::string& GetApplicationLocale() const = 0;

  // Returns user selected locale.
  virtual const std::string& GetUserLocale() const = 0;

  // Returns the permanent country code stored for this client.
  // Country code is in the format of lowercase ISO 3166-1 alpha-2.
  // Example: `us`, `br`, `in`.
  virtual const std::string GetCountryCode() const = 0;

  // Get demo mode app component version.
  virtual const base::Version& GetDemoModeAppVersion() const = 0;

  // Get the implementations for the various Actions on the growth
  // framework.
  // TODO: b/330930157 - Rename to BuildCampaignsActions.
  virtual ActionMap GetCampaignsActions() = 0;

  // Register sythetical trial for current session.
  virtual void RegisterSyntheticFieldTrial(
      const std::string& trial_name,
      const std::string& group_name) const = 0;

  // Proxy to Feature Engagement methods.
  virtual void ClearConfig(
      const std::map<std::string, std::string>& params) = 0;
  virtual void RecordEvent(const std::string& event,
                           bool trigger_campaigns) = 0;
  virtual bool WouldTriggerHelpUI(
      const std::map<std::string, std::string>& params) = 0;
  // Returns the IdentityManager for the active user profile.
  virtual signin::IdentityManager* GetIdentityManager() const = 0;
  virtual void RecordImpressionEvents(int campaign_id,
                                      std::optional<int> group_id) = 0;
};

}  // namespace growth

#endif  // CHROMEOS_ASH_COMPONENTS_GROWTH_CAMPAIGNS_MANAGER_CLIENT_H_