Commit 1d2da997 authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

[Android] Create a feedback module.

Currently HelpAndFeedback is not modularized, so a modularized fragment
is not able to use it due to circular dependency.

In this CL, create a feedback module and introduce two interfaces as a
workaround:
* HelpAndFeedbackLauncher, which is used to launch a help and feedback
page in an activity. HelpAndFeedback implements this interface.
* FragmentHelpAndFeedbackLauncher, which is used to inject
HelpAndFeedbackLauncher to a fragment. Any fragment that needs to
launch a help page implements this interface.

The safe_browsing module will depend on this new module to launch a
help page.

Bug: 1115758,1117343
Change-Id: I3d9d76f0ba87db26ae5bbe853f7b6cc38eb9353a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359749
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799475}
parent cc0b1c65
...@@ -189,6 +189,7 @@ android_resources("chrome_app_java_resources") { ...@@ -189,6 +189,7 @@ android_resources("chrome_app_java_resources") {
":ui_locale_string_resources", ":ui_locale_string_resources",
"//chrome/android/webapk/libs/common:splash_resources", "//chrome/android/webapk/libs/common:splash_resources",
"//chrome/app:java_strings_grd", "//chrome/app:java_strings_grd",
"//chrome/browser/feedback/android:java_resources",
"//chrome/browser/password_check/android:java_resources", "//chrome/browser/password_check/android:java_resources",
"//chrome/browser/ui/android/appmenu:java_resources", "//chrome/browser/ui/android/appmenu:java_resources",
"//chrome/browser/ui/android/default_browser_promo:java_resources", "//chrome/browser/ui/android/default_browser_promo:java_resources",
...@@ -311,6 +312,7 @@ android_library("chrome_java") { ...@@ -311,6 +312,7 @@ android_library("chrome_java") {
"//chrome/browser/download/android:java_resources", "//chrome/browser/download/android:java_resources",
"//chrome/browser/engagement/android:java", "//chrome/browser/engagement/android:java",
"//chrome/browser/enterprise/util:java", "//chrome/browser/enterprise/util:java",
"//chrome/browser/feedback/android:java",
"//chrome/browser/flags:java", "//chrome/browser/flags:java",
"//chrome/browser/fullscreen/android:java", "//chrome/browser/fullscreen/android:java",
"//chrome/browser/image_editor/public:java", "//chrome/browser/image_editor/public:java",
......
include_rules = [ include_rules = [
"+chrome/browser/browser_controls/android", "+chrome/browser/browser_controls/android",
"+chrome/browser/enterprise", "+chrome/browser/enterprise",
"+chrome/browser/feedback/android",
"+chrome/browser/flags/android", "+chrome/browser/flags/android",
"+chrome/browser/fullscreen/android", "+chrome/browser/fullscreen/android",
"+chrome/browser/notifications", "+chrome/browser/notifications",
......
...@@ -32,32 +32,6 @@ ...@@ -32,32 +32,6 @@
<integer name="reload_button_level_reload">0</integer> <integer name="reload_button_level_reload">0</integer>
<integer name="reload_button_level_stop">1</integer> <integer name="reload_button_level_stop">1</integer>
<!-- Help and Feedback
These constants should be in sync with the context names on go/mobilehelprecs.
If the context ID cannot be found, the default help page will be shown to the user.-->
<string name="help_context_autofill">android_autofill_ota</string>
<string name="help_context_new_tab">mobile_new_tab</string>
<string name="help_context_search_results">mobile_search_results</string>
<string name="help_context_webpage">mobile_webpage</string>
<string name="help_context_settings">mobile_settings</string>
<string name="help_context_incognito">mobile_incognito</string>
<string name="help_context_bookmarks">mobile_bookmarks</string>
<string name="help_context_history">mobile_history</string>
<string name="help_context_privacy">mobile_privacy</string>
<string name="help_context_general">mobile_general</string>
<string name="help_context_protected_content">protected_content</string>
<string name="help_context_data_reduction">reduce_data_usage</string>
<string name="help_context_incognito_learn_more">chrome_incognito</string>
<string name="help_context_sad_tab">mobile_awsnap</string>
<string name="help_context_clear_browsing_data">clear_browsing_data</string>
<string name="help_context_change_sync_passphrase">change_sync_passphrase</string>
<string name="help_context_sync_and_services">syncgoogleservices</string>
<string name="help_context_passwords">passwords</string>
<string name="help_context_password_leak_detection">leak_detection_android</string>
<string name="help_context_check_passwords">check_passwords</string>
<!-- TODO(peconn): Add help section. -->
<!-- <string name="help_context_suggestions">mobile_content_suggestions</string> -->
<!-- Our manage space activity. Default pre-KitKat to be nothing. --> <!-- Our manage space activity. Default pre-KitKat to be nothing. -->
<string name="manage_space_activity"></string> <string name="manage_space_activity"></string>
......
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.AppHooks; ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.feedback.ChromeFeedbackCollector; import org.chromium.chrome.browser.feedback.ChromeFeedbackCollector;
import org.chromium.chrome.browser.feedback.FeedFeedbackCollector; import org.chromium.chrome.browser.feedback.FeedFeedbackCollector;
import org.chromium.chrome.browser.feedback.FeedbackCollector; import org.chromium.chrome.browser.feedback.FeedbackCollector;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncher;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.embedder_support.util.UrlUtilitiesJni; import org.chromium.components.embedder_support.util.UrlUtilitiesJni;
...@@ -32,7 +33,7 @@ import javax.annotation.Nonnull; ...@@ -32,7 +33,7 @@ import javax.annotation.Nonnull;
/** /**
* Launches an activity that displays a relevant support page and has an option to provide feedback. * Launches an activity that displays a relevant support page and has an option to provide feedback.
*/ */
public class HelpAndFeedback { public class HelpAndFeedback implements HelpAndFeedbackLauncher {
protected static final String FALLBACK_SUPPORT_URL = protected static final String FALLBACK_SUPPORT_URL =
"https://support.google.com/chrome/topic/6069782"; "https://support.google.com/chrome/topic/6069782";
private static final String TAG = "HelpAndFeedback"; private static final String TAG = "HelpAndFeedback";
...@@ -87,6 +88,7 @@ public class HelpAndFeedback { ...@@ -87,6 +88,7 @@ public class HelpAndFeedback {
* @param profile the current profile. * @param profile the current profile.
* @param url the current URL. May be null. * @param url the current URL. May be null.
*/ */
@Override
public void show(final Activity activity, final String helpContext, Profile profile, public void show(final Activity activity, final String helpContext, Profile profile,
@Nullable String url) { @Nullable String url) {
RecordUserAction.record("MobileHelpAndFeedback"); RecordUserAction.record("MobileHelpAndFeedback");
...@@ -105,6 +107,7 @@ public class HelpAndFeedback { ...@@ -105,6 +107,7 @@ public class HelpAndFeedback {
* @param url the current URL. May be null. * @param url the current URL. May be null.
* @param categoryTag The category that this feedback report falls under. * @param categoryTag The category that this feedback report falls under.
*/ */
@Override
public void showFeedback(final Activity activity, Profile profile, @Nullable String url, public void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag) { @Nullable final String categoryTag) {
new ChromeFeedbackCollector(activity, categoryTag, null /* description */, new ChromeFeedbackCollector(activity, categoryTag, null /* description */,
...@@ -123,6 +126,7 @@ public class HelpAndFeedback { ...@@ -123,6 +126,7 @@ public class HelpAndFeedback {
* @param feedContext Feed specific parameters (url, title, etc) to include with feedback. * @param feedContext Feed specific parameters (url, title, etc) to include with feedback.
* @param feedbackContext The context that describes the current feature being used. * @param feedbackContext The context that describes the current feature being used.
*/ */
@Override
public void showFeedback(final Activity activity, Profile profile, @Nullable String url, public void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag, @Nullable final Map<String, String> feedContext, @Nullable final String categoryTag, @Nullable final Map<String, String> feedContext,
@Nullable final String feedbackContext) { @Nullable final String feedbackContext) {
......
...@@ -27,6 +27,7 @@ import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; ...@@ -27,6 +27,7 @@ import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeBaseAppCompatActivity; import org.chromium.chrome.browser.ChromeBaseAppCompatActivity;
import org.chromium.chrome.browser.feedback.FragmentHelpAndFeedbackLauncher;
import org.chromium.chrome.browser.help.HelpAndFeedback; import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer; import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.password_check.PasswordCheckComponentUiFactory; import org.chromium.chrome.browser.password_check.PasswordCheckComponentUiFactory;
...@@ -278,13 +279,22 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity ...@@ -278,13 +279,22 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity
((SiteSettingsPreferenceFragment) fragment) ((SiteSettingsPreferenceFragment) fragment)
.setSiteSettingsClient(new ChromeSiteSettingsClient( .setSiteSettingsClient(new ChromeSiteSettingsClient(
this, Profile.getLastUsedRegularProfile())); this, Profile.getLastUsedRegularProfile()));
} else if (fragment instanceof FragmentSettingsLauncher) { }
FragmentSettingsLauncher framentSettingsLauncher = (FragmentSettingsLauncher) fragment; if (fragment instanceof FragmentSettingsLauncher) {
framentSettingsLauncher.setSettingsLauncher(mSettingsLauncher); FragmentSettingsLauncher fragmentSettingsLauncher = (FragmentSettingsLauncher) fragment;
} else if (fragment instanceof SafetyCheckSettingsFragment) { fragmentSettingsLauncher.setSettingsLauncher(mSettingsLauncher);
}
if (fragment instanceof FragmentHelpAndFeedbackLauncher) {
FragmentHelpAndFeedbackLauncher fragmentHelpAndFeedbackLauncher =
(FragmentHelpAndFeedbackLauncher) fragment;
fragmentHelpAndFeedbackLauncher.setHelpAndFeedbackLauncher(
HelpAndFeedback.getInstance());
}
if (fragment instanceof SafetyCheckSettingsFragment) {
SafetyCheckCoordinator.create((SafetyCheckSettingsFragment) fragment, SafetyCheckCoordinator.create((SafetyCheckSettingsFragment) fragment,
new SafetyCheckUpdatesDelegateImpl(this), new SettingsLauncherImpl()); new SafetyCheckUpdatesDelegateImpl(this), new SettingsLauncherImpl());
} else if (fragment instanceof PasswordCheckFragmentView) { }
if (fragment instanceof PasswordCheckFragmentView) {
PasswordCheckComponentUiFactory.create((PasswordCheckFragmentView) fragment); PasswordCheckComponentUiFactory.create((PasswordCheckFragmentView) fragment);
} else if (fragment instanceof PasswordCheckEditFragmentView) { } else if (fragment instanceof PasswordCheckEditFragmentView) {
PasswordCheckEditFragmentView editFragment = (PasswordCheckEditFragmentView) fragment; PasswordCheckEditFragmentView editFragment = (PasswordCheckEditFragmentView) fragment;
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/rules.gni")
android_library("java") {
sources = [
"java/src/org/chromium/chrome/browser/feedback/FragmentHelpAndFeedbackLauncher.java",
"java/src/org/chromium/chrome/browser/feedback/HelpAndFeedbackLauncher.java",
]
deps = [
":java_resources",
"//chrome/browser/profiles/android:java",
"//third_party/android_deps:androidx_annotation_annotation_java",
]
resources_package = "org.chromium.chrome.browser.feedback"
}
android_resources("java_resources") {
sources = [ "java/res/values/strings.xml" ]
}
nyquist@chromium.org
twellington@chromium.org
# COMPONENT: UI>Browser>Mobile
# OS: Android
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<resources>
<!-- These constants should be in sync with the context names on go/mobilehelprecs.
If the context ID cannot be found, the default help page will be shown to the user.-->
<string name="help_context_autofill">android_autofill_ota</string>
<string name="help_context_new_tab">mobile_new_tab</string>
<string name="help_context_search_results">mobile_search_results</string>
<string name="help_context_webpage">mobile_webpage</string>
<string name="help_context_settings">mobile_settings</string>
<string name="help_context_incognito">mobile_incognito</string>
<string name="help_context_bookmarks">mobile_bookmarks</string>
<string name="help_context_history">mobile_history</string>
<string name="help_context_privacy">mobile_privacy</string>
<string name="help_context_general">mobile_general</string>
<string name="help_context_protected_content">protected_content</string>
<string name="help_context_data_reduction">reduce_data_usage</string>
<string name="help_context_incognito_learn_more">chrome_incognito</string>
<string name="help_context_sad_tab">mobile_awsnap</string>
<string name="help_context_clear_browsing_data">clear_browsing_data</string>
<string name="help_context_change_sync_passphrase">change_sync_passphrase</string>
<string name="help_context_sync_and_services">syncgoogleservices</string>
<string name="help_context_passwords">passwords</string>
<string name="help_context_password_leak_detection">leak_detection_android</string>
<string name="help_context_check_passwords">check_passwords</string>
<!-- TODO(peconn): Add help section. -->
<!-- <string name="help_context_suggestions">mobile_content_suggestions</string> -->
</resources>
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.feedback;
/**
* Interface for injecting HelpAndFeedbackLauncher to a fragment. It is useful for modularized
* fragments that need access to HelpAndFeedback.
*/
public interface FragmentHelpAndFeedbackLauncher {
/**
* Set an instance of HelpAndFeedbackLauncher in a fragment.
*
* @param helpAndFeedbackLauncher The HelpAndFeedbackLauncher that is injected.
*/
void setHelpAndFeedbackLauncher(HelpAndFeedbackLauncher helpAndFeedbackLauncher);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.feedback;
import android.app.Activity;
import androidx.annotation.Nullable;
import org.chromium.chrome.browser.profiles.Profile;
import java.util.Map;
/**
* Interface for launching a help and feedback page.
*/
public interface HelpAndFeedbackLauncher {
/**
* Starts an activity showing a help page for the specified context ID.
*
* @param activity The activity to use for starting the help activity and to take a
* screenshot of.
* @param helpContext One of the CONTEXT_* constants. This should describe the user's current
* context and will be used to show a more relevant help page.
* @param profile the current profile.
* @param url the current URL. May be null.
*/
void show(final Activity activity, String helpContext, Profile profile, @Nullable String url);
/**
* Starts an activity prompting the user to enter feedback.
*
* @param activity The activity to use for starting the feedback activity and to take a
* screenshot of.
* @param profile the current profile.
* @param url the current URL. May be null.
* @param categoryTag The category that this feedback report falls under.
*/
void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag);
/**
* Starts an activity prompting the user to enter feedback for the interest feed.
*
* @param activity The activity to use for starting the feedback activity and to take a
* screenshot of.
* @param profile the current profile.
* @param categoryTag The category that this feedback report falls under.
* @param feedContext Feed specific parameters (url, title, etc) to include with feedback.
* @param feedbackContext The context that describes the current feature being used.
*/
void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag, @Nullable final Map<String, String> feedContext,
@Nullable final String feedbackContext);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment