blob: e08b6335a7fa2bf4556ae08dc3d81dd9a22812e6 [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>
9#include <memory>
10#include <string>
11
12#include "base/android/jni_android.h"
13#include "base/functional/callback_helpers.h"
Florian Jacky298d7902023-10-26 14:59:2414#include "chrome/browser/profiles/profile.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
21namespace ui {
22class WindowAndroid;
23} // namespace ui
24
25namespace hats {
26
27// Key-value mapping type for survey's product specific bits data.
28typedef std::map<std::string, bool> SurveyBitsData;
29
30// Key-value mapping type for survey's product specific string data.
31typedef std::map<std::string, std::string> SurveyStringData;
32
33// C++ equivalent of Java SurveyClient.
34class SurveyClientAndroid {
35 public:
36 explicit SurveyClientAndroid(const std::string& trigger,
Florian Jacky298d7902023-10-26 14:59:2437 SurveyUiDelegateAndroid* ui_delegate,
38 Profile* profile);
Wenyu Fuf358b902023-09-26 23:52:4239
40 SurveyClientAndroid(const SurveyClientAndroid&) = delete;
41 SurveyClientAndroid& operator=(const SurveyClientAndroid&) = delete;
42
43 ~SurveyClientAndroid();
44
45 // Launch the survey with identifier if appropriate. Similar interface to
46 // |HatsService::LaunchSurvey|.
47 void LaunchSurvey(ui::WindowAndroid* window,
48 const SurveyBitsData& product_specific_bits_data = {},
49 const SurveyStringData& product_specific_string_data = {});
50
51 // Destroy the instance and clean up the dependencies.
52 void Destroy();
53
54 private:
55 std::unique_ptr<SurveyUiDelegateAndroid> ui_delegate_;
56 base::android::ScopedJavaGlobalRef<jobject> jobj_;
57};
58
59} // namespace hats
60
61#endif // CHROME_BROWSER_UI_ANDROID_HATS_SURVEY_CLIENT_ANDROID_H_