| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.sync.signin; | 5 package org.chromium.sync.signin; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.preference.PreferenceManager; | |
| 10 | 9 |
| 10 import org.chromium.base.ContextUtils; |
| 11 import org.chromium.sync.AndroidSyncSettings; | 11 import org.chromium.sync.AndroidSyncSettings; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Caches the signed-in username in the app prefs. | 14 * Caches the signed-in username in the app prefs. |
| 15 */ | 15 */ |
| 16 public class ChromeSigninController { | 16 public class ChromeSigninController { |
| 17 | 17 |
| 18 public static final String TAG = "ChromeSigninController"; | 18 public static final String TAG = "ChromeSigninController"; |
| 19 | 19 |
| 20 // Used by ChromeBackupAgent and for testing. | 20 // Used by ChromeBackupAgent and for testing. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return null; | 52 return null; |
| 53 } | 53 } |
| 54 return AccountManagerHelper.createAccountFromName(syncAccountName); | 54 return AccountManagerHelper.createAccountFromName(syncAccountName); |
| 55 } | 55 } |
| 56 | 56 |
| 57 public boolean isSignedIn() { | 57 public boolean isSignedIn() { |
| 58 return getSignedInAccountName() != null; | 58 return getSignedInAccountName() != null; |
| 59 } | 59 } |
| 60 | 60 |
| 61 public void setSignedInAccountName(String accountName) { | 61 public void setSignedInAccountName(String accountName) { |
| 62 PreferenceManager.getDefaultSharedPreferences(mApplicationContext).edit(
) | 62 ContextUtils.getAppSharedPreferences().edit() |
| 63 .putString(SIGNED_IN_ACCOUNT_KEY, accountName) | 63 .putString(SIGNED_IN_ACCOUNT_KEY, accountName) |
| 64 .apply(); | 64 .apply(); |
| 65 // TODO(maxbogue): Move this to SigninManager. | 65 // TODO(maxbogue): Move this to SigninManager. |
| 66 AndroidSyncSettings.updateAccount(mApplicationContext, getSignedInUser()
); | 66 AndroidSyncSettings.updateAccount(mApplicationContext, getSignedInUser()
); |
| 67 } | 67 } |
| 68 | 68 |
| 69 public String getSignedInAccountName() { | 69 public String getSignedInAccountName() { |
| 70 return PreferenceManager.getDefaultSharedPreferences(mApplicationContext
) | 70 return ContextUtils.getAppSharedPreferences().getString(SIGNED_IN_ACCOUN
T_KEY, null); |
| 71 .getString(SIGNED_IN_ACCOUNT_KEY, null); | |
| 72 } | 71 } |
| 73 } | 72 } |
| OLD | NEW |