blob: 1801c3695a90bbc4ee42b923fb6e212666b72e68 [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,
41 const std::optional<std::string>& supplied_trigger_id);
Wenyu Fuf358b902023-09-26 23:52:4242
43 SurveyClientAndroid(const SurveyClientAndroid&) = delete;
44 SurveyClientAndroid& operator=(const SurveyClientAndroid&) = delete;
45
46 ~SurveyClientAndroid();
47
48 // Launch the survey with identifier if appropriate. Similar interface to
49 // |HatsService::LaunchSurvey|.
50 void LaunchSurvey(ui::WindowAndroid* window,
51 const SurveyBitsData& product_specific_bits_data = {},
52 const SurveyStringData& product_specific_string_data = {});
53
54 // Destroy the instance and clean up the dependencies.
55 void Destroy();
56
57 private:
58 std::unique_ptr<SurveyUiDelegateAndroid> ui_delegate_;
59 base::android::ScopedJavaGlobalRef<jobject> jobj_;
60};
61
62} // namespace hats
63
64#endif // CHROME_BROWSER_UI_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_