blob: 393a517c0276e0e3ca3535b2a0d0283eec373d13 [file] [log] [blame]
Wenyu Fuf358b902023-09-26 23:52:421// Copyright 2023 The Chromium Authors
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_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_
6#define CHROME_BROWSER_UI_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_
7
8#include <jni.h>
Peter Kastinga4863242024-12-23 00:19:439
Wenyu Fuf358b902023-09-26 23:52:4210#include <memory>
11#include <string>
12
13#include "base/android/jni_android.h"
14#include "base/functional/callback_helpers.h"
Florian Jacky298d7902023-10-26 14:59:2415#include "chrome/browser/profiles/profile.h"
Wenyu Fuf358b902023-09-26 23:52:4216#include "chrome/browser/ui/android/hats/survey_ui_delegate_android.h"
17#include "chrome/browser/ui/hats/survey_config.h"
18
19using base::android::JavaParamRef;
20using base::android::JavaRef;
21
22namespace ui {
23class WindowAndroid;
24} // namespace ui
25
26namespace hats {
27
28// Key-value mapping type for survey's product specific bits data.
29typedef std::map<std::string, bool> SurveyBitsData;
30
31// Key-value mapping type for survey's product specific string data.
32typedef std::map<std::string, std::string> SurveyStringData;
33
34// C++ equivalent of Java SurveyClient.
35class SurveyClientAndroid {
36 public:
Florian Jacky308b3572024-01-22 10:00:5437 explicit SurveyClientAndroid(
38 const std::string& trigger,
39 SurveyUiDelegateAndroid* ui_delegate,
40 Profile* profile,
Kamil Jarosz15e087e2025-05-16 13:11:3941 const std::optional<std::string>& supplied_trigger_id,
42 ui::WindowAndroid* window);
Wenyu Fuf358b902023-09-26 23:52:4243
44 SurveyClientAndroid(const SurveyClientAndroid&) = delete;
45 SurveyClientAndroid& operator=(const SurveyClientAndroid&) = delete;
46
47 ~SurveyClientAndroid();
48
49 // Launch the survey with identifier if appropriate. Similar interface to
50 // |HatsService::LaunchSurvey|.
51 void LaunchSurvey(ui::WindowAndroid* window,
52 const SurveyBitsData& product_specific_bits_data = {},
53 const SurveyStringData& product_specific_string_data = {});
54
55 // Destroy the instance and clean up the dependencies.
56 void Destroy();
57
58 private:
59 std::unique_ptr<SurveyUiDelegateAndroid> ui_delegate_;
60 base::android::ScopedJavaGlobalRef<jobject> jobj_;
61};
62
63} // namespace hats
64
65#endif // CHROME_BROWSER_UI_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_