org.chromium.chrome.browser.metrics.ActivityStopMetrics Java Examples

The following examples show how to use org.chromium.chrome.browser.metrics.ActivityStopMetrics. 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: ChromeTabbedActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Opens a new Tab with the possibility of showing it in a Custom Tab, instead.
 *
 * See IntentHandler#processUrlViewIntent() for an explanation most of the parameters.
 * @param forceNewTab If not handled by a Custom Tab, forces the new tab to be created.
 */
private void openNewTab(String url, String referer, String headers,
        String externalAppId, Intent intent, boolean forceNewTab) {
    boolean isAllowedToReturnToExternalApp = IntentUtils.safeGetBooleanExtra(intent,
            ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);

    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (isAllowedToReturnToExternalApp
            && ChromeLauncherActivity.canBeHijackedByHerb(intent)
            && TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DILL, herbFlavor)) {
        Log.d(TAG, "Sending to CustomTabActivity");
        mActivityStopMetrics.setStopReason(
                ActivityStopMetrics.STOP_REASON_CUSTOM_TAB_STARTED);

        Intent newIntent = ChromeLauncherActivity.createCustomTabActivityIntent(
                ChromeTabbedActivity.this, intent, false);
        newIntent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
        newIntent.putExtra(
                CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
        ChromeLauncherActivity.updateHerbIntent(ChromeTabbedActivity.this,
                newIntent, Uri.parse(IntentHandler.getUrlFromIntent(newIntent)));

        // Launch the Activity on top of this task.
        int updatedFlags = newIntent.getFlags();
        updatedFlags &= ~Intent.FLAG_ACTIVITY_NEW_TASK;
        updatedFlags &= ~Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        newIntent.setFlags(updatedFlags);
        startActivityForResult(newIntent, CCT_RESULT);
    } else {
        // Create a new tab.
        Tab newTab =
                launchIntent(url, referer, headers, externalAppId, forceNewTab, intent);
        newTab.setIsAllowedToReturnToExternalApp(isAllowedToReturnToExternalApp);
        RecordUserAction.record("MobileReceivedExternalIntent");
    }
}
 
Example #2
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onActivityResultWithNative(int requestCode, int resultCode, Intent data) {
    if (super.onActivityResultWithNative(requestCode, resultCode, data)) return true;

    if (requestCode == FIRST_RUN_EXPERIENCE_RESULT) {
        mIsOnFirstRun = false;
        if (resultCode == RESULT_OK) {
            refreshSignIn();
        } else {
            if (data != null && data.getBooleanExtra(
                    FirstRunActivity.RESULT_CLOSE_APP, false)) {
                getTabModelSelector().closeAllTabs(true);
                finish();
            } else {
                launchFirstRunExperience();
            }
        }
        return true;
    } else if (requestCode == CCT_RESULT) {
        Log.d(TAG, "Custom Tab result: " + resultCode);
        if (resultCode == CustomTabActivity.RESULT_STOPPED && data != null) {
            // Open the last URL shown in the CustomTabActivity.  Unfortunately, there isn't a
            // good TabLaunchType to use here (FROM_EXTERNAL_APP changes back behavior, e.g.),
            // but this shouldn't be a problem once Tab reparenting lands.
            //
            // TODO(dfalcantara): Use real tab reparenting here when possible.  We should fall
            //                    back to using the TabState file or URL, in that order.
            getTabCreator(false).createNewTab(new LoadUrlParams(
                    data.getDataString()), TabLaunchType.FROM_CHROME_UI, null);
        } else if ((resultCode == CustomTabActivity.RESULT_BACK_PRESSED
                || resultCode == CustomTabActivity.RESULT_CLOSED) && data != null) {
            // Herb UMA should have already been recorded by the CustomTabActivity.
            Log.d(TAG, "Herb: Sending app to the background");
            mActivityStopMetrics.setStopReason(
                    ActivityStopMetrics.STOP_REASON_CUSTOM_TAB_STOPPED);
            sendToBackground(null);
        }
        return true;
    }
    return false;
}
 
Example #3
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a ChromeTabbedActivity.
 */
public ChromeTabbedActivity() {
    mActivityStopMetrics = new ActivityStopMetrics();
    mMainIntentMetrics = new MainIntentBehaviorMetrics(this);
    mAppIndexingUtil = new AppIndexingUtil();
}