blob: 6994bd4d6fe475e253e015d0c7a2e4fbff135e41 [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"
Wenyu Fuf358b902023-09-26 23:52:4215#include "chrome/browser/ui/android/hats/survey_ui_delegate_android.h"
16#include "chrome/browser/ui/hats/survey_config.h"
17
18using base::android::JavaParamRef;
19using base::android::JavaRef;
20
Antonio Gomes63093932025-05-21 17:57:0821class Profile;
22
Wenyu Fuf358b902023-09-26 23:52:4223namespace ui {
24class WindowAndroid;
25} // namespace ui
26
27namespace hats {
28
29// Key-value mapping type for survey's product specific bits data.
30typedef std::map<std::string, bool> SurveyBitsData;
31
32// Key-value mapping type for survey's product specific string data.
33typedef std::map<std::string, std::string> SurveyStringData;
34
35// C++ equivalent of Java SurveyClient.
36class SurveyClientAndroid {
37 public:
Florian Jacky308b3572024-01-22 10:00:5438 explicit SurveyClientAndroid(
39 const std::string& trigger,
40 SurveyUiDelegateAndroid* ui_delegate,
41 Profile* profile,
Kamil Jarosz15e087e2025-05-16 13:11:3942 const std::optional<std::string>& supplied_trigger_id,
43 ui::WindowAndroid* window);
Wenyu Fuf358b902023-09-26 23:52:4244
45 SurveyClientAndroid(const SurveyClientAndroid&) = delete;
46 SurveyClientAndroid& operator=(const SurveyClientAndroid&) = delete;
47
48 ~SurveyClientAndroid();
49
50 // Launch the survey with identifier if appropriate. Similar interface to
51 // |HatsService::LaunchSurvey|.
52 void LaunchSurvey(ui::WindowAndroid* window,
53 const SurveyBitsData& product_specific_bits_data = {},
54 const SurveyStringData& product_specific_string_data = {});
55
56 // Destroy the instance and clean up the dependencies.
57 void Destroy();
58
59 private:
60 std::unique_ptr<SurveyUiDelegateAndroid> ui_delegate_;
61 base::android::ScopedJavaGlobalRef<jobject> jobj_;
62};
63
64} // namespace hats
65
66#endif // CHROME_BROWSER_UI_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_