Ejemplo n.º 1
0
 @VisibleForTesting
 protected boolean isSyncAllowed() {
   SigninManager signinManager = SigninManager.get(mActivity.getApplicationContext());
   return FeatureUtilities.canAllowSync(mActivity)
       && !signinManager.isSigninDisabledByPolicy()
       && signinManager.isSigninSupported();
 }
  /**
   * Determine whether the sync promo needs to be displayed.
   *
   * @return Whether sync promo should be displayed.
   */
  public boolean shouldDisplaySyncPromo() {
    if (SigninManager.get(mContext).isSigninDisabledByPolicy()) {
      return false;
    }

    if (ContextUtils.getAppSharedPreferences().getBoolean(PREF_SIGNIN_PROMO_DECLINED, false)) {
      return false;
    }

    return !AndroidSyncSettings.isSyncEnabled(mContext) || mForeignSessions.isEmpty();
  }
  /**
   * 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();
  }