• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChromeSigninController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.chromium.sync.signin.ChromeSigninController的典型用法代码示例。如果您正苦于以下问题:Java ChromeSigninController类的具体用法?Java ChromeSigninController怎么用?Java ChromeSigninController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChromeSigninController类属于org.chromium.sync.signin包,在下文中一共展示了ChromeSigninController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onChildAccountStatusUpdated

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的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);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:31,代码来源:ChildAccountService.java


示例2: deliverMessage

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@Override
public void deliverMessage(final String to, final Bundle data) {
    @Nullable
    Account account = ChromeSigninController.get(this).getSignedInUser();
    if (account == null) {
        // This should never happen, because this code should only be run if a user is
        // signed-in.
        Log.w(TAG, "No signed-in user; cannot send message to data center");
        return;
    }

    // Attempt to retrieve a token for the user.
    OAuth2TokenService.getOAuth2AccessToken(this, null, account,
            SyncConstants.CHROME_SYNC_OAUTH2_SCOPE,
            new AccountManagerHelper.GetAuthTokenCallback() {
                @Override
                public void tokenAvailable(String token) {
                    sendUpstreamMessage(to, data, token);
                }
            });
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:22,代码来源:InvalidationGcmUpstreamSender.java


示例3: launchSigninPromoIfNeeded

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Launches the signin promo if it needs to be displayed.
 * @param activity The parent activity.
 * @return Whether the signin promo is shown.
 */
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
    // The promo is displayed if Chrome is launched directly (i.e., not with the intent to
    // navigate to and view a URL on startup), the instance is part of the field trial,
    // and the promo has been marked to display.
    ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
    if (MultiWindowUtils.getInstance().isMultiWindow(activity)) return false;
    if (!preferenceManager.getShowSigninPromo()) return false;
    preferenceManager.setShowSigninPromo(false);

    String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
    if (SigninManager.getAndroidSigninPromoExperimentGroup() < 0
            || ChromeSigninController.get(activity).isSignedIn()
            || !TextUtils.isEmpty(lastSyncName)) {
        return false;
    }

    SigninPromoScreen promoScreen = new SigninPromoScreen(activity);
    promoScreen.show();
    preferenceManager.setSigninPromoShown();
    return true;
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:27,代码来源:SigninPromoScreen.java


示例4: signOut

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Signs out of Chrome.
 * <p/>
 * This method clears the signed-in username, stops sync and sends out a
 * sign-out notification on the native side.
 *
 * @param activity If not null then a progress dialog is shown over the activity until signout
 * completes, in case the account had management enabled. The activity must be valid until the
 * callback is invoked.
 * @param callback Will be invoked after signout completes, if not null.
 */
public void signOut(Activity activity, Runnable callback) {
    mSignOutCallback = callback;

    boolean wipeData = getManagementDomain() != null;
    Log.d(TAG, "Signing out, wipe data? " + wipeData);

    ChromeSigninController.get(mContext).clearSignedInUser();
    ProfileSyncService.get().signOut();
    nativeSignOut(mNativeSigninManagerAndroid);

    if (wipeData) {
        wipeProfileData(activity);
    } else {
        onSignOutDone();
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:28,代码来源:SigninManager.java


示例5: prefetchUserNamePicture

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Prefetch the primary account image and name.
 * @param context A context to use.
 * @param profile A profile to use.
 */
public static void prefetchUserNamePicture(Context context, Profile profile) {
    final String accountName = ChromeSigninController.get(context).getSignedInAccountName();
    if (TextUtils.isEmpty(accountName)) return;
    if (sToNamePicture.get(accountName) != null) return;

    ProfileDownloader.addObserver(new ProfileDownloader.Observer() {
        @Override
        public void onProfileDownloaded(String accountId, String fullName, String givenName,
                Bitmap bitmap) {
            if (TextUtils.equals(accountName, accountId)) {
                updateUserNamePictureCache(accountId, fullName, bitmap);
                ProfileDownloader.removeObserver(this);
            }
        }
    });
    startFetchingAccountInformation(context, profile, accountName);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:23,代码来源:AccountManagementFragment.java


示例6: onResume

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    Account account = ChromeSigninController.get(this).getSignedInUser();
    if (account == null) {
        finish();
        return;
    }

    if (!isShowingDialog(FRAGMENT_PASSPHRASE)) {
        if (ProfileSyncService.get().isSyncInitialized()) {
            displayPassphraseDialog();
        } else {
            addSyncStateChangedListener();
            displaySpinnerDialog();
        }
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:19,代码来源:PassphraseActivity.java


示例7: ensureStartedAndUpdateRegisteredTypes

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Updates the sync invalidation types that the client is registered for based on the preferred
 * sync types.  Starts the client if needed.
 */
public void ensureStartedAndUpdateRegisteredTypes() {
    mStarted = true;

    // Ensure GCM has been initialized.
    ensureGcmIsInitialized();

    // Do not apply changes to {@link #mSessionInvalidationsEnabled} yet because the timer task
    // may be scheduled far into the future.
    mEnableSessionInvalidationsTimer.resume();

    HashSet<Integer> typesToRegister = new HashSet<Integer>();
    typesToRegister.addAll(ProfileSyncService.get().getPreferredDataTypes());
    if (!mSessionInvalidationsEnabled) {
        typesToRegister.remove(ModelType.SESSIONS);
        typesToRegister.remove(ModelType.FAVICON_TRACKING);
        typesToRegister.remove(ModelType.FAVICON_IMAGES);
    }

    Intent registerIntent = InvalidationIntentProtocol.createRegisterIntent(
            ChromeSigninController.get(mContext).getSignedInUser(),
            typesToRegister);
    registerIntent.setClass(mContext, InvalidationClientService.class);
    mContext.startService(registerIntent);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:29,代码来源:InvalidationController.java


示例8: onReceive

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
    if (AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) {
        final Account signedInUser =
                ChromeSigninController.get(context).getSignedInUser();
        if (signedInUser != null) {
            BrowserStartupController.StartupCallback callback =
                    new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    OAuth2TokenService.getForProfile(Profile.getLastUsedProfile())
                            .validateAccounts(context);
                }

                @Override
                public void onFailure() {
                    Log.w(TAG, "Failed to start browser process.");
                }
            };
            startBrowserProcessOnUiThread(context, callback);
        }
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:24,代码来源:AccountsChangedReceiver.java


示例9: signOut

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Signs out of Chrome.
 * <p/>
 * This method clears the signed-in username, stops sync and sends out a
 * sign-out notification on the native side.
 *
 * @param activity If not null then a progress dialog is shown over the activity until signout
 * completes, in case the account had management enabled. The activity must be valid until the
 * callback is invoked.
 * @param callback Will be invoked after signout completes, if not null.
 */
public void signOut(Activity activity, Runnable callback) {
    mSignOutCallback = callback;

    boolean wipeData = getManagementDomain() != null;
    Log.d(TAG, "Signing out, wipe data? " + wipeData);

    ChromeSigninController.get(mContext).clearSignedInUser();
    ProfileSyncService.get(mContext).signOut();
    nativeSignOut(mNativeSigninManagerAndroid);

    if (wipeData) {
        wipeProfileData(activity);
    } else {
        onSignOutDone();
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:28,代码来源:SigninManager.java


示例10: requestAuthToken

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@Override
public void requestAuthToken(final PendingIntent pendingIntent,
        @Nullable String invalidAuthToken) {
    @Nullable Account account = ChromeSigninController.get(this).getSignedInUser();
    if (account == null) {
        // This should never happen, because this code should only be run if a user is
        // signed-in.
        Log.w(TAG, "No signed-in user; cannot send message to data center");
        return;
    }

    // Attempt to retrieve a token for the user. This method will also invalidate
    // invalidAuthToken if it is non-null.
    AccountManagerHelper.get(this).getNewAuthTokenFromForeground(
            account, invalidAuthToken, getOAuth2ScopeWithType(),
            new AccountManagerHelper.GetAuthTokenCallback() {
                @Override
                public void tokenAvailable(String token) {
                    if (token != null) {
                        setAuthToken(InvalidationService.this.getApplicationContext(),
                                pendingIntent, token, getOAuth2ScopeWithType());
                    }
                }
            });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:26,代码来源:InvalidationService.java


示例11: requestSync

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Requests that the sync system perform a sync.
 *
 * @param objectId the object that changed, if known.
 * @param version the version of the object that changed, if known.
 * @param payload the payload of the change, if known.
 */
private void requestSync(@Nullable ObjectId objectId, @Nullable Long version,
        @Nullable String payload) {
    // Construct the bundle to supply to the native sync code.
    Bundle bundle = new Bundle();
    if (objectId == null && version == null && payload == null) {
        // Use an empty bundle in this case for compatibility with the v1 implementation.
    } else {
        if (objectId != null) {
            bundle.putInt("objectSource", objectId.getSource());
            bundle.putString("objectId", new String(objectId.getName()));
        }
        // We use "0" as the version if we have an unknown-version invalidation. This is OK
        // because the native sync code special-cases zero and always syncs for invalidations at
        // that version (Tango defines a special UNKNOWN_VERSION constant with this value).
        bundle.putLong("version", (version == null) ? 0 : version);
        bundle.putString("payload", (payload == null) ? "" : payload);
    }
    Account account = ChromeSigninController.get(this).getSignedInUser();
    String contractAuthority = SyncStatusHelper.get(this).getContractAuthority();
    requestSyncFromContentResolver(bundle, account, contractAuthority);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:29,代码来源:InvalidationService.java


示例12: GoogleServicesManager

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的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(null, null);
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:31,代码来源:GoogleServicesManager.java


示例13: SigninManager

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
private SigninManager(Context context) {
    ThreadUtils.assertOnUiThread();
    mContext = context.getApplicationContext();
    mNativeSigninManagerAndroid = nativeInit();
    mSigninAllowedByPolicy = nativeIsSigninAllowedByPolicy(mNativeSigninManagerAndroid);

    // Setup notification system for Google services. This includes both sign-in and sync.
    GoogleServicesNotificationController controller =
            GoogleServicesNotificationController.get(mContext);
    mSigninNotificationController = new SigninNotificationController(
            mContext, controller, AccountManagementFragment.class);
    ChromeSigninController.get(mContext).addListener(mSigninNotificationController);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:14,代码来源:SigninManager.java


示例14: isSignInAllowed

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
/**
 * Returns true if signin can be started now.
 */
public boolean isSignInAllowed() {
    return mSigninAllowedByPolicy
            && !mFirstRunCheckIsPending
            && mSignInAccount == null
            && ChromeSigninController.get(mContext).getSignedInUser() == null;
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:10,代码来源:SigninManager.java


示例15: finishSignIn

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
private void finishSignIn(AccountIdsAndNames accountIdsAndNames) {
    if (mSignInAccount == null) {
        Log.w(TAG, "Sign in request was canceled; aborting finishSignIn().");
        return;
    }

    // Tell the native side that sign-in has completed.
    nativeOnSignInCompleted(mNativeSigninManagerAndroid, mSignInAccount.name,
                            accountIdsAndNames.mAccountIds, accountIdsAndNames.mAccountNames);

    // Cache the signed-in account name. This must be done after the native call, otherwise
    // sync tries to start without being signed in natively and crashes.
    ChromeSigninController.get(mContext).setSignedInAccountName(mSignInAccount.name);

    // Sign-in to sync.
    ProfileSyncService profileSyncService = ProfileSyncService.get();
    if (AndroidSyncSettings.isSyncEnabled(mContext)
            && !profileSyncService.hasSyncSetupCompleted()) {
        profileSyncService.setSetupInProgress(true);
        profileSyncService.requestStart();
    }

    if (mSignInFlowObserver != null) mSignInFlowObserver.onSigninComplete();

    // All done, cleanup.
    Log.d(TAG, "Signin done");
    mSignInActivity = null;
    mSignInAccount = null;
    mSignInFlowObserver = null;

    notifySignInAllowedChanged();
    for (SignInStateObserver observer : mSignInStateObservers) {
        observer.onSignedIn();
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:36,代码来源:SigninManager.java


示例16: validateAccounts

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@CalledByNative
public void validateAccounts(Context context, boolean forceNotifications) {
    ThreadUtils.assertOnUiThread();
    String currentlySignedInAccount =
            ChromeSigninController.get(context).getSignedInAccountName();
    nativeValidateAccounts(mNativeOAuth2TokenServiceDelegateAndroid, currentlySignedInAccount,
            forceNotifications);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:9,代码来源:OAuth2TokenService.java


示例17: update

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
public void update() {
    final Context context = getActivity();
    if (context == null) return;

    if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();

    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.
        getActivity().finish();
        return;
    }

    addPreferencesFromResource(R.xml.account_management_preferences);

    String signedInAccountName =
            ChromeSigninController.get(getActivity()).getSignedInAccountName();
    String fullName = getCachedUserName(signedInAccountName);
    if (TextUtils.isEmpty(fullName)) {
        fullName = ProfileDownloader.getCachedFullName(Profile.getLastUsedProfile());
    }
    if (TextUtils.isEmpty(fullName)) fullName = signedInAccountName;

    getActivity().setTitle(fullName);

    configureSignOutSwitch();
    configureAddAccountPreference(fullName);
    configureGoIncognitoPreferences(fullName);
    configureChildAccountPreferences();

    updateAccountsList();
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:34,代码来源:AccountManagementFragment.java


示例18: configureSignOutSwitch

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
private void configureSignOutSwitch() {
    boolean hasChildAccount = ChildAccountService.getInstance(getActivity()).hasChildAccount();

    ChromeSwitchPreference signOutSwitch =
            (ChromeSwitchPreference) findPreference(PREF_SIGN_OUT_SWITCH);
    if (hasChildAccount) {
        getPreferenceScreen().removePreference(signOutSwitch);
    } else {
        getPreferenceScreen().removePreference(findPreference(PREF_SIGN_IN_CHILD_MESSAGE));
        signOutSwitch.setChecked(true);
        signOutSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (!isVisible() || !isResumed()) return false;
                if ((boolean) newValue) return true;

                if (ChromeSigninController.get(getActivity()).isSignedIn()
                        && getSignOutAllowedPreferenceValue(getActivity())) {
                    AccountManagementScreenHelper.logEvent(
                            ProfileAccountManagementMetrics.TOGGLE_SIGNOUT,
                            mGaiaServiceType);

                    SignOutDialogFragment signOutFragment = new SignOutDialogFragment();
                    signOutFragment.setTargetFragment(AccountManagementFragment.this, 0);
                    signOutFragment.show(getFragmentManager(), SIGN_OUT_DIALOG_TAG);
                }

                // Return false to prevent the switch from updating. The
                // AccountManagementFragment is hidden when the user signs out of Chrome, so the
                // switch never actually needs to be updated.
                return false;
            }
        });
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:36,代码来源:AccountManagementFragment.java


示例19: onSignOutClicked

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
@Override
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(getActivity()).isSignedIn()) return;

    SigninManager.get(getActivity()).signOut(getActivity(), null);
    AccountManagementScreenHelper.logEvent(
            ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT,
            mGaiaServiceType);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:12,代码来源:AccountManagementFragment.java


示例20: getSyncStatusSummary

import org.chromium.sync.signin.ChromeSigninController; //导入依赖的package包/类
private static String getSyncStatusSummary(Activity activity) {
    if (!ChromeSigninController.get(activity).isSignedIn()) return "";

    ProfileSyncService profileSyncService = ProfileSyncService.get();
    Resources res = activity.getResources();

    if (ChildAccountService.getInstance(activity).hasChildAccount()) {
        return res.getString(R.string.kids_account);
    }

    if (!AndroidSyncSettings.isMasterSyncEnabled(activity)) {
        return res.getString(R.string.sync_android_master_sync_disabled);
    }

    if (profileSyncService.getAuthError() != GoogleServiceAuthError.State.NONE) {
        return res.getString(profileSyncService.getAuthError().getMessage());
    }

    if (AndroidSyncSettings.isSyncEnabled(activity)) {
        if (!profileSyncService.isSyncInitialized()) {
            return res.getString(R.string.sync_setup_progress);
        }

        if (profileSyncService.isPassphraseRequiredForDecryption()) {
            return res.getString(R.string.sync_need_passphrase);
        }
    }

    return AndroidSyncSettings.isSyncEnabled(activity)
            ? res.getString(R.string.sync_is_enabled)
            : res.getString(R.string.sync_is_disabled);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:33,代码来源:AccountManagementFragment.java



注:本文中的org.chromium.sync.signin.ChromeSigninController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MediaRouteDescriptor类代码示例发布时间:2022-05-23
下一篇:
Java ValueSpecification类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap