org.chromium.chrome.browser.signin.SigninHelper Java Examples

The following examples show how to use org.chromium.chrome.browser.signin.SigninHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountsChangedReceiver.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, final Intent intent) {
    final Context appContext = context.getApplicationContext();
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            SigninHelper.updateAccountRenameData(appContext);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            continueHandleAccountChangeIfNeeded(appContext, intent);
        }
    };
    task.execute();
}
 
Example #2
Source File: AccountsChangedReceiver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, final Intent intent) {
    final Context appContext = context.getApplicationContext();
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            SigninHelper.updateAccountRenameData(appContext);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            continueHandleAccountChangeIfNeeded(appContext, intent);
        }
    };
    task.execute();
}
 
Example #3
Source File: AccountsChangedReceiver.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, final Intent intent) {
    if (!AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) return;

    final Context appContext = context.getApplicationContext();
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            SigninHelper.updateAccountRenameData(appContext);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            continueHandleAccountChangeIfNeeded(appContext);
        }
    };
    task.execute();
}
 
Example #4
Source File: GoogleServicesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
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");
    }
}
 
Example #5
Source File: GoogleServicesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called once during initialization and then again for every start (warm-start).
 * Responsible for checking if configuration has changed since Chrome was last launched
 * and updates state accordingly.
 */
public void onMainActivityStart() {
    try {
        TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
        boolean accountsChanged = SigninHelper.checkAndClearAccountsChangedPref(mContext);
        mSigninHelper.validateAccountSettings(accountsChanged);
    } finally {
        TraceEvent.end("GoogleServicesManager.onMainActivityStart");
    }
}
 
Example #6
Source File: AccountsChangedReceiver.java    From delion with Apache License 2.0 5 votes vote down vote up
private void continueHandleAccountChangeIfNeeded(final Context context, final Intent intent) {
    if (!AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) return;

    AccountTrackerService.get(context).invalidateAccountSeedStatus(
            false /* don't refresh right now */);
    boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
    if (isChromeVisible) {
        startBrowserIfNeededAndValidateAccounts(context);
    } else {
        // Notify SigninHelper of changed accounts (via shared prefs).
        SigninHelper.markAccountsChangedPref(context);
    }
    notifyAccountsChangedOnBrowserStartup(context, intent);
}
 
Example #7
Source File: AccountsChangedReceiver.java    From delion with Apache License 2.0 5 votes vote down vote up
@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}
 
Example #8
Source File: GoogleServicesManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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");
    }
}
 
Example #9
Source File: GoogleServicesManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Called once during initialization and then again for every start (warm-start).
 * Responsible for checking if configuration has changed since Chrome was last launched
 * and updates state accordingly.
 */
public void onMainActivityStart() {
    try {
        TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
        boolean accountsChanged = SigninHelper.checkAndClearAccountsChangedPref(mContext);
        mSigninHelper.validateAccountSettings(accountsChanged);
    } finally {
        TraceEvent.end("GoogleServicesManager.onMainActivityStart");
    }
}
 
Example #10
Source File: AccountsChangedReceiver.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void continueHandleAccountChangeIfNeeded(final Context context, final Intent intent) {
    if (!AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) return;

    AccountTrackerService.get(context).invalidateAccountSeedStatus(
            false /* don't refresh right now */);
    boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
    if (isChromeVisible) {
        startBrowserIfNeededAndValidateAccounts(context);
    } else {
        // Notify SigninHelper of changed accounts (via shared prefs).
        SigninHelper.markAccountsChangedPref(context);
    }
    notifyAccountsChangedOnBrowserStartup(context, intent);
}
 
Example #11
Source File: AccountsChangedReceiver.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}
 
Example #12
Source File: GoogleServicesManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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();
        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");
    }
}
 
Example #13
Source File: GoogleServicesManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called once during initialization and then again for every start (warm-start).
 * Responsible for checking if configuration has changed since Chrome was last launched
 * and updates state accordingly.
 */
public void onMainActivityStart() {
    try {
        TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
        boolean accountsChanged = SigninHelper.checkAndClearAccountsChangedPref(mContext);
        mSigninHelper.validateAccountSettings(accountsChanged);
    } finally {
        TraceEvent.end("GoogleServicesManager.onMainActivityStart");
    }
}
 
Example #14
Source File: AccountsChangedReceiver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void continueHandleAccountChangeIfNeeded(final Context context) {
    AccountTrackerService.get().invalidateAccountSeedStatus(
            false /* don't refresh right now */);
    boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
    if (isChromeVisible) {
        startBrowserIfNeededAndValidateAccounts(context);
    } else {
        // Notify SigninHelper of changed accounts (via shared prefs).
        SigninHelper.markAccountsChangedPref(context);
    }
    notifyAccountsChangedOnBrowserStartup(context);
}
 
Example #15
Source File: AccountsChangedReceiver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}