org.chromium.chrome.browser.util.FeatureUtilities Java Examples

The following examples show how to use org.chromium.chrome.browser.util.FeatureUtilities. 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: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent.
 */
private boolean isHerbIntent() {
    if (!canBeHijackedByHerb(getIntent())) return false;

    // Different Herb flavors handle incoming intents differently.
    String flavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(flavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) {
        return false;
    } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        return IntentUtils.safeGetBooleanExtra(getIntent(),
                ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);
    } else {
        // Legacy Herb Flavors might hit this path before the caching logic corrects it, so
        // treat this as disabled.
        return false;
    }
}
 
Example #2
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe(
                       FeatureUtilities.isDocumentMode(mHost.getContext()))
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    boolean isAccessibility =
            DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext());
    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT
            || (direction == ScrollDirection.DOWN && mOverviewLayout != null
                       && !isAccessibility);
}
 
Example #3
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartWithNative() {
    super.onStartWithNative();
    UpdateMenuItemHelper.getInstance().onStart();
    getChromeApplication().onStartWithNative();
    FeatureUtilities.setDocumentModeEnabled(FeatureUtilities.isDocumentMode(this));

    if (GSAState.getInstance(this).isGsaAvailable()) {
        mGSAServiceClient = new GSAServiceClient(this);
        mGSAServiceClient.connect();
        createContextReporterIfNeeded();
    } else {
        ContextReporter.reportStatus(ContextReporter.STATUS_GSA_NOT_AVAILABLE);
    }
    mCompositorViewHolder.resetFlags();

    // postDeferredStartupIfNeeded() is called in TabModelSelectorTabObsever#onLoadStopped(),
    // #onPageLoadFinished() and #onCrash(). If we are not actively loading a tab (e.g.
    // in Android N multi-instance, which is created by re-parenting an existing tab),
    // ensure onDeferredStartup() gets called by calling postDeferredStartupIfNeeded() here.
    if (getActivityTab() == null || !getActivityTab().isLoading()) {
        postDeferredStartupIfNeeded();
    }
}
 
Example #4
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }
}
 
Example #5
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onResumeWithNative() {
    super.onResumeWithNative();

    CookiesFetcher.restoreCookies(this);
    StartupMetrics.getInstance().recordHistogram(false);

    if (FeatureUtilities.isTabModelMergingEnabled()) {
        boolean inMultiWindowMode = MultiWindowUtils.getInstance().isInMultiWindowMode(this);
        // Merge tabs if the activity is not in multi-window mode and mMergeTabsOnResume is true
        // or unset because the activity is just starting or was destroyed.
        if (!inMultiWindowMode && (mMergeTabsOnResume == null || mMergeTabsOnResume)) {
            maybeMergeTabs();
        }
        mMergeTabsOnResume = false;
    }
    mVrShellDelegate.maybeResumeVR();

    mLocaleManager.setSnackbarManager(getSnackbarManager());
    mLocaleManager.startObservingPhoneChanges();
}
 
Example #6
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }

    super.onMultiWindowModeChanged(isInMultiWindowMode);
}
 
Example #7
Source File: ChromeLauncherActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent.
 */
private boolean isHerbIntent() {
    if (!canBeHijackedByHerb(getIntent())) return false;

    // Different Herb flavors handle incoming intents differently.
    String flavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(flavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) {
        return false;
    } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        return IntentUtils.safeGetBooleanExtra(getIntent(),
                ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);
    } else {
        // Legacy Herb Flavors might hit this path before the caching logic corrects it, so
        // treat this as disabled.
        return false;
    }
}
 
Example #8
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        if (tab.isIncognito()) {
            return new ChromeHomeIncognitoNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        } else {
            return new ChromeHomeNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        }
    } else if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, new TabShim(tab), tabModelSelector);
    }
}
 
Example #9
Source File: Tab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @param manager The fullscreen manager that should be notified of changes to this tab (if
 *                set to null, no more updates will come from this tab).
 */
public void setFullscreenManager(FullscreenManager manager) {
    mFullscreenManager = manager;
    if (mFullscreenManager != null) {
        boolean topOffsetsInitialized = !Float.isNaN(mPreviousTopControlsOffsetY)
                && !Float.isNaN(mPreviousContentOffsetY);
        boolean bottomOffsetsInitialized =
                !Float.isNaN(mPreviousBottomControlsOffsetY);
        boolean isChromeHomeEnabled = FeatureUtilities.isChromeHomeEnabled();

        // Make sure the dominant control offsets have been set.
        if ((!topOffsetsInitialized && !isChromeHomeEnabled)
                || (!bottomOffsetsInitialized && isChromeHomeEnabled)) {
            mFullscreenManager.setPositionsForTabToNonFullscreen();
        } else {
            mFullscreenManager.setPositionsForTab(mPreviousTopControlsOffsetY,
                    mPreviousBottomControlsOffsetY,
                    mPreviousContentOffsetY);
        }
        updateFullscreenEnabledState();
    }
}
 
Example #10
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onResumeWithNative() {
    super.onResumeWithNative();
    markSessionResume();
    RecordUserAction.record("MobileComeToForeground");

    if (getActivityTab() != null) {
        LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents());
    }
    ContentViewCore cvc = getContentViewCore();
    if (cvc != null) cvc.onResume();
    FeatureUtilities.setCustomTabVisible(isCustomTab());
    FeatureUtilities.setIsInMultiWindowMode(
            MultiWindowUtils.getInstance().isInMultiWindowMode(this));

    VideoPersister.getInstance().cleanup(this);
    VrShellDelegate.maybeRegisterVrEntryHook(this);
}
 
Example #11
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }

    super.onMultiWindowModeChanged(isInMultiWindowMode);
}
 
Example #12
Source File: StackLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onTabCreated(long time, int id, int tabIndex, int sourceId, boolean newIsIncognito,
        boolean background, float originX, float originY) {
    super.onTabCreated(
            time, id, tabIndex, sourceId, newIsIncognito, background, originX, originY);
    startHiding(id, false);
    mStacks[getTabStackIndex(id)].tabCreated(time, id);
    startMarginAnimation(false);
    uiPreemptivelySelectTabModel(newIsIncognito);

    // TODO(twellington): Add a proper tab creation animation rather than disabling the current
    //                    animation.
    if (FeatureUtilities.isChromeHomeEnabled()) {
        onUpdateAnimation(System.currentTimeMillis(), true);
    }
}
 
Example #13
Source File: BottomSheet.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the sheet can be moved. It cannot be moved when the activity is in overview
 * mode, when "find in page" is visible, or when the toolbar is hidden.
 */
private boolean canMoveSheet() {
    boolean isInOverviewMode = mTabModelSelector != null
            && (mTabModelSelector.getCurrentTab() == null
                       || mTabModelSelector.getCurrentTab().getActivity().isInOverviewMode());

    // If the expand button is enabled, do not allow swiping when the sheet is in the peeking
    // position.
    boolean blockPeekingSwipes = FeatureUtilities.isChromeHomeExpandButtonEnabled()
            && getSheetState() == SHEET_STATE_PEEK;

    if (mFindInPageView == null) mFindInPageView = findViewById(R.id.find_toolbar);
    boolean isFindInPageVisible =
            mFindInPageView != null && mFindInPageView.getVisibility() == View.VISIBLE;

    return !isToolbarAndroidViewHidden()
            && (!isInOverviewMode || mNtpController.isShowingNewTabUi()) && !isFindInPageVisible
            && !blockPeekingSwipes;
}
 
Example #14
Source File: LayoutManagerDocument.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !FeatureUtilities.isDocumentModeEligible(mHost.getContext())
            || !DeviceClassManager.enableToolbarSwipe(
                       FeatureUtilities.isDocumentMode(mHost.getContext()))
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #15
Source File: ForcedSigninProcessor.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Processes the fully automatic non-FRE-related forced sign-in.
 * This is used to enforce the environment for Android EDU and child accounts.
 */
private static void processForcedSignIn(
        final Context appContext, @Nullable final Runnable onComplete) {
    final SigninManager signinManager = SigninManager.get(appContext);
    // By definition we have finished all the checks for first run.
    signinManager.onFirstRunCheckDone();
    if (!FeatureUtilities.canAllowSync(appContext) || !signinManager.isSignInAllowed()) {
        Log.d(TAG, "Sign in disallowed");
        return;
    }
    AccountManagerHelper.get().getGoogleAccounts(new Callback<Account[]>() {
        @Override
        public void onResult(Account[] accounts) {
            if (accounts.length != 1) {
                Log.d(TAG, "Incorrect number of accounts (%d)", accounts.length);
                return;
            }
            signinManager.signIn(accounts[0], null, new SigninManager.SignInCallback() {
                @Override
                public void onSignInComplete() {
                    // Since this is a forced signin, signout is not allowed.
                    AccountManagementFragment.setSignOutAllowedPreferenceValue(false);
                    if (onComplete != null) {
                        onComplete.run();
                    }
                }

                @Override
                public void onSignInAborted() {
                    if (onComplete != null) {
                        onComplete.run();
                    }
                }
            });
        }
    });
}
 
Example #16
Source File: SelectableListLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void setEmptyOrLoadingViewStyle(View view) {
    if (!FeatureUtilities.isChromeHomeEnabled()) return;

    ((FrameLayout.LayoutParams) view.getLayoutParams()).gravity = Gravity.CENTER_HORIZONTAL;
    ApiCompatibilityUtils.setPaddingRelative(view, ApiCompatibilityUtils.getPaddingStart(view),
            view.getPaddingTop() + mChromeHomeEmptyAndLoadingViewTopPadding,
            ApiCompatibilityUtils.getPaddingEnd(view), view.getPaddingBottom());
}
 
Example #17
Source File: BottomToolbarPhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onNativeLibraryReady() {
    super.onNativeLibraryReady();

    mUseToolbarHandle = !FeatureUtilities.isChromeHomeExpandButtonEnabled();

    if (!mUseToolbarHandle) {
        initExpandButton();
    } else {
        setFocusable(true);
        setFocusableInTouchMode(true);
        setContentDescription(
                getResources().getString(R.string.bottom_sheet_accessibility_toolbar));
    }
}
 
Example #18
Source File: LayoutManagerChromePhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    if (direction == ScrollDirection.DOWN && FeatureUtilities.isChromeHomeEnabled()) {
        return false;
    }

    return super.isSwipeEnabled(direction);
}
 
Example #19
Source File: LayoutManagerDocument.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !FeatureUtilities.isDocumentModeEligible(mHost.getContext())
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #20
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private boolean isMergedInstanceTaskRunning() {
    if (!FeatureUtilities.isTabModelMergingEnabled() || sMergedInstanceTaskId == 0) {
        return false;
    }

    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (AppTask task : manager.getAppTasks()) {
        RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
        if (info == null) continue;
        if (info.id == sMergedInstanceTaskId) return true;
    }
    return false;
}
 
Example #21
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);
    if (!FeatureUtilities.isTabModelMergingEnabled()) return;
    if (!isInMultiWindowMode) {
        // If the activity is currently resumed when multi-window mode is exited, try to merge
        // tabs from the other activity instance.
        if (ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
            maybeMergeTabs();
        } else {
            mMergeTabsOnResume = true;
        }
    }
}
 
Example #22
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected int getToolbarLayoutId() {
    if (DeviceFormFactor.isTablet()) return R.layout.toolbar_tablet;

    if (FeatureUtilities.isChromeHomeEnabled()) return R.layout.bottom_toolbar_phone;
    return R.layout.toolbar_phone;
}
 
Example #23
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected int getControlContainerLayoutId() {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        return R.layout.bottom_control_container;
    }
    return R.layout.control_container;
}
 
Example #24
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void showFeatureEngagementTextBubbleForDownloadHome() {
    final FeatureEngagementTracker tracker =
            FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForProfile(
                    Profile.getLastUsedProfile());
    if (!tracker.shouldTriggerHelpUI(FeatureConstants.DOWNLOAD_HOME_FEATURE)) return;

    ViewAnchoredTextBubble textBubble = new ViewAnchoredTextBubble(this,
            getToolbarManager().getMenuButton(), R.string.iph_download_home_text,
            R.string.iph_download_home_accessibility_text);
    textBubble.setDismissOnTouchInteraction(true);
    textBubble.addOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss() {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    tracker.dismissed(FeatureConstants.DOWNLOAD_HOME_FEATURE);
                    getAppMenuHandler().setMenuHighlight(null);
                }
            });
        }
    });
    getAppMenuHandler().setMenuHighlight(R.id.downloads_menu_id);
    int yInsetPx =
            getResources().getDimensionPixelOffset(R.dimen.text_bubble_menu_anchor_y_inset);
    textBubble.setInsetPx(0, FeatureUtilities.isChromeHomeEnabled() ? yInsetPx : 0, 0,
            FeatureUtilities.isChromeHomeEnabled() ? 0 : yInsetPx);
    textBubble.show();
}
 
Example #25
Source File: ChromeApplication.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called when last of Chrome activities is stopped, ending the foreground session. This will
 * not be called when a Chrome activity is stopped because another Chrome activity takes over.
 * This is ensured by ActivityStatus, which switches to track new activity when its started and
 * will not report the old one being stopped (see createStateListener() below).
 */
private void onForegroundSessionEnd() {
    if (!mIsStarted) return;
    mBackgroundProcessing.suspendTimers();
    flushPersistentData();
    mIsStarted = false;
    mPowerBroadcastReceiver.onForegroundSessionEnd();

    ChildProcessLauncher.onSentToBackground();
    IntentHandler.clearPendingReferrer();

    if (FeatureUtilities.isDocumentMode(this)) {
        if (sDocumentTabModelSelector != null) {
            RecordHistogram.recordCountHistogram("Tab.TotalTabCount.BeforeLeavingApp",
                    sDocumentTabModelSelector.getTotalTabCount());
        }
    } else {
        int totalTabCount = 0;
        for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
            Activity activity = reference.get();
            if (activity instanceof ChromeActivity) {
                TabModelSelector tabModelSelector =
                        ((ChromeActivity) activity).getTabModelSelector();
                if (tabModelSelector != null) {
                    totalTabCount += tabModelSelector.getTotalTabCount();
                }
            }
        }
        RecordHistogram.recordCountHistogram(
                "Tab.TotalTabCount.BeforeLeavingApp", totalTabCount);
    }
}
 
Example #26
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onResumeWithNative() {
    super.onResumeWithNative();
    markSessionResume();
    RecordUserAction.record("MobileComeToForeground");

    if (getActivityTab() != null) {
        LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents());
    }
    FeatureUtilities.setCustomTabVisible(isCustomTab());
    FeatureUtilities.setIsInMultiWindowMode(
            MultiWindowUtils.getInstance().isInMultiWindowMode(this));
}
 
Example #27
Source File: ForcedSigninProcessor.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Processes the fully automatic non-FRE-related forced sign-in.
 * This is used to enforce the environment for Android EDU and child accounts.
 */
private static void processForcedSignIn(final Context appContext) {
    final SigninManager signinManager = SigninManager.get(appContext);
    // By definition we have finished all the checks for first run.
    signinManager.onFirstRunCheckDone();
    if (!FeatureUtilities.canAllowSync(appContext) || !signinManager.isSignInAllowed()) {
        Log.d(TAG, "Sign in disallowed");
        return;
    }
    AccountManagerHelper.get(appContext).getGoogleAccounts(new Callback<Account[]>() {
        @Override
        public void onResult(Account[] accounts) {
            if (accounts.length != 1) {
                Log.d(TAG, "Incorrect number of accounts (%d)", accounts.length);
                return;
            }
            signinManager.signIn(accounts[0], null, new SigninManager.SignInCallback() {
                @Override
                public void onSignInComplete() {
                    // Since this is a forced signin, signout is not allowed.
                    AccountManagementFragment.setSignOutAllowedPreferenceValue(
                            appContext, false);
                }

                @Override
                public void onSignInAborted() {}
            });
        }
    });
}
 
Example #28
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 #29
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param manager The fullscreen manager that should be notified of changes to this tab (if
 *                set to null, no more updates will come from this tab).
 */
public void setFullscreenManager(FullscreenManager manager) {
    mFullscreenManager = manager;
    if (mFullscreenManager != null) {
        boolean topOffsetsInitialized = !Float.isNaN(mPreviousTopControlsOffsetY)
                && !Float.isNaN(mPreviousContentOffsetY);
        boolean bottomOffsetsInitialized =
                !Float.isNaN(mPreviousBottomControlsOffsetY);
        boolean isChromeHomeEnabled = FeatureUtilities.isChromeHomeEnabled();

        // Make sure the dominant control offsets have been set.
        if ((!topOffsetsInitialized && !isChromeHomeEnabled)
                || (!bottomOffsetsInitialized && isChromeHomeEnabled)) {
            mFullscreenManager.setPositionsForTabToNonFullscreen();
        } else {
            mFullscreenManager.setPositionsForTab(mPreviousTopControlsOffsetY,
                    mPreviousBottomControlsOffsetY,
                    mPreviousContentOffsetY);
        }
        updateFullscreenEnabledState();
    }

    // For blimp mode, offset the blimp view by the height of browser controls. This will ensure
    // that the view doesn't get clipped at the bottom of the page and also the touch offsets
    // would work correctly.
    if (getBlimpContents() != null && mFullscreenManager != null) {
        ViewGroup blimpView = getBlimpContents().getView();
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) blimpView.getLayoutParams();
        if (lp == null) {
            lp = new FrameLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        }

        lp.topMargin = mFullscreenManager.getTopControlsHeight();
        blimpView.setLayoutParams(lp);
    }
}
 
Example #30
Source File: StackAnimation.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The position of the static tab when entering or exiting the tab switcher.
 */
protected float getStaticTabPosition() {
    // The y position of the tab will depend on whether or not the toolbar is at the top or
    // bottom of the screen.
    float yPos = -mBorderTopHeight;
    if (!FeatureUtilities.isChromeHomeEnabled()) {
        yPos += mHeight - mHeightMinusBrowserControls;
    }
    return yPos;
}