本文整理汇总了Java中org.chromium.chrome.browser.signin.SigninManager类的典型用法代码示例。如果您正苦于以下问题:Java SigninManager类的具体用法?Java SigninManager怎么用?Java SigninManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SigninManager类属于org.chromium.chrome.browser.signin包,在下文中一共展示了SigninManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BookmarkPromoHeader
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Initializes the class. Note that this will start listening to signin related events and
* update itself if needed.
*/
BookmarkPromoHeader(Context context,
PromoHeaderShowingChangeListener showingChangeListener) {
mContext = context;
mShowingChangeListener = showingChangeListener;
AndroidSyncSettings.registerObserver(mContext, this);
mSignInManager = SigninManager.get(mContext);
mSignInManager.addSignInStateObserver(this);
updateShouldShow(false);
if (shouldShow()) {
int promoShowCount = ContextUtils.getAppSharedPreferences()
.getInt(PREF_SIGNIN_PROMO_SHOW_COUNT, 0) + 1;
ContextUtils.getAppSharedPreferences().edit()
.putInt(PREF_SIGNIN_PROMO_SHOW_COUNT, promoShowCount).apply();
RecordUserAction.record("Signin_Impression_FromBookmarkManager");
}
}
示例2: GoogleServicesManager
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
private GoogleServicesManager(Context context) {
try {
TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
ThreadUtils.assertOnUiThread();
// We should store the application context, as we outlive any activity which may create
// us.
mContext = context.getApplicationContext();
mChromeSigninController = ChromeSigninController.get(mContext);
mSigninHelper = SigninHelper.get(mContext);
// The sign out flow starts by clearing the signed in user in the ChromeSigninController
// on the Java side, and then performs a sign out on the native side. If there is a
// crash on the native side then the signin state may get out of sync. Make sure that
// the native side is signed out if the Java side doesn't have a currently signed in
// user.
SigninManager signinManager = SigninManager.get(mContext);
if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
signinManager.signOut();
}
// Initialize sync.
SyncController.get(context);
ApplicationStatus.registerApplicationStateListener(this);
} finally {
TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
}
}
示例3: RecentTabsManager
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Create an RecentTabsManager to be used with RecentTabsPage and RecentTabsRowAdapter.
*
* @param tab The Tab that is showing this recent tabs page.
* @param profile Profile that is associated with the current session.
* @param context the Android context this manager will work in.
*/
public RecentTabsManager(Tab tab, Profile profile, Context context) {
mProfile = profile;
mTab = tab;
mForeignSessionHelper = buildForeignSessionHelper(mProfile);
mNewTabPagePrefs = buildNewTabPagePrefs(mProfile);
mFaviconHelper = buildFaviconHelper();
mRecentlyClosedBridge = buildRecentlyClosedBridge(mProfile);
mSignInManager = SigninManager.get(context);
mContext = context;
updateRecentlyClosedTabs();
registerForForeignSessionUpdates();
updateForeignSessions();
mForeignSessionHelper.triggerSessionSync();
registerForSignInAndSyncNotifications();
InvalidationController.get(mContext).onRecentTabsPageOpened();
}
示例4: onChildAccountStatusUpdated
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Called when the child account status has been determined or updated.
* Can be overridden by subclasses to avoid native calls and calls into dependencies in testing.
*
* @param oldValue The old child account status. This is null when the child account status
* has been determined for the first time after the browser has started.
*/
protected void onChildAccountStatusUpdated(Boolean oldValue) {
Log.v(TAG, "hasChildAccount: " + mHasChildAccount + " oldHasChildAccount: " + oldValue);
if (mHasChildAccount) {
if (oldValue == null) {
// This is the first time we have determined the child account status, which means
// the browser is starting up. If we are not signed in yet, the startup code will
// sign in and call us back in onChildAccountSigninComplete().
if (ChromeSigninController.get(mContext).getSignedInUser() == null) return;
} else if (!oldValue.booleanValue()) {
// We have switched from no child account to child account while the browser
// is running. Sign in (which will call us back in onChildAccountSigninComplete()).
SigninManager signinManager = SigninManager.get(mContext);
Account account = AccountManagerHelper.get(mContext).getSingleGoogleAccount();
signinManager.signInToSelectedAccount(null, account,
SigninManager.SIGNIN_TYPE_FORCED_CHILD_ACCOUNT,
SigninManager.SIGNIN_SYNC_IMMEDIATELY, false, null);
return;
}
}
// Fallthrough for all other cases: Propagate child account status to native code.
// This is a no-op if the child account status does not change.
nativeSetIsChildAccount(mHasChildAccount);
}
示例5: signIn
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Trigger Chromium sign in of the given account.
*
* This also ensure that sync setup is not in progress anymore, so sync will start after
* sync initialization has happened.
*
* @param activity the current activity.
* @param accountName the full account name.
*/
@VisibleForTesting
public void signIn(Activity activity, String accountName) {
final Account account = AccountManagerHelper.createAccountFromName(accountName);
// The SigninManager handles most of the sign-in flow, and doFinishSignIn handles the
// ChromeShell specific details.
SigninManager signinManager = SigninManager.get(mContext);
signinManager.onFirstRunCheckDone();
final boolean passive = false;
signinManager.startSignIn(activity, account, passive, new SignInFlowObserver() {
@Override
public void onSigninComplete() {
SigninManager.get(mContext).logInSignedInUser();
mProfileSyncService.setSetupInProgress(false);
start();
}
@Override
public void onSigninCancelled() {
stop();
}
});
}
示例6: onCreate
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
RecordUserAction.record("Stars_SignInPromoActivity_Launched");
}
setContentView(new RecentTabsPromoView(this, this, this));
AndroidSyncSettings.registerObserver(this, this);
mSignInManager = SigninManager.get(this);
mSignInManager.addSignInStateObserver(this);
// This signin activity shouldn't be created if user is signed in already, but for just in
// case it was signed in just before onCreate somehow.
if (isSignedIn()) finish();
}
示例7: EnhancedBookmarkPromoHeader
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Initializes the class. Note that this will start listening to signin related events and
* update itself if needed.
*/
EnhancedBookmarkPromoHeader(Context context,
PromoHeaderShowingChangeListener showingChangeListener) {
mContext = context;
mShowingChangeListener = showingChangeListener;
AndroidSyncSettings.registerObserver(mContext, this);
mSignInManager = SigninManager.get(mContext);
mSignInManager.addSignInStateObserver(this);
updateShouldShow(false);
if (shouldShow()) {
int promoShowCount = PreferenceManager.getDefaultSharedPreferences(mContext)
.getInt(PREF_SIGNIN_PROMO_SHOW_COUNT, 0) + 1;
PreferenceManager.getDefaultSharedPreferences(mContext).edit()
.putInt(PREF_SIGNIN_PROMO_SHOW_COUNT, promoShowCount).apply();
RecordUserAction.record("Stars_SignInPromoHeader_Displayed");
}
}
示例8: signIn
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Trigger Chromium sign in of the given account.
*
* This also ensure that sync setup is not in progress anymore, so sync will start after
* sync initialization has happened.
*
* @param activity the current activity.
* @param accountName the full account name.
*/
public void signIn(Activity activity, String accountName) {
final Account account = AccountManagerHelper.createAccountFromName(accountName);
// The SigninManager handles most of the sign-in flow, and doFinishSignIn handles the
// Chromium testshell specific details.
SigninManager signinManager = SigninManager.get(mContext);
signinManager.onFirstRunCheckDone();
final boolean passive = false;
signinManager.startSignIn(activity, account, passive, new SigninManager.Observer() {
@Override
public void onSigninComplete() {
SigninManager.get(mContext).logInSignedInUser();
mProfileSyncService.setSetupInProgress(false);
mProfileSyncService.syncSignIn();
start();
}
@Override
public void onSigninCancelled() {
stop();
}
});
}
示例9: shouldDisplaySyncPromo
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Determine whether the sync promo needs to be displayed.
*
* @return Whether sync promo should be displayed.
*/
public boolean shouldDisplaySyncPromo() {
SigninManager signinManager = SigninManager.get(mContext);
if (signinManager.isSigninDisabledByPolicy() || !signinManager.isSigninSupported()) {
return false;
}
if (ContextUtils.getAppSharedPreferences().getBoolean(
PREF_SIGNIN_PROMO_DECLINED, false)) {
return false;
}
return !AndroidSyncSettings.isSyncEnabled(mContext) || mForeignSessions.isEmpty();
}
示例10: SignInPromo
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
public SignInPromo(NodeParent parent, NewTabPageAdapter adapter) {
super(parent);
mDismissed = ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext())
.getNewTabPageSigninPromoDismissed();
final SigninManager signinManager = SigninManager.get(ContextUtils.getApplicationContext());
mObserver = mDismissed ? null : new SigninObserver(signinManager, adapter);
setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInOnNative());
}
示例11: onResume
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
// updatePreferences() must be called before setupSignInPref as updatePreferences loads
// the SignInPreference.
updatePreferences();
if (SigninManager.get(getActivity()).isSigninSupported()) {
SigninManager.get(getActivity()).addSignInStateObserver(this);
setupSignInPref();
}
}
示例12: onPause
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
@Override
public void onPause() {
super.onPause();
if (SigninManager.get(getActivity()).isSigninSupported()) {
SigninManager.get(getActivity()).removeSignInStateObserver(this);
clearSignInPref();
}
}
示例13: registerForUpdates
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Starts listening for updates to the sign-in and sync state.
*/
public void registerForUpdates() {
SigninManager manager = SigninManager.get(getContext());
manager.addSignInAllowedObserver(this);
ProfileDownloader.addObserver(this);
FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone(getContext());
AndroidSyncSettings.registerObserver(getContext(), this);
ProfileSyncService syncService = ProfileSyncService.get();
if (syncService != null) {
syncService.addSyncStateChangedListener(this);
}
}
示例14: unregisterForUpdates
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Stops listening for updates to the sign-in and sync state. Every call to registerForUpdates()
* must be matched with a call to this method.
*/
public void unregisterForUpdates() {
SigninManager manager = SigninManager.get(getContext());
manager.removeSignInAllowedObserver(this);
ProfileDownloader.removeObserver(this);
AndroidSyncSettings.unregisterObserver(getContext(), this);
ProfileSyncService syncService = ProfileSyncService.get();
if (syncService != null) {
syncService.removeSyncStateChangedListener(this);
}
}
示例15: updateSigninManagerFirstRunCheckDone
import org.chromium.chrome.browser.signin.SigninManager; //导入依赖的package包/类
/**
* Allows the user to sign-in if there are no pending FRE sign-in requests.
* @param context A context
*/
public static void updateSigninManagerFirstRunCheckDone(Context context) {
SigninManager manager = SigninManager.get(context);
if (manager.isSignInAllowed()) return;
if (!FirstRunStatus.getFirstRunFlowComplete()) return;
if (!getFirstRunFlowSignInComplete(context)) return;
manager.onFirstRunCheckDone();
}