Commit f50de5ce authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Android] Clean up how arguments are passed to Preference fragments

1. Revised how Preferences activity gets argument bundle to pass to
   a subpage fragment. PreferencesLauncher methods got Bundle argument,
   so EXTRA_SHOW_FRAGMENT and EXTRA_SHOW_FRAGMENT_ARGUMENTS are
   package-private now.
2. The type of PreferencesLauncher.launchSettingsPage fragment parameter
   is changed to Class<? extends Fragment> to get compile-time checks.
3. A bunch of callers are changed to use launchSettingsPage instead of
   createIntentForSettingsPage followed by startActivity.
4. DataReductionPreferences and PasswordEntryEditor now get their
   parameters using fragment arguments instead of intent extras.

Bug: None
Change-Id: Ic0ae700149d721ab9194ed36c311c8f8b47bea1e
Reviewed-on: https://chromium-review.googlesource.com/c/1323071Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606404}
parent 859f6471
...@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.lifecycle.Destroyable; ...@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.browser.lifecycle.StartStopWithNativeObserver; import org.chromium.chrome.browser.lifecycle.StartStopWithNativeObserver;
import org.chromium.chrome.browser.notifications.NotificationBuilderFactory; import org.chromium.chrome.browser.notifications.NotificationBuilderFactory;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
...@@ -188,9 +187,8 @@ public class PersistentNotificationController implements StartStopWithNativeObse ...@@ -188,9 +187,8 @@ public class PersistentNotificationController implements StartStopWithNativeObse
} }
private PendingIntent makeManageDataIntent() { private PendingIntent makeManageDataIntent() {
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(mAppContext,
mAppContext, SingleWebsitePreferences.class.getName()); SingleWebsitePreferences.class.getName(),
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS,
SingleWebsitePreferences.createFragmentArgsForSite(mOrigin.toString())); SingleWebsitePreferences.createFragmentArgsForSite(mOrigin.toString()));
return PendingIntent.getActivity(mAppContext, 0, settingsIntent, FLAG_UPDATE_CURRENT); return PendingIntent.getActivity(mAppContext, 0, settingsIntent, FLAG_UPDATE_CURRENT);
} }
......
...@@ -397,8 +397,8 @@ public class ContextualSearchPromoControl extends OverlayPanelInflater { ...@@ -397,8 +397,8 @@ public class ContextualSearchPromoControl extends OverlayPanelInflater {
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@Override @Override
public void run() { public void run() {
PreferencesLauncher.launchSettingsPage(getContext(), PreferencesLauncher.launchSettingsPage(
ContextualSearchPreferenceFragment.class.getName()); getContext(), ContextualSearchPreferenceFragment.class);
} }
}); });
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.contextual_suggestions; package org.chromium.chrome.browser.contextual_suggestions;
import android.content.Intent;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
...@@ -20,7 +19,6 @@ import org.chromium.chrome.browser.suggestions.SuggestionsNavigationDelegate; ...@@ -20,7 +19,6 @@ import org.chromium.chrome.browser.suggestions.SuggestionsNavigationDelegate;
import org.chromium.chrome.browser.suggestions.SuggestionsUiDelegateImpl; import org.chromium.chrome.browser.suggestions.SuggestionsUiDelegateImpl;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver;
...@@ -170,9 +168,7 @@ public class ContextualSuggestionsCoordinator implements Destroyable { ...@@ -170,9 +168,7 @@ public class ContextualSuggestionsCoordinator implements Destroyable {
/** Show the settings page for contextual suggestions. */ /** Show the settings page for contextual suggestions. */
void showSettings() { void showSettings() {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(mActivity, ContextualSuggestionsPreference.class);
mActivity, ContextualSuggestionsPreference.class.getName());
IntentUtils.safeStartActivity(mActivity, intent);
} }
/** Show the feedback page. */ /** Show the feedback page. */
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.download.home; package org.chromium.chrome.browser.download.home;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -156,9 +155,7 @@ class DownloadManagerCoordinatorImpl ...@@ -156,9 +155,7 @@ class DownloadManagerCoordinatorImpl
@Override @Override
public void openSettings() { public void openSettings() {
RecordUserAction.record("Android.DownloadManager.Settings"); RecordUserAction.record("Android.DownloadManager.Settings");
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(mActivity, DownloadPreferences.class);
mActivity, DownloadPreferences.class.getName());
mActivity.startActivity(intent);
} }
private void notifyFilterChanged(@FilterType int filter) { private void notifyFilterChanged(@FilterType int filter) {
......
...@@ -385,9 +385,7 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat ...@@ -385,9 +385,7 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
mToolbar.showSearchView(); mToolbar.showSearchView();
return true; return true;
} else if (item.getItemId() == R.id.settings_menu_id) { } else if (item.getItemId() == R.id.settings_menu_id) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(mActivity, DownloadPreferences.class);
mActivity, DownloadPreferences.class.getName());
mActivity.startActivity(intent);
return true; return true;
} }
return false; return false;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.firstrun; package org.chromium.chrome.browser.firstrun;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.text.TextUtils; import android.text.TextUtils;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
...@@ -110,13 +111,13 @@ public final class FirstRunSignInProcessor { ...@@ -110,13 +111,13 @@ public final class FirstRunSignInProcessor {
* Opens sign in settings as requested in the FRE sign-in dialog. * Opens sign in settings as requested in the FRE sign-in dialog.
*/ */
private static void openSignInSettings(Activity activity) { private static void openSignInSettings(Activity activity) {
final String fragmentName; final Class<? extends Fragment> fragment;
if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) {
fragmentName = SyncAndServicesPreferences.class.getName(); fragment = SyncAndServicesPreferences.class;
} else { } else {
fragmentName = AccountManagementFragment.class.getName(); fragment = AccountManagementFragment.class;
} }
PreferencesLauncher.launchSettingsPage(activity, fragmentName); PreferencesLauncher.launchSettingsPage(activity, fragment);
} }
/** /**
......
...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.preferences.Pref; ...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.preferences.PrefChangeRegistrar; import org.chromium.chrome.browser.preferences.PrefChangeRegistrar;
import org.chromium.chrome.browser.preferences.PrefChangeRegistrar.PrefObserver; import org.chromium.chrome.browser.preferences.PrefChangeRegistrar.PrefObserver;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.privacy.ClearBrowsingDataTabsFragment;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver;
...@@ -356,8 +357,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ...@@ -356,8 +357,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
*/ */
public void openClearBrowsingDataPreference() { public void openClearBrowsingDataPreference() {
recordUserAction("ClearBrowsingData"); recordUserAction("ClearBrowsingData");
Intent intent = PreferencesLauncher.createIntentForClearBrowsingDataPage(mActivity); PreferencesLauncher.launchSettingsPage(mActivity, ClearBrowsingDataTabsFragment.class);
IntentUtils.safeStartActivity(mActivity, intent);
} }
@Override @Override
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.infobar;
import android.content.Intent; import android.os.Bundle;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ResourceId; import org.chromium.chrome.browser.ResourceId;
...@@ -31,9 +31,9 @@ public class PreviewsLitePageInfoBar extends ConfirmInfoBar { ...@@ -31,9 +31,9 @@ public class PreviewsLitePageInfoBar extends ConfirmInfoBar {
public void onLinkClicked() { public void onLinkClicked() {
super.onLinkClicked(); super.onLinkClicked();
final Intent intent = PreferencesLauncher.createIntentForSettingsPage( Bundle fragmentArgs = new Bundle();
getContext(), DataReductionPreferences.class.getName()); fragmentArgs.putBoolean(FROM_INFOBAR, true);
intent.putExtra(FROM_INFOBAR, true); PreferencesLauncher.launchSettingsPage(
getContext().startActivity(intent); getContext(), DataReductionPreferences.class, fragmentArgs);
} }
} }
...@@ -5,16 +5,12 @@ ...@@ -5,16 +5,12 @@
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.infobar;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ResourceId; import org.chromium.chrome.browser.ResourceId;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
import org.chromium.chrome.browser.util.IntentUtils;
/** /**
* An infobar to disclose to the user that the default search engine has geolocation access by * An infobar to disclose to the user that the default search engine has geolocation access by
...@@ -60,10 +56,7 @@ public class SearchGeolocationDisclosureInfoBar extends InfoBar { ...@@ -60,10 +56,7 @@ public class SearchGeolocationDisclosureInfoBar extends InfoBar {
@CalledByNative @CalledByNative
private static void showSettingsPage(String searchUrl) { private static void showSettingsPage(String searchUrl) {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(context, SingleWebsitePreferences.class,
context, SingleWebsitePreferences.class.getName()); SingleWebsitePreferences.createFragmentArgsForSite(searchUrl));
Bundle fragmentArgs = SingleWebsitePreferences.createFragmentArgsForSite(searchUrl);
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
IntentUtils.safeStartActivity(context, settingsIntent);
} }
} }
...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.locale; ...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.locale;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.StrictMode; import android.os.StrictMode;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
...@@ -95,9 +94,7 @@ public class LocaleManager { ...@@ -95,9 +94,7 @@ public class LocaleManager {
@Override @Override
public void onAction(Object actionData) { public void onAction(Object actionData) {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
Intent intent = PreferencesLauncher.createIntentForSettingsPage(context, PreferencesLauncher.launchSettingsPage(context, SearchEnginePreference.class);
SearchEnginePreference.class.getName());
context.startActivity(intent);
} }
}; };
......
...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.locale; ...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.locale;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -54,9 +53,7 @@ public class SogouPromoDialog extends PromoDialog { ...@@ -54,9 +53,7 @@ public class SogouPromoDialog extends PromoDialog {
private final LocaleManager mLocaleManager; private final LocaleManager mLocaleManager;
private final ClickableSpan mSpan = new NoUnderlineClickableSpan((widget) -> { private final ClickableSpan mSpan = new NoUnderlineClickableSpan((widget) -> {
mChoice = UserChoice.SETTINGS; mChoice = UserChoice.SETTINGS;
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(getContext(), SearchEnginePreference.class);
getContext(), SearchEnginePreference.class.getName());
getContext().startActivity(intent);
dismiss(); dismiss();
}); });
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.notifications; package org.chromium.chrome.browser.notifications;
import android.app.Fragment;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.RemoteInput; import android.app.RemoteInput;
...@@ -33,7 +34,6 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer; ...@@ -33,7 +34,6 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager; import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager;
import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences; import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences;
import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
...@@ -264,11 +264,9 @@ public class NotificationPlatformBridge { ...@@ -264,11 +264,9 @@ public class NotificationPlatformBridge {
String origin = getOriginFromIntent(incomingIntent); String origin = getOriginFromIntent(incomingIntent);
boolean launchSingleWebsitePreferences = origin != null; boolean launchSingleWebsitePreferences = origin != null;
String fragmentName = launchSingleWebsitePreferences Class<? extends Fragment> fragment = launchSingleWebsitePreferences
? SingleWebsitePreferences.class.getName() ? SingleWebsitePreferences.class
: SingleCategoryPreferences.class.getName(); : SingleCategoryPreferences.class;
Intent preferencesIntent =
PreferencesLauncher.createIntentForSettingsPage(applicationContext, fragmentName);
Bundle fragmentArguments; Bundle fragmentArguments;
if (launchSingleWebsitePreferences) { if (launchSingleWebsitePreferences) {
...@@ -286,9 +284,8 @@ public class NotificationPlatformBridge { ...@@ -286,9 +284,8 @@ public class NotificationPlatformBridge {
applicationContext.getResources().getString( applicationContext.getResources().getString(
R.string.push_notifications_permission_title)); R.string.push_notifications_permission_title));
} }
preferencesIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArguments);
applicationContext.startActivity(preferencesIntent); PreferencesLauncher.launchSettingsPage(applicationContext, fragment, fragmentArguments);
} }
/** /**
...@@ -598,12 +595,10 @@ public class NotificationPlatformBridge { ...@@ -598,12 +595,10 @@ public class NotificationPlatformBridge {
notificationBuilder); notificationBuilder);
} else { } else {
// Set up a pending intent for going to the settings screen for |origin|. // Set up a pending intent for going to the settings screen for |origin|.
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(context,
context, SingleWebsitePreferences.class.getName()); SingleWebsitePreferences.class.getName(),
settingsIntent.setData(makeIntentData(notificationId, origin, -1 /* actionIndex */));
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS,
SingleWebsitePreferences.createFragmentArgsForSite(origin)); SingleWebsitePreferences.createFragmentArgsForSite(origin));
settingsIntent.setData(makeIntentData(notificationId, origin, -1 /* actionIndex */));
PendingIntent pendingSettingsIntent = PendingIntent.getActivity(context, PendingIntent pendingSettingsIntent = PendingIntent.getActivity(context,
PENDING_INTENT_REQUEST_CODE, settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT); PENDING_INTENT_REQUEST_CODE, settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT);
......
...@@ -12,7 +12,6 @@ import android.content.Context; ...@@ -12,7 +12,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.text.Spannable; import android.text.Spannable;
...@@ -40,7 +39,6 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; ...@@ -40,7 +39,6 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer;
import org.chromium.chrome.browser.page_info.PageInfoView.ConnectionInfoParams; import org.chromium.chrome.browser.page_info.PageInfoView.ConnectionInfoParams;
import org.chromium.chrome.browser.page_info.PageInfoView.PageInfoViewParams; import org.chromium.chrome.browser.page_info.PageInfoView.PageInfoViewParams;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.website.ContentSetting; import org.chromium.chrome.browser.preferences.website.ContentSetting;
import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
...@@ -232,12 +230,9 @@ public class PageInfoController ...@@ -232,12 +230,9 @@ public class PageInfoController
// Delay while the dialog closes. // Delay while the dialog closes.
runAfterDismiss(() -> { runAfterDismiss(() -> {
recordAction(PageInfoAction.PAGE_INFO_SITE_SETTINGS_OPENED); recordAction(PageInfoAction.PAGE_INFO_SITE_SETTINGS_OPENED);
Bundle fragmentArguments =
SingleWebsitePreferences.createFragmentArgsForSite(mFullUrl);
Intent preferencesIntent = PreferencesLauncher.createIntentForSettingsPage( Intent preferencesIntent = PreferencesLauncher.createIntentForSettingsPage(
mContext, SingleWebsitePreferences.class.getName()); mContext, SingleWebsitePreferences.class.getName(),
preferencesIntent.putExtra( SingleWebsitePreferences.createFragmentArgsForSite(mFullUrl));
Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArguments);
// Disabling StrictMode to avoid violations (https://crbug.com/819410). // Disabling StrictMode to avoid violations (https://crbug.com/819410).
try (StrictModeContext unused = StrictModeContext.allowDiskReads()) { try (StrictModeContext unused = StrictModeContext.allowDiskReads()) {
mContext.startActivity(preferencesIntent); mContext.startActivity(preferencesIntent);
......
...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.payments; ...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.payments;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.support.v4.util.ArrayMap; import android.support.v4.util.ArrayMap;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -1434,9 +1433,7 @@ public class PaymentRequestImpl ...@@ -1434,9 +1433,7 @@ public class PaymentRequestImpl
return; return;
} }
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(context, MainPreferences.class);
context, MainPreferences.class.getName());
context.startActivity(intent);
} }
@Override @Override
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.preferences; package org.chromium.chrome.browser.preferences;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -24,7 +23,6 @@ import org.chromium.chrome.browser.signin.SigninAccessPoint; ...@@ -24,7 +23,6 @@ import org.chromium.chrome.browser.signin.SigninAccessPoint;
import org.chromium.chrome.browser.signin.SigninActivity; import org.chromium.chrome.browser.signin.SigninActivity;
import org.chromium.chrome.browser.sync.ProfileSyncService; import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.widget.TintedDrawable; import org.chromium.chrome.browser.widget.TintedDrawable;
import org.chromium.components.signin.ChromeSigninController; import org.chromium.components.signin.ChromeSigninController;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
...@@ -95,18 +93,16 @@ public class ContextualSuggestionsPreference ...@@ -95,18 +93,16 @@ public class ContextualSuggestionsPreference
final NoUnderlineClickableSpan span = new NoUnderlineClickableSpan((widget) -> { final NoUnderlineClickableSpan span = new NoUnderlineClickableSpan((widget) -> {
if (isUnifiedConsentEnabled) { if (isUnifiedConsentEnabled) {
if (isSignedIn) { if (isSignedIn) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(
context, SyncAndServicesPreferences.class.getName()); context, SyncAndServicesPreferences.class);
IntentUtils.safeStartActivity(context, intent);
} else { } else {
startActivity(SigninActivity.createIntentForPromoChooseAccountFlow( startActivity(SigninActivity.createIntentForPromoChooseAccountFlow(
context, SigninAccessPoint.SETTINGS, null)); context, SigninAccessPoint.SETTINGS, null));
} }
} else { } else {
if (isSignedIn) { if (isSignedIn) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(
context, SyncCustomizationFragment.class.getName()); context, SyncCustomizationFragment.class);
IntentUtils.safeStartActivity(context, intent);
} else { } else {
startActivity(AccountSigninActivity.createIntentForDefaultSigninFlow( startActivity(AccountSigninActivity.createIntentForDefaultSigninFlow(
context, SigninAccessPoint.SETTINGS, false)); context, SigninAccessPoint.SETTINGS, false));
......
...@@ -53,8 +53,8 @@ import org.chromium.chrome.browser.profiles.ProfileManagerUtils; ...@@ -53,8 +53,8 @@ import org.chromium.chrome.browser.profiles.ProfileManagerUtils;
* PreferenceUtils.getShowShadowOnScrollListener(...). * PreferenceUtils.getShowShadowOnScrollListener(...).
*/ */
public class Preferences extends AppCompatActivity implements OnPreferenceStartFragmentCallback { public class Preferences extends AppCompatActivity implements OnPreferenceStartFragmentCallback {
public static final String EXTRA_SHOW_FRAGMENT = "show_fragment"; static final String EXTRA_SHOW_FRAGMENT = "show_fragment";
public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = "show_fragment_args"; static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = "show_fragment_args";
private static final String TAG = "Preferences"; private static final String TAG = "Preferences";
......
...@@ -5,15 +5,18 @@ ...@@ -5,15 +5,18 @@
package org.chromium.chrome.browser.preferences; package org.chromium.chrome.browser.preferences;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.preferences.autofill.AutofillPaymentMethodsFragment; import org.chromium.chrome.browser.preferences.autofill.AutofillPaymentMethodsFragment;
import org.chromium.chrome.browser.preferences.autofill.AutofillProfilesFragment; import org.chromium.chrome.browser.preferences.autofill.AutofillProfilesFragment;
import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences; import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences;
import org.chromium.chrome.browser.preferences.privacy.ClearBrowsingDataTabsFragment; import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -28,11 +31,37 @@ public class PreferencesLauncher { ...@@ -28,11 +31,37 @@ public class PreferencesLauncher {
* Launches settings, either on the top-level page or on a subpage. * Launches settings, either on the top-level page or on a subpage.
* *
* @param context The current Activity, or an application context if no Activity is available. * @param context The current Activity, or an application context if no Activity is available.
* @param fragment The fragment to show, or null to show the top-level page.
*/
public static void launchSettingsPage(
Context context, @Nullable Class<? extends Fragment> fragment) {
launchSettingsPage(context, fragment, null);
}
/**
* Launches settings, either on the top-level page or on a subpage.
*
* @param context The current Activity, or an application context if no Activity is available.
* @param fragment The name of the fragment to show, or null to show the top-level page.
* @param fragmentArgs The arguments bundle to initialize the instance of subpage fragment.
*/
public static void launchSettingsPage(Context context,
@Nullable Class<? extends Fragment> fragment, @Nullable Bundle fragmentArgs) {
String fragmentName = fragment != null ? fragment.getName() : null;
Intent intent = createIntentForSettingsPage(context, fragmentName, fragmentArgs);
IntentUtils.safeStartActivity(context, intent);
}
/**
* Creates an intent for launching settings, either on the top-level settings page or a specific
* subpage.
*
* @param context The current Activity, or an application context if no Activity is available.
* @param fragmentName The name of the fragment to show, or null to show the top-level page. * @param fragmentName The name of the fragment to show, or null to show the top-level page.
*/ */
public static void launchSettingsPage(Context context, String fragmentName) { public static Intent createIntentForSettingsPage(
Intent intent = createIntentForSettingsPage(context, fragmentName); Context context, @Nullable String fragmentName) {
context.startActivity(intent); return createIntentForSettingsPage(context, fragmentName, null);
} }
/** /**
...@@ -41,8 +70,10 @@ public class PreferencesLauncher { ...@@ -41,8 +70,10 @@ public class PreferencesLauncher {
* *
* @param context The current Activity, or an application context if no Activity is available. * @param context The current Activity, or an application context if no Activity is available.
* @param fragmentName The name of the fragment to show, or null to show the top-level page. * @param fragmentName The name of the fragment to show, or null to show the top-level page.
* @param fragmentArgs The arguments bundle to initialize the instance of subpage fragment.
*/ */
public static Intent createIntentForSettingsPage(Context context, String fragmentName) { public static Intent createIntentForSettingsPage(
Context context, @Nullable String fragmentName, @Nullable Bundle fragmentArgs) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(context, Preferences.class); intent.setClass(context, Preferences.class);
if (!(context instanceof Activity)) { if (!(context instanceof Activity)) {
...@@ -52,38 +83,31 @@ public class PreferencesLauncher { ...@@ -52,38 +83,31 @@ public class PreferencesLauncher {
if (fragmentName != null) { if (fragmentName != null) {
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT, fragmentName); intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT, fragmentName);
} }
if (fragmentArgs != null) {
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
}
return intent; return intent;
} }
/**
* Creates an intent for launching clear browsing data, either on the top-level settings page or
* a specific subpage.
*
* @param context The current Activity, or an application context if no Activity is available.
*/
public static Intent createIntentForClearBrowsingDataPage(Context context) {
return createIntentForSettingsPage(context, ClearBrowsingDataTabsFragment.class.getName());
}
@CalledByNative @CalledByNative
private static void showAutofillProfileSettings(WebContents webContents) { private static void showAutofillProfileSettings(WebContents webContents) {
showSettingSubpage(webContents, AutofillProfilesFragment.class.getName()); showSettingSubpage(webContents, AutofillProfilesFragment.class);
} }
@CalledByNative @CalledByNative
private static void showAutofillCreditCardSettings(WebContents webContents) { private static void showAutofillCreditCardSettings(WebContents webContents) {
showSettingSubpage(webContents, AutofillPaymentMethodsFragment.class.getName()); showSettingSubpage(webContents, AutofillPaymentMethodsFragment.class);
} }
@CalledByNative @CalledByNative
private static void showPasswordSettings() { private static void showPasswordSettings() {
launchSettingsPage( launchSettingsPage(ContextUtils.getApplicationContext(), SavePasswordsPreferences.class);
ContextUtils.getApplicationContext(), SavePasswordsPreferences.class.getName());
} }
private static void showSettingSubpage(WebContents webContents, String className) { private static void showSettingSubpage(
WebContents webContents, Class<? extends Fragment> fragment) {
WeakReference<Activity> currentActivity = WeakReference<Activity> currentActivity =
webContents.getTopLevelNativeWindow().getActivity(); webContents.getTopLevelNativeWindow().getActivity();
launchSettingsPage(currentActivity.get(), className); launchSettingsPage(currentActivity.get(), fragment);
} }
} }
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
package org.chromium.chrome.browser.preferences; package org.chromium.chrome.browser.preferences;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.text.SpannableString; import android.text.SpannableString;
...@@ -475,11 +473,8 @@ public class SearchEngineAdapter extends BaseAdapter ...@@ -475,11 +473,8 @@ public class SearchEngineAdapter extends BaseAdapter
if (linkBeingShown == R.string.search_engine_system_location_disabled) { if (linkBeingShown == R.string.search_engine_system_location_disabled) {
mContext.startActivity(LocationUtils.getInstance().getSystemLocationSettingsIntent()); mContext.startActivity(LocationUtils.getInstance().getSystemLocationSettingsIntent());
} else { } else {
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(mContext, SingleWebsitePreferences.class,
mContext, SingleWebsitePreferences.class.getName()); SingleWebsitePreferences.createFragmentArgsForSite(url));
Bundle fragmentArgs = SingleWebsitePreferences.createFragmentArgsForSite(url);
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
mContext.startActivity(settingsIntent);
} }
} }
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
package org.chromium.chrome.browser.preferences.datareduction; package org.chromium.chrome.browser.preferences.datareduction;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.ColorMatrix; import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.text.format.Formatter; import android.text.format.Formatter;
import android.util.AttributeSet; import android.util.AttributeSet;
...@@ -101,11 +101,11 @@ public class DataReductionMainMenuItem extends FrameLayout implements View.OnCli ...@@ -101,11 +101,11 @@ public class DataReductionMainMenuItem extends FrameLayout implements View.OnCli
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage(
getContext(), DataReductionPreferences.class.getName());
RecordUserAction.record("MobileMenuDataSaverOpened"); RecordUserAction.record("MobileMenuDataSaverOpened");
intent.putExtra(DataReductionPreferences.FROM_MAIN_MENU, true); Bundle fragmentArgs = new Bundle();
getContext().startActivity(intent); fragmentArgs.putBoolean(DataReductionPreferences.FROM_MAIN_MENU, true);
PreferencesLauncher.launchSettingsPage(
getContext(), DataReductionPreferences.class, fragmentArgs);
Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile()); Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile());
tracker.notifyEvent(EventConstants.DATA_SAVER_DETAIL_OPENED); tracker.notifyEvent(EventConstants.DATA_SAVER_DETAIL_OPENED);
......
...@@ -57,14 +57,11 @@ public class DataReductionPreferences extends PreferenceFragment { ...@@ -57,14 +57,11 @@ public class DataReductionPreferences extends PreferenceFragment {
setHasOptionsMenu(true); setHasOptionsMenu(true);
if (getActivity() != null) { mFromPromo = IntentUtils.safeGetBoolean(
mFromPromo = IntentUtils.safeGetBooleanExtra(getActivity().getIntent(), getArguments(), DataReductionPromoSnackbarController.FROM_PROMO, false);
DataReductionPromoSnackbarController.FROM_PROMO, false); mFromMainMenu = IntentUtils.safeGetBoolean(getArguments(), FROM_MAIN_MENU, false);
mFromMainMenu = IntentUtils.safeGetBooleanExtra( mFromInfobar = IntentUtils.safeGetBoolean(
getActivity().getIntent(), FROM_MAIN_MENU, false); getArguments(), PreviewsLitePageInfoBar.FROM_INFOBAR, false);
mFromInfobar = IntentUtils.safeGetBooleanExtra(
getActivity().getIntent(), PreviewsLitePageInfoBar.FROM_INFOBAR, false);
}
} }
@Override @Override
......
...@@ -102,8 +102,8 @@ public class PasswordEntryEditor extends Fragment { ...@@ -102,8 +102,8 @@ public class PasswordEntryEditor extends Fragment {
mExtras = getArguments(); mExtras = getArguments();
assert mExtras != null; assert mExtras != null;
mID = mExtras.getInt(SavePasswordsPreferences.PASSWORD_LIST_ID); mID = mExtras.getInt(SavePasswordsPreferences.PASSWORD_LIST_ID);
mFoundViaSearch = getActivity().getIntent().getBooleanExtra( mFoundViaSearch =
SavePasswordsPreferences.EXTRA_FOUND_VIA_SEARCH, false); mExtras.getBoolean(SavePasswordsPreferences.EXTRA_FOUND_VIA_SEARCH, false);
final String name = mExtras.containsKey(SavePasswordsPreferences.PASSWORD_LIST_NAME) final String name = mExtras.containsKey(SavePasswordsPreferences.PASSWORD_LIST_NAME)
? mExtras.getString(SavePasswordsPreferences.PASSWORD_LIST_NAME) ? mExtras.getString(SavePasswordsPreferences.PASSWORD_LIST_NAME)
: null; : null;
......
...@@ -31,7 +31,6 @@ import org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference; ...@@ -31,7 +31,6 @@ import org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference;
import org.chromium.chrome.browser.preferences.ChromeBasePreference; import org.chromium.chrome.browser.preferences.ChromeBasePreference;
import org.chromium.chrome.browser.preferences.ChromeSwitchPreference; import org.chromium.chrome.browser.preferences.ChromeSwitchPreference;
import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SearchUtils; import org.chromium.chrome.browser.preferences.SearchUtils;
import org.chromium.chrome.browser.preferences.TextMessagePreference; import org.chromium.chrome.browser.preferences.TextMessagePreference;
...@@ -385,11 +384,11 @@ public class SavePasswordsPreferences ...@@ -385,11 +384,11 @@ public class SavePasswordsPreferences
} else { } else {
// Launch preference activity with PasswordEntryEditor fragment with // Launch preference activity with PasswordEntryEditor fragment with
// intent extras specifying the object. // intent extras specifying the object.
Intent intent = PreferencesLauncher.createIntentForSettingsPage( Bundle fragmentAgs = new Bundle(preference.getExtras());
getActivity(), PasswordEntryEditor.class.getName()); fragmentAgs.putBoolean(
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, preference.getExtras()); SavePasswordsPreferences.EXTRA_FOUND_VIA_SEARCH, mSearchQuery != null);
intent.putExtra(SavePasswordsPreferences.EXTRA_FOUND_VIA_SEARCH, mSearchQuery != null); PreferencesLauncher.launchSettingsPage(
startActivity(intent); getActivity(), PasswordEntryEditor.class, fragmentAgs);
} }
return true; return true;
} }
......
...@@ -83,7 +83,7 @@ public class PrivacyPreferences extends PreferenceFragment ...@@ -83,7 +83,7 @@ public class PrivacyPreferences extends PreferenceFragment
Preference syncAndServicesLink = findPreference(PREF_SYNC_AND_SERVICES_LINK); Preference syncAndServicesLink = findPreference(PREF_SYNC_AND_SERVICES_LINK);
NoUnderlineClickableSpan linkSpan = new NoUnderlineClickableSpan(view -> { NoUnderlineClickableSpan linkSpan = new NoUnderlineClickableSpan(view -> {
PreferencesLauncher.launchSettingsPage( PreferencesLauncher.launchSettingsPage(
getActivity(), SyncAndServicesPreferences.class.getName()); getActivity(), SyncAndServicesPreferences.class);
}); });
syncAndServicesLink.setSummary( syncAndServicesLink.setSummary(
SpanApplier.applySpans(getString(R.string.privacy_sync_and_services_link), SpanApplier.applySpans(getString(R.string.privacy_sync_and_services_link),
......
...@@ -9,7 +9,6 @@ import android.annotation.TargetApi; ...@@ -9,7 +9,6 @@ import android.annotation.TargetApi;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -36,7 +35,6 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer; ...@@ -36,7 +35,6 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.init.EmptyBrowserParts; import org.chromium.chrome.browser.init.EmptyBrowserParts;
import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager; import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager;
import org.chromium.chrome.browser.preferences.AboutChromePreferences; import org.chromium.chrome.browser.preferences.AboutChromePreferences;
import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.website.Website.StoredDataClearedCallback; import org.chromium.chrome.browser.preferences.website.Website.StoredDataClearedCallback;
import org.chromium.chrome.browser.searchwidget.SearchWidgetProvider; import org.chromium.chrome.browser.searchwidget.SearchWidgetProvider;
...@@ -236,17 +234,15 @@ public class ManageSpaceActivity extends AppCompatActivity implements View.OnCli ...@@ -236,17 +234,15 @@ public class ManageSpaceActivity extends AppCompatActivity implements View.OnCli
} }
mUnimportantDialog.show(); mUnimportantDialog.show();
} else if (view == mManageSiteDataButton) { } else if (view == mManageSiteDataButton) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage(
this, SingleCategoryPreferences.class.getName());
Bundle initialArguments = new Bundle(); Bundle initialArguments = new Bundle();
initialArguments.putString(SingleCategoryPreferences.EXTRA_CATEGORY, initialArguments.putString(SingleCategoryPreferences.EXTRA_CATEGORY,
SiteSettingsCategory.preferenceKey(SiteSettingsCategory.Type.USE_STORAGE)); SiteSettingsCategory.preferenceKey(SiteSettingsCategory.Type.USE_STORAGE));
initialArguments.putString(SingleCategoryPreferences.EXTRA_TITLE, initialArguments.putString(SingleCategoryPreferences.EXTRA_TITLE,
getString(R.string.website_settings_storage)); getString(R.string.website_settings_storage));
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, initialArguments);
RecordHistogram.recordEnumeratedHistogram( RecordHistogram.recordEnumeratedHistogram(
"Android.ManageSpace.ActionTaken", OPTION_MANAGE_STORAGE, OPTION_MAX); "Android.ManageSpace.ActionTaken", OPTION_MANAGE_STORAGE, OPTION_MAX);
startActivity(intent); PreferencesLauncher.launchSettingsPage(
this, SingleCategoryPreferences.class, initialArguments);
} else if (view == mClearAllDataButton) { } else if (view == mClearAllDataButton) {
final ActivityManager activityManager = final ActivityManager activityManager =
(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
......
...@@ -11,7 +11,6 @@ import android.app.Dialog; ...@@ -11,7 +11,6 @@ import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
...@@ -68,8 +67,7 @@ public class AccountManagementFragment extends PreferenceFragment ...@@ -68,8 +67,7 @@ public class AccountManagementFragment extends PreferenceFragment
private static final String CLEAR_DATA_PROGRESS_DIALOG_TAG = "clear_data_progress"; private static final String CLEAR_DATA_PROGRESS_DIALOG_TAG = "clear_data_progress";
/** /**
* The key for an integer value in * The key for an integer value in arguments bundle to
* {@link Preferences#EXTRA_SHOW_FRAGMENT_ARGUMENTS} bundle to
* specify the correct GAIA service that has triggered the dialog. * specify the correct GAIA service that has triggered the dialog.
* If the argument is not set, GAIA_SERVICE_TYPE_NONE is used as the origin of the dialog. * If the argument is not set, GAIA_SERVICE_TYPE_NONE is used as the origin of the dialog.
*/ */
...@@ -510,12 +508,10 @@ public class AccountManagementFragment extends PreferenceFragment ...@@ -510,12 +508,10 @@ public class AccountManagementFragment extends PreferenceFragment
* @param serviceType A signin::GAIAServiceType that triggered the dialog. * @param serviceType A signin::GAIAServiceType that triggered the dialog.
*/ */
public static void openAccountManagementScreen(int serviceType) { public static void openAccountManagementScreen(int serviceType) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage(
ContextUtils.getApplicationContext(), AccountManagementFragment.class.getName());
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, serviceType); arguments.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, serviceType);
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, arguments); PreferencesLauncher.launchSettingsPage(
ContextUtils.getApplicationContext().startActivity(intent); ContextUtils.getApplicationContext(), AccountManagementFragment.class, arguments);
} }
/** /**
......
...@@ -191,9 +191,8 @@ public class AccountSigninActivity extends SynchronousInitializationActivity ...@@ -191,9 +191,8 @@ public class AccountSigninActivity extends SynchronousInitializationActivity
@Override @Override
public void onSignInComplete() { public void onSignInComplete() {
if (settingsClicked) { if (settingsClicked) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(
context, AccountManagementFragment.class.getName()); context, AccountManagementFragment.class);
startActivity(intent);
} }
recordSigninCompletedHistogramAccountInfo(); recordSigninCompletedHistogramAccountInfo();
......
...@@ -55,8 +55,7 @@ public class ConsentBumpFragment extends SigninFragmentBase { ...@@ -55,8 +55,7 @@ public class ConsentBumpFragment extends SigninFragmentBase {
boolean settingsClicked, Runnable callback) { boolean settingsClicked, Runnable callback) {
UnifiedConsentServiceBridge.setUnifiedConsentGiven(true); UnifiedConsentServiceBridge.setUnifiedConsentGiven(true);
if (settingsClicked) { if (settingsClicked) {
PreferencesLauncher.launchSettingsPage( PreferencesLauncher.launchSettingsPage(getActivity(), SyncAndServicesPreferences.class);
getActivity(), SyncAndServicesPreferences.class.getName());
} }
getActivity().finish(); getActivity().finish();
callback.run(); callback.run();
......
...@@ -137,7 +137,7 @@ public class SigninFragment extends SigninFragmentBase { ...@@ -137,7 +137,7 @@ public class SigninFragment extends SigninFragmentBase {
UnifiedConsentServiceBridge.setUnifiedConsentGiven(true); UnifiedConsentServiceBridge.setUnifiedConsentGiven(true);
if (settingsClicked) { if (settingsClicked) {
PreferencesLauncher.launchSettingsPage( PreferencesLauncher.launchSettingsPage(
getActivity(), SyncAndServicesPreferences.class.getName()); getActivity(), SyncAndServicesPreferences.class);
} }
recordSigninCompletedHistogramAccountInfo(); recordSigninCompletedHistogramAccountInfo();
......
...@@ -174,7 +174,7 @@ public class SyncPromoView extends LinearLayout implements AndroidSyncSettingsOb ...@@ -174,7 +174,7 @@ public class SyncPromoView extends LinearLayout implements AndroidSyncSettingsOb
ButtonState positiveButton = new ButtonPresent(R.string.enable_sync_button, ButtonState positiveButton = new ButtonPresent(R.string.enable_sync_button,
view -> PreferencesLauncher.launchSettingsPage( view -> PreferencesLauncher.launchSettingsPage(
getContext(), SyncCustomizationFragment.class.getName())); getContext(), SyncCustomizationFragment.class));
return new ViewState(descId, positiveButton); return new ViewState(descId, positiveButton);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package org.chromium.chrome.browser.snackbar; package org.chromium.chrome.browser.snackbar;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.os.Bundle;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -130,10 +130,10 @@ public class DataReductionPromoSnackbarController implements SnackbarManager.Sna ...@@ -130,10 +130,10 @@ public class DataReductionPromoSnackbarController implements SnackbarManager.Sna
@Override @Override
public void onAction(Object actionData) { public void onAction(Object actionData) {
assert mContext != null; assert mContext != null;
Intent intent = PreferencesLauncher.createIntentForSettingsPage( Bundle fragmentArgs = new Bundle();
mContext, DataReductionPreferences.class.getName()); fragmentArgs.putBoolean(FROM_PROMO, true);
intent.putExtra(FROM_PROMO, true); PreferencesLauncher.launchSettingsPage(
mContext.startActivity(intent); mContext, DataReductionPreferences.class, fragmentArgs);
} }
@Override @Override
......
...@@ -149,9 +149,8 @@ public class SiteSettingsPreferencesTest { ...@@ -149,9 +149,8 @@ public class SiteSettingsPreferencesTest {
Bundle fragmentArgs = new Bundle(); Bundle fragmentArgs = new Bundle();
fragmentArgs.putString(SingleCategoryPreferences.EXTRA_CATEGORY, category); fragmentArgs.putString(SingleCategoryPreferences.EXTRA_CATEGORY, category);
Intent intent = PreferencesLauncher.createIntentForSettingsPage( Intent intent = PreferencesLauncher.createIntentForSettingsPage(
InstrumentationRegistry.getTargetContext(), InstrumentationRegistry.getTargetContext(), SiteSettingsPreferences.class.getName(),
SiteSettingsPreferences.class.getName()); fragmentArgs);
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent); return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent);
} }
...@@ -161,8 +160,7 @@ public class SiteSettingsPreferencesTest { ...@@ -161,8 +160,7 @@ public class SiteSettingsPreferencesTest {
SingleCategoryPreferences.EXTRA_CATEGORY, SiteSettingsCategory.preferenceKey(type)); SingleCategoryPreferences.EXTRA_CATEGORY, SiteSettingsCategory.preferenceKey(type));
Intent intent = PreferencesLauncher.createIntentForSettingsPage( Intent intent = PreferencesLauncher.createIntentForSettingsPage(
InstrumentationRegistry.getTargetContext(), InstrumentationRegistry.getTargetContext(),
SingleCategoryPreferences.class.getName()); SingleCategoryPreferences.class.getName(), fragmentArgs);
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent); return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent);
} }
...@@ -171,8 +169,7 @@ public class SiteSettingsPreferencesTest { ...@@ -171,8 +169,7 @@ public class SiteSettingsPreferencesTest {
fragmentArgs.putSerializable(SingleWebsitePreferences.EXTRA_SITE, site); fragmentArgs.putSerializable(SingleWebsitePreferences.EXTRA_SITE, site);
Intent intent = PreferencesLauncher.createIntentForSettingsPage( Intent intent = PreferencesLauncher.createIntentForSettingsPage(
InstrumentationRegistry.getTargetContext(), InstrumentationRegistry.getTargetContext(),
SingleWebsitePreferences.class.getName()); SingleWebsitePreferences.class.getName(), fragmentArgs);
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent); return (Preferences) InstrumentationRegistry.getInstrumentation().startActivitySync(intent);
} }
......
...@@ -392,9 +392,7 @@ public class VrBrowserTransitionTest { ...@@ -392,9 +392,7 @@ public class VrBrowserTransitionTest {
NativeUiUtils.enableMockedInput(); NativeUiUtils.enableMockedInput();
NativeUiUtils.performActionAndWaitForUiQuiescence(() -> { NativeUiUtils.performActionAndWaitForUiQuiescence(() -> {
ThreadUtils.runOnUiThreadBlocking(() -> { ThreadUtils.runOnUiThreadBlocking(() -> {
Intent preferencesIntent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(context, SingleWebsitePreferences.class);
context, SingleWebsitePreferences.class.getName());
context.startActivity(preferencesIntent);
}); });
}); });
ThreadUtils.runOnUiThreadBlocking( ThreadUtils.runOnUiThreadBlocking(
......
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