Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java
index 02524a3eff9ae053424ab0871d196b7a853c15d7..6bcee905c0065125a0330633871252e029e26edc 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java
@@ -183,7 +183,7 @@
* @param profile Profile to use.
*/
private static void startFetchingAccountsInformation(Context context, Profile profile) {
- Account[] accounts = AccountManagerHelper.get().getGoogleAccounts();
+ Account[] accounts = AccountManagerHelper.get(context).getGoogleAccounts();
for (int i = 0; i < accounts.length; i++) {
startFetchingAccountInformation(context, profile, accounts[i].name);
}
@@ -195,7 +195,7 @@
if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();
- ChromeSigninController signInController = ChromeSigninController.get();
+ ChromeSigninController signInController = ChromeSigninController.get(context);
if (!signInController.isSignedIn()) {
// The AccountManagementFragment can only be shown when the user is signed in. If the
// user is signed out, exit the fragment.
@@ -205,7 +205,8 @@
addPreferencesFromResource(R.xml.account_management_preferences);
- String signedInAccountName = ChromeSigninController.get().getSignedInAccountName();
+ String signedInAccountName =
+ ChromeSigninController.get(getActivity()).getSignedInAccountName();
String fullName = getCachedUserName(signedInAccountName);
if (TextUtils.isEmpty(fullName)) {
fullName = ProfileDownloader.getCachedFullName(Profile.getLastUsedProfile());
@@ -245,7 +246,7 @@
public boolean onPreferenceClick(Preference preference) {
if (!isVisible() || !isResumed()) return false;
- if (ChromeSigninController.get().isSignedIn()
+ if (ChromeSigninController.get(getActivity()).isSignedIn()
&& getSignOutAllowedPreferenceValue(getActivity())) {
AccountManagementScreenHelper.logEvent(
ProfileAccountManagementMetrics.TOGGLE_SIGNOUT,
@@ -281,7 +282,7 @@
private void configureSyncSettings() {
final Preferences preferences = (Preferences) getActivity();
- final Account account = ChromeSigninController.get().getSignedInUser();
+ final Account account = ChromeSigninController.get(getActivity()).getSignedInUser();
findPreference(PREF_SYNC_SETTINGS)
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
@@ -309,7 +310,7 @@
public boolean onPreferenceClick(Preference preference) {
Activity activity = getActivity();
AppHooks.get().createGoogleActivityController().openWebAndAppActivitySettings(
- activity, ChromeSigninController.get().getSignedInAccountName());
+ activity, ChromeSigninController.get(activity).getSignedInAccountName());
RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
return true;
}
@@ -415,7 +416,7 @@
mAccountsListPreferences.clear();
final Preferences activity = (Preferences) getActivity();
- Account[] accounts = AccountManagerHelper.get().getGoogleAccounts();
+ Account[] accounts = AccountManagerHelper.get(activity).getGoogleAccounts();
int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;
for (Account account : accounts) {
@@ -474,7 +475,7 @@
public void onSignOutClicked() {
// In case the user reached this fragment without being signed in, we guard the sign out so
// we do not hit a native crash.
- if (!ChromeSigninController.get().isSignedIn()) return;
+ if (!ChromeSigninController.get(getActivity()).isSignedIn()) return;
final Activity activity = getActivity();
final DialogFragment clearDataProgressDialog = new ClearDataProgressDialog();
@@ -542,15 +543,18 @@
/**
* Open the account management UI.
+ * @param applicationContext An application context.
+ * @param profile A user profile.
* @param serviceType A signin::GAIAServiceType that triggered the dialog.
*/
- public static void openAccountManagementScreen(int serviceType) {
- Intent intent = PreferencesLauncher.createIntentForSettingsPage(
- ContextUtils.getApplicationContext(), AccountManagementFragment.class.getName());
+ public static void openAccountManagementScreen(
+ Context applicationContext, Profile profile, int serviceType) {
+ Intent intent = PreferencesLauncher.createIntentForSettingsPage(applicationContext,
+ AccountManagementFragment.class.getName());
Bundle arguments = new Bundle();
arguments.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, serviceType);
intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, arguments);
- ContextUtils.getApplicationContext().startActivity(intent);
+ applicationContext.startActivity(intent);
}
/**
@@ -696,7 +700,7 @@
* @param profile A profile to use.
*/
public static void prefetchUserNamePicture(Context context, Profile profile) {
- final String accountName = ChromeSigninController.get().getSignedInAccountName();
+ final String accountName = ChromeSigninController.get(context).getSignedInAccountName();
if (TextUtils.isEmpty(accountName)) return;
if (sToNamePicture.get(accountName) != null) return;

Powered by Google App Engine
This is Rietveld 408576698