Java Code Examples for org.chromium.chrome.browser.IntentHandler#determineExternalIntentSource()
The following examples show how to use
org.chromium.chrome.browser.IntentHandler#determineExternalIntentSource() .
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: CustomTabActivity.java From delion with Apache License 2.0 | 6 votes |
@Override public void onStartWithNative() { super.onStartWithNative(); setActiveContentHandler(mCustomTabContentHandler); if (getSavedInstanceState() != null || !mIsInitialStart) { RecordUserAction.record("CustomTabs.StartedReopened"); } else { ExternalAppId externalId = IntentHandler.determineExternalIntentSource(getPackageName(), getIntent()); RecordHistogram.recordEnumeratedHistogram("CustomTabs.ClientAppId", externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal()); RecordUserAction.record("CustomTabs.StartedInitially"); } mIsInitialStart = false; }
Example 2
Source File: FirstRunFlowSequencer.java From delion with Apache License 2.0 | 5 votes |
/** * Checks if the First Run needs to be launched. * @return The intent to launch the First Run Experience if necessary, or null. * @param context The context. * @param fromIntent The intent that was used to launch Chrome. It contains the information of * the client to launch different types of the First Run Experience. */ public static Intent checkIfFirstRunIsNecessary(Context context, Intent fromIntent) { // If FRE is disabled (e.g. in tests), proceed directly to the intent handling. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)) { return null; } // If Chrome isn't opened via the Chrome icon, and the user accepted the ToS // in the Setup Wizard, skip any First Run Experience screens and proceed directly // to the intent handling. final boolean fromChromeIcon = fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN); if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null; final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete(context); if (!baseFreComplete) { // Show full First Run Experience if Chrome is opened via Chrome icon or GSA (Google // Search App). if (fromChromeIcon || (fromIntent != null && IntentHandler.determineExternalIntentSource( context.getPackageName(), fromIntent) == ExternalAppId.GSA)) { return createGenericFirstRunIntent(context, fromChromeIcon); } // Show lightweight First Run Experience if the user has not accepted the ToS. if (!FirstRunStatus.shouldSkipWelcomePage(context) && !FirstRunStatus.getLightweightFirstRunFlowComplete(context)) { return createLightweightFirstRunIntent(context, fromChromeIcon); } } // Promo pages are removed, so there is nothing else to show in FRE. return null; }
Example 3
Source File: ChromeLauncherActivity.java From delion with Apache License 2.0 | 5 votes |
/** * Records metrics gleaned from the Intent. */ private void recordIntentMetrics() { Intent intent = getIntent(); IntentHandler.ExternalAppId source = IntentHandler.determineExternalIntentSource(getPackageName(), intent); if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) { int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT; int maskedFlags = intent.getFlags() & flagsOfInterest; sIntentFlagsHistogram.record(maskedFlags); } MediaNotificationUma.recordClickSource(intent); }
Example 4
Source File: CustomTabActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onResumeWithNative() { super.onResumeWithNative(); if (getSavedInstanceState() != null || !mIsInitialResume) { if (mIntentDataProvider.isOpenedByChrome()) { RecordUserAction.record("ChromeGeneratedCustomTab.StartedReopened"); } else { RecordUserAction.record("CustomTabs.StartedReopened"); } } else { SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); String lastUrl = preferences.getString(LAST_URL_PREF, null); if (lastUrl != null && lastUrl.equals(getUrlToLoad())) { RecordUserAction.record("CustomTabsMenuOpenSameUrl"); } else { preferences.edit().putString(LAST_URL_PREF, getUrlToLoad()).apply(); } if (mIntentDataProvider.isOpenedByChrome()) { RecordUserAction.record("ChromeGeneratedCustomTab.StartedInitially"); } else { ExternalAppId externalId = IntentHandler.determineExternalIntentSource(getPackageName(), getIntent()); RecordHistogram.recordEnumeratedHistogram("CustomTabs.ClientAppId", externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal()); RecordUserAction.record("CustomTabs.StartedInitially"); } } mIsInitialResume = false; }
Example 5
Source File: CustomTabsConnectionService.java From AndroidChromium with Apache License 2.0 | 5 votes |
private boolean isFirstRunDone() { if (mBindIntent == null) return true; boolean showLightweightFre = IntentHandler.determineExternalIntentSource(this.getPackageName(), mBindIntent) != ExternalAppId.GSA; boolean firstRunNecessary = FirstRunFlowSequencer.checkIfFirstRunIsNecessary( getApplicationContext(), mBindIntent, showLightweightFre) != null; if (!firstRunNecessary) { mBindIntent = null; return true; } return false; }
Example 6
Source File: ChromeLauncherActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Records metrics gleaned from the Intent. */ private void recordIntentMetrics() { Intent intent = getIntent(); IntentHandler.ExternalAppId source = IntentHandler.determineExternalIntentSource(getPackageName(), intent); if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) { int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT; int maskedFlags = intent.getFlags() & flagsOfInterest; sIntentFlagsHistogram.record(maskedFlags); } MediaNotificationUma.recordClickSource(intent); }
Example 7
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onResumeWithNative() { super.onResumeWithNative(); if (getSavedInstanceState() != null || !mIsInitialResume) { if (mIntentDataProvider.isOpenedByChrome()) { RecordUserAction.record("ChromeGeneratedCustomTab.StartedReopened"); } else { RecordUserAction.record("CustomTabs.StartedReopened"); } } else { SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); String lastUrl = preferences.getString(LAST_URL_PREF, null); if (lastUrl != null && lastUrl.equals(getUrlToLoad())) { RecordUserAction.record("CustomTabsMenuOpenSameUrl"); } else { preferences.edit().putString(LAST_URL_PREF, getUrlToLoad()).apply(); } if (mIntentDataProvider.isOpenedByChrome()) { RecordUserAction.record("ChromeGeneratedCustomTab.StartedInitially"); } else { ExternalAppId externalId = IntentHandler.determineExternalIntentSource(getPackageName(), getIntent()); RecordHistogram.recordEnumeratedHistogram("CustomTabs.ClientAppId", externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal()); RecordUserAction.record("CustomTabs.StartedInitially"); } } mIsInitialResume = false; }
Example 8
Source File: CustomTabsConnectionService.java From 365browser with Apache License 2.0 | 5 votes |
private boolean isFirstRunDone() { if (mBindIntent == null) return true; boolean showLightweightFre = IntentHandler.determineExternalIntentSource(this.getPackageName(), mBindIntent) != ExternalAppId.GSA; boolean firstRunNecessary = FirstRunFlowSequencer.checkIfFirstRunIsNecessary( getApplicationContext(), mBindIntent, showLightweightFre) != null; if (!firstRunNecessary) { mBindIntent = null; return true; } return false; }
Example 9
Source File: ChromeLauncherActivity.java From 365browser with Apache License 2.0 | 5 votes |
/** * Records metrics gleaned from the Intent. */ private void recordIntentMetrics() { Intent intent = getIntent(); IntentHandler.ExternalAppId source = IntentHandler.determineExternalIntentSource(getPackageName(), intent); if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) { int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT; int maskedFlags = intent.getFlags() & flagsOfInterest; sIntentFlagsHistogram.record(maskedFlags); } MediaNotificationUma.recordClickSource(intent); }
Example 10
Source File: FirstRunSignInProcessor.java From delion with Apache License 2.0 | 4 votes |
/** * Initiates the automatic sign-in process in background. * * @param activity The context for the FRE parameters processor. */ public static void start(final Activity activity) { SigninManager signinManager = SigninManager.get(activity.getApplicationContext()); signinManager.onFirstRunCheckDone(); boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete(activity); // We skip signin and the FRE only if // - FRE is disabled, or // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || (!firstRunFlowComplete && ToSAckedReceiver.checkAnyUserHasSeenToS(activity))) { return; } // Skip sign in if Chrome is neither started via Chrome icon nor GSA (Google Search App). if (!TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN) && IntentHandler.determineExternalIntentSource( activity.getPackageName(), activity.getIntent()) != ExternalAppId.GSA) { return; } // Otherwise, force trigger the FRE. if (!firstRunFlowComplete) { requestToFireIntentAndFinish(activity); return; } // We are only processing signin from the FRE. if (getFirstRunFlowSignInComplete(activity)) { return; } final String accountName = getFirstRunFlowSignInAccountName(activity); if (!FeatureUtilities.canAllowSync(activity) || !signinManager.isSignInAllowed() || TextUtils.isEmpty(accountName)) { setFirstRunFlowSignInComplete(activity, true); return; } final boolean setUp = getFirstRunFlowSignInSetup(activity); signinManager.signIn(accountName, activity, new SignInCallback() { @Override public void onSignInComplete() { // Show sync settings if user pressed the "Settings" button. if (setUp) { openSignInSettings(activity); } setFirstRunFlowSignInComplete(activity, true); } @Override public void onSignInAborted() { // Set FRE as complete even if signin fails because the user has already seen and // accepted the terms of service. setFirstRunFlowSignInComplete(activity, true); } }); }
Example 11
Source File: FirstRunSignInProcessor.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Initiates the automatic sign-in process in background. * * @param activity The context for the FRE parameters processor. */ public static void start(final Activity activity) { SigninManager signinManager = SigninManager.get(activity.getApplicationContext()); signinManager.onFirstRunCheckDone(); boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete(); // We skip signin and the FRE if // - FRE is disabled, or // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(activity) || (!firstRunFlowComplete && ToSAckedReceiver.checkAnyUserHasSeenToS(activity))) { return; } // Force trigger the FRE if the Lightweight FRE is disabled or Chrome is started via Chrome // icon or via intent from GSA. Otherwise, skip signin. if (!firstRunFlowComplete) { if (!CommandLine.getInstance().hasSwitch( ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE) || TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN) || IntentHandler.determineExternalIntentSource( activity.getPackageName(), activity.getIntent()) == ExternalAppId.GSA) { requestToFireIntentAndFinish(activity); } return; } // We are only processing signin from the FRE. if (getFirstRunFlowSignInComplete(activity)) { return; } final String accountName = getFirstRunFlowSignInAccountName(activity); if (!FeatureUtilities.canAllowSync(activity) || !signinManager.isSignInAllowed() || TextUtils.isEmpty(accountName)) { setFirstRunFlowSignInComplete(activity, true); return; } final boolean setUp = getFirstRunFlowSignInSetup(activity); signinManager.signIn(accountName, activity, new SignInCallback() { @Override public void onSignInComplete() { // Show sync settings if user pressed the "Settings" button. if (setUp) { openSignInSettings(activity); } setFirstRunFlowSignInComplete(activity, true); } @Override public void onSignInAborted() { // Set FRE as complete even if signin fails because the user has already seen and // accepted the terms of service. setFirstRunFlowSignInComplete(activity, true); } }); }
Example 12
Source File: ChromeLauncherActivity.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Tries to launch the First Run Experience. If ChromeLauncherActivity is running with the * wrong Intent flags, we instead relaunch ChromeLauncherActivity to make sure it runs in its * own task, which then triggers First Run. * @return Whether or not the First Run Experience needed to be shown. * @param forTabbedMode Whether the First Run Experience is launched for tabbed mode. */ private boolean launchFirstRunExperience(boolean forTabbedMode) { // Tries to launch the Generic First Run Experience for intent from GSA. boolean showLightweightFre = IntentHandler.determineExternalIntentSource(this.getPackageName(), getIntent()) != ExternalAppId.GSA; Intent freIntent = FirstRunFlowSequencer.checkIfFirstRunIsNecessary( this, getIntent(), showLightweightFre); if (freIntent == null) return false; if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { if (CommandLine.getInstance().hasSwitch( ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) { boolean isTabbedModeActive = false; boolean isLightweightFreActive = false; boolean isGenericFreActive = false; List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities(); for (WeakReference<Activity> weakActivity : activities) { Activity activity = weakActivity.get(); if (activity == null) { continue; } if (activity instanceof ChromeTabbedActivity) { isTabbedModeActive = true; continue; } if (activity instanceof LightweightFirstRunActivity) { isLightweightFreActive = true; // A Generic or a new Lightweight First Run Experience will be launched // below, so finish the old Lightweight First Run Experience. activity.setResult(Activity.RESULT_CANCELED); activity.finish(); continue; } if (activity instanceof FirstRunActivity) { isGenericFreActive = true; continue; } } if (forTabbedMode) { if (isTabbedModeActive || isLightweightFreActive || !showLightweightFre) { // Lets ChromeTabbedActivity checks and launches the Generic First Run // Experience. launchTabbedMode(false); finish(); return true; } } else if (isGenericFreActive) { // Launch the Generic First Run Experience if it is active previously. freIntent = FirstRunFlowSequencer.createGenericFirstRunIntent( this, TextUtils.equals(getIntent().getAction(), Intent.ACTION_MAIN)); } } // Add a PendingIntent so that the intent used to launch Chrome will be resent when // first run is completed or canceled. FirstRunFlowSequencer.addPendingIntent(this, freIntent, getIntent()); freIntent.putExtra(FirstRunActivity.EXTRA_FINISH_ON_TOUCH_OUTSIDE, !forTabbedMode); startActivity(freIntent); } else { Intent newIntent = new Intent(getIntent()); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(newIntent); } finish(); return true; }
Example 13
Source File: FirstRunSignInProcessor.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initiates the automatic sign-in process in background. * * @param activity The context for the FRE parameters processor. */ public static void start(final Activity activity) { SigninManager signinManager = SigninManager.get(activity.getApplicationContext()); signinManager.onFirstRunCheckDone(); boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete(); // We skip signin and the FRE if // - FRE is disabled, or // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(activity) || (!firstRunFlowComplete && ToSAckedReceiver.checkAnyUserHasSeenToS(activity))) { return; } // Force trigger the FRE if the Lightweight FRE is disabled or Chrome is started via Chrome // icon or via intent from GSA. Otherwise, skip signin. if (!firstRunFlowComplete) { if (!CommandLine.getInstance().hasSwitch( ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE) || TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN) || IntentHandler.determineExternalIntentSource( activity.getPackageName(), activity.getIntent()) == ExternalAppId.GSA) { requestToFireIntentAndFinish(activity); } return; } // We are only processing signin from the FRE. if (getFirstRunFlowSignInComplete(activity)) { return; } final String accountName = getFirstRunFlowSignInAccountName(activity); if (!FeatureUtilities.canAllowSync(activity) || !signinManager.isSignInAllowed() || TextUtils.isEmpty(accountName)) { setFirstRunFlowSignInComplete(activity, true); return; } final boolean setUp = getFirstRunFlowSignInSetup(activity); signinManager.signIn(accountName, activity, new SignInCallback() { @Override public void onSignInComplete() { // Show sync settings if user pressed the "Settings" button. if (setUp) { openSignInSettings(activity); } setFirstRunFlowSignInComplete(activity, true); } @Override public void onSignInAborted() { // Set FRE as complete even if signin fails because the user has already seen and // accepted the terms of service. setFirstRunFlowSignInComplete(activity, true); } }); }
Example 14
Source File: FirstRunFlowSequencer.java From 365browser with Apache License 2.0 | 4 votes |
/** * Tries to launch the First Run Experience. If the Activity was launched with the wrong Intent * flags, we first relaunch it to make sure it runs in its own task, then trigger First Run. * * @param caller Activity instance that is checking if first run is necessary. * @param intent Intent used to launch the caller. * @param requiresBroadcast Whether or not the Intent triggers a BroadcastReceiver. * @return Whether startup must be blocked (e.g. via Activity#finish or dropping the Intent). */ public static boolean launch(Context caller, Intent intent, boolean requiresBroadcast) { // Check if the user just came back from the FRE. boolean firstRunActivityResult = IntentUtils.safeGetBooleanExtra( intent, FirstRunActivity.EXTRA_FIRST_RUN_ACTIVITY_RESULT, false); boolean firstRunComplete = IntentUtils.safeGetBooleanExtra( intent, FirstRunActivity.EXTRA_FIRST_RUN_COMPLETE, false); if (firstRunActivityResult && !firstRunComplete) { Log.d(TAG, "User failed to complete the FRE. Aborting"); return true; } // Tries to launch the Generic First Run Experience for intent from GSA. boolean showLightweightFre = IntentHandler.determineExternalIntentSource(caller.getPackageName(), intent) != ExternalAppId.GSA; // Check if the user needs to go through First Run at all. Intent freIntent = checkIfFirstRunIsNecessary(caller, intent, showLightweightFre); if (freIntent == null) return false; Log.d(TAG, "Redirecting user through FRE."); if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { if (CommandLine.getInstance().hasSwitch( ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) { boolean isGenericFreActive = false; List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities(); for (WeakReference<Activity> weakActivity : activities) { Activity activity = weakActivity.get(); if (activity == null) { continue; } else if (activity instanceof LightweightFirstRunActivity) { // A Generic or a new Lightweight First Run Experience will be launched // below, so finish the old Lightweight First Run Experience. activity.setResult(Activity.RESULT_CANCELED); activity.finish(); continue; } else if (activity instanceof FirstRunActivity) { isGenericFreActive = true; continue; } } if (isGenericFreActive) { // Launch the Generic First Run Experience if it was previously active. freIntent = createGenericFirstRunIntent( caller, TextUtils.equals(intent.getAction(), Intent.ACTION_MAIN)); } } // Add a PendingIntent so that the intent used to launch Chrome will be resent when // First Run is completed or canceled. addPendingIntent(caller, freIntent, intent, requiresBroadcast); freIntent.putExtra(FirstRunActivity.EXTRA_FINISH_ON_TOUCH_OUTSIDE, true); if (!(caller instanceof Activity)) freIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); IntentUtils.safeStartActivity(caller, freIntent); } else { // First Run requires that the Intent contains NEW_TASK so that it doesn't sit on top // of something else. Intent newIntent = new Intent(intent); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); IntentUtils.safeStartActivity(caller, newIntent); } return true; }