Commit d9487e5e authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

[WebLayer] Move Site Settings WebappRegistry usage behind SiteSettingsClient

This CL moves the recently added WebappRegistry usage in Clank's
Site Settings UI behind the SiteSettingsClient interface, which removes
the //chrome dependency so site_settings can be componentized.

Bug: 1058597
Change-Id: Ib9b8b0fc2ca43eaf15cbc86e9b5680745d007b19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2158317Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761062}
parent 4b483fc6
......@@ -17,8 +17,11 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
import org.chromium.chrome.browser.ui.favicon.FaviconHelper;
import org.chromium.chrome.browser.ui.favicon.FaviconHelper.FaviconImageCallback;
import org.chromium.chrome.browser.webapps.WebappRegistry;
import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
import java.util.Set;
/**
* A SiteSettingsClient instance that contains Chrome-specific Site Settings logic.
*/
......@@ -112,4 +115,11 @@ public class ChromeSiteSettingsClient implements SiteSettingsClient {
}
return mChromeSiteSettingsPrefClient;
}
@Override
public boolean originHasInstalledWebapp(String origin) {
WebappRegistry registry = WebappRegistry.getInstance();
Set<String> originsWithApps = registry.getOriginsWithInstalledApp();
return originsWithApps.contains(origin);
}
}
......@@ -28,7 +28,6 @@ import org.chromium.base.Callback;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.webapps.WebappRegistry;
import org.chromium.components.browser_ui.settings.ChromeImageViewPreference;
import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils;
import org.chromium.components.browser_ui.settings.SettingsUtils;
......@@ -371,9 +370,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
private void setUpClearDataPreference(ClearWebsiteStorage preference) {
long usage = mSite.getTotalUsage();
if (usage > 0) {
WebappRegistry registry = WebappRegistry.getInstance();
Set<String> originsWithApps = registry.getOriginsWithInstalledApp();
boolean appFound = originsWithApps.contains(mSite.getAddress().getOrigin());
boolean appFound = getSiteSettingsClient().originHasInstalledWebapp(
mSite.getAddress().getOrigin());
Context context = preference.getContext();
preference.setTitle(
String.format(context.getString(R.string.origin_settings_storage_usage_brief),
......
......@@ -65,4 +65,9 @@ public interface SiteSettingsClient {
*/
// TODO(crbug.com/1071603): Remove this once PrefServiceBridge is componentized.
SiteSettingsPrefClient getSiteSettingsPrefClient();
/**
* @return True if a webapp is installed for the site at the given origin.
*/
boolean originHasInstalledWebapp(String origin);
}
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