Commit 8098bca2 authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

Remove HelpAndFeedback.

The plan for this two-sided patch is:
1) Add the new class under feedback/ and AppHooks method upstream with
no reference.
2) Extend the new class downstream and add the new AppHooks method.
3) Update upstream references to point to the new AppHooks method.
4) Cleanup in downstream repository.
5) Cleanup in upstream repository.

1) was done in https://crrev.com/c/2364581.
2) was done in https://crrev.com/i/3227761.
3) was done in https://crrev.com/c/2414779.
4) was done in https://crrev.com/i/3274398.
5) is done in this CL.

Note that the change in SigninUtils was a miss from step 3). Ideally
all references to HelpAndFeedback should be removed in 3), but there is
one left in SigninUtils. The consequence is that after step 4) is landed,
this reference can only be pointed to the upstream implementation.

Bug: 1117343
Change-Id: Iafe729908040925ab5a6c7fb4caf61194a5653e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415383Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815338}
parent 80fcc0d2
......@@ -771,7 +771,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/gsa/GSAHelper.java",
"java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java",
"java/src/org/chromium/chrome/browser/gsa/GSAState.java",
"java/src/org/chromium/chrome/browser/help/HelpAndFeedback.java",
"java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java",
"java/src/org/chromium/chrome/browser/history/HistoryActivity.java",
"java/src/org/chromium/chrome/browser/history/HistoryAdapter.java",
......
......@@ -23,7 +23,6 @@ import org.chromium.chrome.browser.feedback.FeedbackReporter;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncher;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncherImpl;
import org.chromium.chrome.browser.gsa.GSAHelper;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.historyreport.AppIndexingReporter;
import org.chromium.chrome.browser.init.ProcessInitializationHandler;
import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
......@@ -183,14 +182,6 @@ public abstract class AppHooks {
return new HelpAndFeedbackLauncherImpl();
}
/**
* TODO(crbug.com/1117343): Remove this method when downstream dependency is removed.
* Returns a new instance of HelpAndFeedback.
*/
public HelpAndFeedback createHelpAndFeedback() {
return new HelpAndFeedback();
}
public InstantAppsHandler createInstantAppsHandler() {
return new InstantAppsHandler();
}
......
// Copyright 2015 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.help;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Browser;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.feedback.ChromeFeedbackCollector;
import org.chromium.chrome.browser.feedback.FeedFeedbackCollector;
import org.chromium.chrome.browser.feedback.FeedbackCollector;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncher;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.embedder_support.util.UrlUtilitiesJni;
import java.util.Map;
import javax.annotation.Nonnull;
/**
* TODO(crbug.com/1117343): Remove this class when downstream dependency is removed.
* Launches an activity that displays a relevant support page and has an option to provide feedback.
*/
public class HelpAndFeedback implements HelpAndFeedbackLauncher {
protected static final String FALLBACK_SUPPORT_URL =
"https://support.google.com/chrome/topic/6069782";
private static final String TAG = "HelpAndFeedback";
private static HelpAndFeedback sInstance;
/**
* Returns the singleton instance of HelpAndFeedback, creating it if needed.
*/
public static HelpAndFeedback getInstance() {
ThreadUtils.assertOnUiThread();
if (sInstance == null) {
sInstance = AppHooks.get().createHelpAndFeedback();
}
return sInstance;
}
/**
* 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 collector the {@link FeedbackCollector} to use for extra data. Must not be null.
*/
protected void show(
Activity activity, String helpContext, @Nonnull FeedbackCollector collector) {
Log.d(TAG, "Feedback data: " + collector.getBundle());
launchFallbackSupportUri(activity);
}
/**
* 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 collector the {@link FeedbackCollector} to use for extra data. Must not be null.
*/
protected void showFeedback(Activity activity, @Nonnull FeedbackCollector collector) {
Log.d(TAG, "Feedback data: " + collector.getBundle());
launchFallbackSupportUri(activity);
}
/**
* 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.
*/
@Override
public void show(final Activity activity, final String helpContext, Profile profile,
@Nullable String url) {
RecordUserAction.record("MobileHelpAndFeedback");
new ChromeFeedbackCollector(activity, null /* categoryTag */, null /* description */,
true /* takeScreenshot */,
new ChromeFeedbackCollector.InitParams(profile, url, helpContext),
collector -> show(activity, helpContext, collector));
}
/**
* 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.
*/
@Override
public void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag) {
new ChromeFeedbackCollector(activity, categoryTag, null /* description */,
true /* takeScreenshot */,
new ChromeFeedbackCollector.InitParams(profile, url, null),
collector -> showFeedback(activity, collector));
}
/**
* 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.
*/
@Override
public void showFeedback(final Activity activity, Profile profile, @Nullable String url,
@Nullable final String categoryTag, @Nullable final Map<String, String> feedContext,
@Nullable final String feedbackContext) {
new FeedFeedbackCollector(activity, categoryTag, null /* description */, feedbackContext,
true /* takeScreenshot */,
new FeedFeedbackCollector.InitParams(profile, url, feedContext),
collector -> showFeedback(activity, collector));
}
/**
* Get help context ID from URL.
*
* @param url The URL to be checked.
* @param isIncognito Whether we are in incognito mode or not.
* @return Help context ID that matches the URL and incognito mode.
*/
public static String getHelpContextIdFromUrl(Context context, String url, boolean isIncognito) {
if (TextUtils.isEmpty(url)) {
return context.getString(R.string.help_context_general);
} else if (url.startsWith(UrlConstants.BOOKMARKS_URL)) {
return context.getString(R.string.help_context_bookmarks);
} else if (url.equals(UrlConstants.HISTORY_URL)) {
return context.getString(R.string.help_context_history);
}
// Note: For www.google.com the following function returns false.
else if (UrlUtilitiesJni.get().isGoogleSearchUrl(url)) {
return context.getString(R.string.help_context_search_results);
}
// For incognito NTP, we want to show incognito help.
else if (isIncognito) {
return context.getString(R.string.help_context_incognito);
} else if (url.equals(UrlConstants.NTP_URL)) {
return context.getString(R.string.help_context_new_tab);
}
return context.getString(R.string.help_context_webpage);
}
protected static void launchFallbackSupportUri(Context context) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(FALLBACK_SUPPORT_URL));
// Let Chrome know that this intent is from Chrome, so that it does not close the app when
// the user presses 'back' button.
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
intent.setPackage(context.getPackageName());
context.startActivity(intent);
}
}
......@@ -19,7 +19,7 @@ import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncherImpl;
import org.chromium.chrome.browser.incognito.interstitial.IncognitoInterstitialDelegate;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.account_picker.AccountConsistencyPromoAction;
......@@ -107,7 +107,7 @@ public class SigninUtils {
TabCreator incognitoTabCreator = activity.getTabCreator(/*incognito=*/true);
IncognitoInterstitialDelegate incognitoInterstitialDelegate =
new IncognitoInterstitialDelegate(activity, regularTabModel, incognitoTabCreator,
HelpAndFeedback.getInstance());
HelpAndFeedbackLauncherImpl.getInstance());
AccountPickerBottomSheetCoordinator coordinator = new AccountPickerBottomSheetCoordinator(
windowAndroid.getContext().get(), BottomSheetControllerProvider.from(windowAndroid),
......
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