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

[WebLayer] Fix 'All sites' and 'Storage' Site Settings categories

crrev.com/c/2252560 separated 'All sites' and 'Storage' settings
categories into their own Fragment, which broke them in WebLayer. This
CL adds support for the new AllSiteSettings Fragment. Note that the new
Intent being created in this CL does get passed to the client in order
for it to start the new Activity, but its contents are transparent to
the client so this is backwards compatible with older client versions.

I'll add tests for every settings page in a followup that should catch
issues like this in the future.

Bug: 1122705
Change-Id: I94f69d1cebfbd19add42e936afccc0a5f2512aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2380575Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802422}
parent 5e89dc34
...@@ -24,6 +24,7 @@ import androidx.preference.Preference; ...@@ -24,6 +24,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import org.chromium.components.browser_ui.settings.SettingsUtils; import org.chromium.components.browser_ui.settings.SettingsUtils;
import org.chromium.components.browser_ui.site_settings.AllSiteSettings;
import org.chromium.components.browser_ui.site_settings.SingleCategorySettings; import org.chromium.components.browser_ui.site_settings.SingleCategorySettings;
import org.chromium.components.browser_ui.site_settings.SingleWebsiteSettings; import org.chromium.components.browser_ui.site_settings.SingleWebsiteSettings;
import org.chromium.components.browser_ui.site_settings.SiteSettings; import org.chromium.components.browser_ui.site_settings.SiteSettings;
...@@ -150,6 +151,11 @@ public class SiteSettingsFragmentImpl extends RemoteFragmentImpl { ...@@ -150,6 +151,11 @@ public class SiteSettingsFragmentImpl extends RemoteFragmentImpl {
mFragmentImpl.getEmbedderContext(), mFragmentImpl.getProfile().getName(), mFragmentImpl.getEmbedderContext(), mFragmentImpl.getProfile().getName(),
newFragmentArgs.getString(SingleCategorySettings.EXTRA_CATEGORY), newFragmentArgs.getString(SingleCategorySettings.EXTRA_CATEGORY),
newFragmentArgs.getString(SingleCategorySettings.EXTRA_TITLE)); newFragmentArgs.getString(SingleCategorySettings.EXTRA_TITLE));
} else if (newFragmentClassName.equals(AllSiteSettings.class.getName())) {
intent = SiteSettingsIntentHelper.createIntentForAllSites(
mFragmentImpl.getEmbedderContext(), mFragmentImpl.getProfile().getName(),
newFragmentArgs.getString(AllSiteSettings.EXTRA_CATEGORY),
newFragmentArgs.getString(AllSiteSettings.EXTRA_TITLE));
} else if (newFragmentClassName.equals(SingleWebsiteSettings.class.getName())) { } else if (newFragmentClassName.equals(SingleWebsiteSettings.class.getName())) {
WebsiteAddress address; WebsiteAddress address;
if (newFragmentArgs.containsKey(SingleWebsiteSettings.EXTRA_SITE)) { if (newFragmentArgs.containsKey(SingleWebsiteSettings.EXTRA_SITE)) {
...@@ -217,6 +223,14 @@ public class SiteSettingsFragmentImpl extends RemoteFragmentImpl { ...@@ -217,6 +223,14 @@ public class SiteSettingsFragmentImpl extends RemoteFragmentImpl {
// implementation fragments expect. // implementation fragments expect.
Bundle fragmentArgs = intentExtras.getBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS); Bundle fragmentArgs = intentExtras.getBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS);
switch (intentExtras.getString(SiteSettingsFragmentArgs.FRAGMENT_NAME)) { switch (intentExtras.getString(SiteSettingsFragmentArgs.FRAGMENT_NAME)) {
case SiteSettingsFragmentArgs.ALL_SITES:
mFragmentClass = AllSiteSettings.class;
mFragmentArguments = new Bundle();
mFragmentArguments.putString(AllSiteSettings.EXTRA_TITLE,
fragmentArgs.getString(SiteSettingsFragmentArgs.ALL_SITES_TITLE));
mFragmentArguments.putString(AllSiteSettings.EXTRA_CATEGORY,
fragmentArgs.getString(SiteSettingsFragmentArgs.ALL_SITES_TYPE));
break;
case SiteSettingsFragmentArgs.CATEGORY_LIST: case SiteSettingsFragmentArgs.CATEGORY_LIST:
mFragmentClass = SiteSettings.class; mFragmentClass = SiteSettings.class;
mFragmentArguments = null; mFragmentArguments = null;
......
...@@ -14,6 +14,7 @@ public interface SiteSettingsFragmentArgs { ...@@ -14,6 +14,7 @@ public interface SiteSettingsFragmentArgs {
String FRAGMENT_ARGUMENTS = "fragment_arguments"; String FRAGMENT_ARGUMENTS = "fragment_arguments";
// FRAGMENT_NAME values // FRAGMENT_NAME values
String ALL_SITES = "all_sites";
String CATEGORY_LIST = "category_list"; String CATEGORY_LIST = "category_list";
String SINGLE_CATEGORY = "single_category"; String SINGLE_CATEGORY = "single_category";
String SINGLE_WEBSITE = "single_website"; String SINGLE_WEBSITE = "single_website";
...@@ -24,4 +25,8 @@ public interface SiteSettingsFragmentArgs { ...@@ -24,4 +25,8 @@ public interface SiteSettingsFragmentArgs {
// SINGLE_CATEGORY argument names // SINGLE_CATEGORY argument names
String SINGLE_CATEGORY_TITLE = "title"; String SINGLE_CATEGORY_TITLE = "title";
String SINGLE_CATEGORY_TYPE = "type"; String SINGLE_CATEGORY_TYPE = "type";
// ALL_SITES argument names
String ALL_SITES_TITLE = "title";
String ALL_SITES_TYPE = "type";
} }
...@@ -50,6 +50,21 @@ public class SiteSettingsIntentHelper { ...@@ -50,6 +50,21 @@ public class SiteSettingsIntentHelper {
return createIntentWithExtras(context, extras); return createIntentWithExtras(context, extras);
} }
/** Creates an Intent that launches the all sites settings UI. */
public static Intent createIntentForAllSites(
Context context, String profileName, String type, String title) {
Bundle extras = new Bundle();
extras.putString(SiteSettingsFragmentArgs.PROFILE_NAME, profileName);
extras.putString(
SiteSettingsFragmentArgs.FRAGMENT_NAME, SiteSettingsFragmentArgs.ALL_SITES);
Bundle fragmentArgs = new Bundle();
fragmentArgs.putString(SiteSettingsFragmentArgs.ALL_SITES_TITLE, title);
fragmentArgs.putString(SiteSettingsFragmentArgs.ALL_SITES_TYPE, type);
extras.putBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS, fragmentArgs);
return createIntentWithExtras(context, extras);
}
private static Intent createIntentWithExtras(Context context, Bundle extras) { private static Intent createIntentWithExtras(Context context, Bundle extras) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClassName(context, SiteSettingsFragmentArgs.ACTIVITY_CLASS_NAME); intent.setClassName(context, SiteSettingsFragmentArgs.ACTIVITY_CLASS_NAME);
......
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