Commit 799b53ea authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

|createImagefecter| function clean-up for autofill assistant.

This CL replaces deprecated |createImageFecther| function by passing
profile to the function. Since assistant is only available in regular
mode, |AutofillAssistantUiController#getProfile| returns
|Profile#getLastUsedRegularProfile|. Then, the caller classes creates
image fecther using |AutofillAssistantUiController#getProfile|.
Previous discussions are in crrev.com/c/2276422.

Bug: 1041781, 1083923, 1075562
Change-Id: I339c4e69f01de8a855a6353614adc26c1cac6439
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2301769
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789444}
parent 74b96bc1
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantChip.Typ ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantChip.Typ
import org.chromium.chrome.browser.autofill_assistant.header.AssistantHeaderModel; import org.chromium.chrome.browser.autofill_assistant.header.AssistantHeaderModel;
import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason; import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason;
import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.ui.TabObscuringHandler; import org.chromium.chrome.browser.ui.TabObscuringHandler;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarController; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarController;
...@@ -44,7 +45,7 @@ import java.util.Set; ...@@ -44,7 +45,7 @@ import java.util.Set;
@JNINamespace("autofill_assistant") @JNINamespace("autofill_assistant")
// TODO(crbug.com/806868): This class should be removed once all logic is in native side and the // TODO(crbug.com/806868): This class should be removed once all logic is in native side and the
// model is directly modified by the native AssistantMediator. // model is directly modified by the native AssistantMediator.
class AutofillAssistantUiController { public class AutofillAssistantUiController {
private static Set<ChromeActivity> sActiveChromeActivities; private static Set<ChromeActivity> sActiveChromeActivities;
private long mNativeUiController; private long mNativeUiController;
...@@ -54,6 +55,19 @@ class AutofillAssistantUiController { ...@@ -54,6 +55,19 @@ class AutofillAssistantUiController {
private WebContents mWebContents; private WebContents mWebContents;
private SnackbarController mSnackbarController; private SnackbarController mSnackbarController;
/**
* Getter for the current profile while assistant is running. Since autofill assistant is only
* available in regular mode and there is only one regular profile in android, this method
* returns {@link Profile#getLastUsedRegularProfile()}.
*
* TODO(b/161519639): Return current profile to support multi profiles, instead of returning
* always regular profile. This could be achieve by retrieving profile from native and using it
* where the profile is needed on Java side.
* @return The current regular profile.
*/
public static Profile getProfile() {
return Profile.getLastUsedRegularProfile();
}
/** /**
* Finds an activity to which a AA UI can be added. * Finds an activity to which a AA UI can be added.
* *
......
...@@ -11,6 +11,7 @@ import android.view.View; ...@@ -11,6 +11,7 @@ import android.view.View;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiController;
import org.chromium.chrome.browser.autofill_assistant.details.AssistantDetailsViewBinder.ViewHolder; import org.chromium.chrome.browser.autofill_assistant.details.AssistantDetailsViewBinder.ViewHolder;
import org.chromium.chrome.browser.image_fetcher.ImageFetcher; import org.chromium.chrome.browser.image_fetcher.ImageFetcher;
import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig; import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig;
...@@ -26,7 +27,8 @@ public class AssistantDetailsCoordinator { ...@@ -26,7 +27,8 @@ public class AssistantDetailsCoordinator {
public AssistantDetailsCoordinator(Context context, AssistantDetailsModel model) { public AssistantDetailsCoordinator(Context context, AssistantDetailsModel model) {
this(context, model, this(context, model,
ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY)); ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY,
AutofillAssistantUiController.getProfile()));
} }
@VisibleForTesting @VisibleForTesting
......
...@@ -19,6 +19,7 @@ import org.chromium.base.Callback; ...@@ -19,6 +19,7 @@ import org.chromium.base.Callback;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiController;
import org.chromium.chrome.browser.autofill_assistant.drawable.AssistantDrawableIcon; import org.chromium.chrome.browser.autofill_assistant.drawable.AssistantDrawableIcon;
import org.chromium.chrome.browser.image_fetcher.ImageFetcher; import org.chromium.chrome.browser.image_fetcher.ImageFetcher;
import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig; import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig;
...@@ -103,8 +104,8 @@ public abstract class AssistantDrawable { ...@@ -103,8 +104,8 @@ public abstract class AssistantDrawable {
} }
private static class AssistantBitmapDrawable extends AssistantDrawable { private static class AssistantBitmapDrawable extends AssistantDrawable {
private final ImageFetcher mImageFetcher = private final ImageFetcher mImageFetcher = ImageFetcherFactory.createImageFetcher(
ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY); ImageFetcherConfig.DISK_CACHE_ONLY, AutofillAssistantUiController.getProfile());
private final String mUrl; private final String mUrl;
private final int mWidthInPixels; private final int mWidthInPixels;
private final int mHeightInPixels; private final int mHeightInPixels;
......
...@@ -9,6 +9,7 @@ import android.view.LayoutInflater; ...@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiController;
import org.chromium.chrome.browser.autofill_assistant.infobox.AssistantInfoBoxViewBinder.ViewHolder; import org.chromium.chrome.browser.autofill_assistant.infobox.AssistantInfoBoxViewBinder.ViewHolder;
import org.chromium.chrome.browser.image_fetcher.ImageFetcher; import org.chromium.chrome.browser.image_fetcher.ImageFetcher;
import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig; import org.chromium.chrome.browser.image_fetcher.ImageFetcherConfig;
...@@ -24,7 +25,8 @@ public class AssistantInfoBoxCoordinator { ...@@ -24,7 +25,8 @@ public class AssistantInfoBoxCoordinator {
public AssistantInfoBoxCoordinator(Context context, AssistantInfoBoxModel model) { public AssistantInfoBoxCoordinator(Context context, AssistantInfoBoxModel model) {
this(context, model, this(context, model,
ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY)); ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY,
AutofillAssistantUiController.getProfile()));
} }
/** Used for testing to inject an image fetcher. */ /** Used for testing to inject an image fetcher. */
......
...@@ -10,6 +10,7 @@ import android.graphics.RectF; ...@@ -10,6 +10,7 @@ import android.graphics.RectF;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiController;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider; import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.compositor.CompositorViewHolder; import org.chromium.chrome.browser.compositor.CompositorViewHolder;
import org.chromium.chrome.browser.image_fetcher.ImageFetcher; import org.chromium.chrome.browser.image_fetcher.ImageFetcher;
...@@ -38,7 +39,8 @@ public class AssistantOverlayCoordinator { ...@@ -38,7 +39,8 @@ public class AssistantOverlayCoordinator {
BrowserControlsStateProvider browserControls, CompositorViewHolder compositorViewHolder, BrowserControlsStateProvider browserControls, CompositorViewHolder compositorViewHolder,
ScrimView scrim, AssistantOverlayModel model) { ScrimView scrim, AssistantOverlayModel model) {
this(context, browserControls, compositorViewHolder, scrim, model, this(context, browserControls, compositorViewHolder, scrim, model,
ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY)); ImageFetcherFactory.createImageFetcher(ImageFetcherConfig.DISK_CACHE_ONLY,
AutofillAssistantUiController.getProfile()));
} }
public AssistantOverlayCoordinator(Context context, public AssistantOverlayCoordinator(Context context,
......
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