Skip to content

Commit

Permalink
Fix the ClassCastException on opening ClearSyncDataPreferences.
Browse files Browse the repository at this point in the history
When opening from ClearSyncDataPreferences, the getActivity() call was casted to Preferences, which was
1.) too specific - this code can be reached from at least three different places, two of which (bookmarks menu, recent tabs menu) are not Preferences; the main entry point is through the privacy settings, which is a Preferences activity, which is why this wasn't discovered immediately
2.) not even needed - PreferencesLauncher.createIntentForSettingsPage accepts any Context as an argument, so getActivity() doesn't need to be casted at all

BUG=585714

Review URL: https://codereview.chromium.org/1701753002

Cr-Commit-Position: refs/heads/master@{#375480}
  • Loading branch information
msramek authored and Commit bot committed Feb 15, 2016
1 parent 1532199 commit 1d144ca
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
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.sync.ui.ClearSyncDataPreferences;
import org.chromium.ui.text.SpanApplier;
Expand Down Expand Up @@ -93,10 +92,9 @@ public void onClick(DialogInterface dialog, int which) {
}

private void showClearSyncDataPreferences() {
Preferences prefActivity = (Preferences) getActivity();
Intent intent = PreferencesLauncher.createIntentForSettingsPage(prefActivity,
Intent intent = PreferencesLauncher.createIntentForSettingsPage(getActivity(),
ClearSyncDataPreferences.class.getName());
prefActivity.startActivity(intent);
startActivity(intent);

// Cancel out of current sign in.
SigninManager.get(getActivity()).abortSignIn();
Expand Down

0 comments on commit 1d144ca

Please sign in to comment.