android.app.ActivityManager.RecentTaskInfo#org.chromium.chrome.browser.util.FeatureUtilities源码实例Demo

下面列出了android.app.ActivityManager.RecentTaskInfo#org.chromium.chrome.browser.util.FeatureUtilities 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: delion   文件: LayoutManagerChrome.java
@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);
}
 
源代码2 项目: delion   文件: ChromeActivity.java
@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();
    }
}
 
源代码3 项目: delion   文件: ChromeActivity.java
/**
 * 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));
    }
}
 
源代码4 项目: AndroidChromium   文件: ChromeTabbedActivity.java
@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();
}
 
源代码5 项目: 365browser   文件: BottomSheet.java
/**
 * 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;
}
 
源代码6 项目: AndroidChromium   文件: ChromeActivity.java
/**
 * 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);
}
 
源代码7 项目: AndroidChromium   文件: ChromeLauncherActivity.java
/**
 * @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;
    }
}
 
源代码8 项目: 365browser   文件: StackLayout.java
@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);
    }
}
 
源代码9 项目: 365browser   文件: NativePageFactory.java
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);
    }
}
 
源代码10 项目: 365browser   文件: Tab.java
/**
 * @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();
    }
}
 
源代码11 项目: 365browser   文件: ChromeActivity.java
@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);
}
 
源代码12 项目: 365browser   文件: ChromeActivity.java
/**
 * 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);
}
 
源代码13 项目: 365browser   文件: ChromeLauncherActivity.java
/**
 * @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;
    }
}
 
源代码14 项目: delion   文件: ChromeTabbedActivity.java
/**
 * 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");
    }
}
 
源代码15 项目: delion   文件: ChromeTabbedActivity.java
@Override
public boolean isStartedUpCorrectly(Intent intent) {
    if (FeatureUtilities.isDocumentMode(this)) {
        Log.e(TAG, "Discarding Intent: Starting ChromeTabbedActivity in Document mode");
        return false;
    }
    return true;
}
 
源代码16 项目: delion   文件: BookmarkUtils.java
/**
 * Updates the title of chrome shown in recent tasks. It only takes effect in document mode.
 */
public static void setTaskDescriptionInDocumentMode(Activity activity, String description) {
    if (FeatureUtilities.isDocumentMode(activity)) {
        // Setting icon to be null and color to be 0 will means "take no effect".
        ApiCompatibilityUtils.setTaskDescription(activity, description, null, 0);
    }
}
 
源代码17 项目: delion   文件: LayoutManagerDocument.java
@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;
}
 
源代码18 项目: delion   文件: LayerTitleCache.java
private String getUpdatedTitleInternal(Tab tab, String titleString,
        boolean fetchFaviconFromHistory) {
    final int tabId = tab.getId();
    Bitmap originalFavicon = tab.getFavicon();

    boolean isDarkTheme = tab.isIncognito();
    // If theme colors are enabled in the tab switcher, the theme might require lighter text.
    if (FeatureUtilities.areTabSwitcherThemeColorsEnabled()
            && !DeviceFormFactor.isTablet(mContext)) {
        isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    }

    ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    boolean isRtl = tab.isTitleDirectionRtl();
    TitleBitmapFactory titleBitmapFactory = isDarkTheme
            ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;

    Title title = mTitles.get(tabId);
    if (title == null) {
        title = new Title();
        mTitles.put(tabId, title);
        title.register();
    }

    title.set(titleBitmapFactory.getTitleBitmap(mContext, titleString),
            titleBitmapFactory.getFaviconBitmap(mContext, originalFavicon),
            fetchFaviconFromHistory);

    if (mNativeLayerTitleCache != 0) {
        nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(),
                title.getFaviconResId(), isDarkTheme, isRtl);
    }
    return titleString;
}
 
源代码19 项目: delion   文件: ChromeApplication.java
/**
 * 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);
    }
}
 
源代码20 项目: delion   文件: CustomTabIntentDataProvider.java
/**
 * Parses out extras specifically added for Herb.
 *
 * @param intent Intent fired to open the CustomTabActivity.
 * @param context Context for the package.
 */
private void parseHerbExtras(Intent intent, Context context) {
    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(herbFlavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, herbFlavor)) {
        return;
    }
    if (!IntentHandler.isIntentChromeOrFirstParty(intent, context)) return;

    mIsOpenedByChrome = IntentUtils.safeGetBooleanExtra(
            intent, EXTRA_IS_OPENED_BY_CHROME, false);
    mShowBookmarkItem = IntentUtils.safeGetBooleanExtra(
            intent, EXTRA_SHOW_STAR_ICON, false);
}
 
源代码21 项目: delion   文件: CustomTabActivity.java
/**
 * @return Whether {@link ChromeTabbedActivity} is waiting for a result from this Activity.
 */
private boolean isHerbResultNeeded() {
    if (!TextUtils.equals(FeatureUtilities.getHerbFlavor(), ChromeSwitches.HERB_FLAVOR_DILL)) {
        return false;
    }

    String callingActivity =
            getCallingActivity() == null ? null : getCallingActivity().getClassName();
    return TextUtils.equals(callingActivity, ChromeTabbedActivity.class.getName());
}
 
源代码22 项目: delion   文件: LocationBarLayout.java
@Override
public boolean isVoiceSearchEnabled() {
    if (mToolbarDataProvider == null) return false;
    if (mToolbarDataProvider.isIncognito()) return false;
    if (mWindowAndroid == null) return false;

    if (!mWindowAndroid.hasPermission(Manifest.permission.RECORD_AUDIO)
            && !mWindowAndroid.canRequestPermission(Manifest.permission.RECORD_AUDIO)) {
        return false;
    }

    return FeatureUtilities.isRecognitionIntentPresent(getContext(), true);
}
 
源代码23 项目: delion   文件: TabWebContentsDelegateAndroid.java
@Override
public void run() {
    boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == mTab;
    mTab.getTabModelSelector().closeTab(mTab);

    // If the parent Tab belongs to another Activity, fire the Intent to bring it back.
    if (isSelected && mTab.getParentIntent() != null
            && mTab.getActivity().getIntent() != mTab.getParentIntent()) {
        boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getApplicationContext())
                ? isParentInAndroidOverview() : true;
        if (mayLaunch) {
            mTab.getActivity().startActivity(mTab.getParentIntent());
        }
    }
}
 
源代码24 项目: delion   文件: ToolbarPhone.java
private boolean isReturnButtonVisible() {
    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (!TextUtils.equals(ChromeSwitches.HERB_FLAVOR_BASIL, herbFlavor)
            && !TextUtils.equals(ChromeSwitches.HERB_FLAVOR_CHIVE, herbFlavor)) {
        return false;
    }

    Tab currentTab = getToolbarDataProvider().getTab();
    return mReturnButtonListener != null && currentTab != null
            && currentTab.isAllowedToReturnToExternalApp();
}
 
源代码25 项目: delion   文件: ToolbarManager.java
private void onNativeLibraryReady() {
    mNativeLibraryReady = true;
    mToolbar.onNativeLibraryReady();

    if (FeatureUtilities.isTabSwitchingEnabledInDocumentMode(mToolbar.getContext())) {
        // We want to give a similar look and feel as Android's overview mode button
        // by not updating tab count and keep the button as a rounded square.
        mShouldUpdateTabCount = false;
    }

    final TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
    TemplateUrlService.LoadListener mTemplateServiceLoadListener =
            new TemplateUrlService.LoadListener() {
                @Override
                public void onTemplateUrlServiceLoaded() {
                    registerTemplateUrlObserver();
                    templateUrlService.unregisterLoadListener(this);
                }
            };
    templateUrlService.registerLoadListener(mTemplateServiceLoadListener);
    if (templateUrlService.isLoaded()) {
        mTemplateServiceLoadListener.onTemplateUrlServiceLoaded();
    } else {
        templateUrlService.load();
    }

    mTabModelSelector.addObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) model.addObserver(mTabModelObserver);

    refreshSelectedTab();
    if (mTabModelSelector.isTabStateInitialized()) mTabRestoreCompleted = true;
    handleTabRestoreCompleted();
}
 
源代码26 项目: delion   文件: ForcedSigninProcessor.java
/**
 * 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() {}
            });
        }
    });
}
 
源代码27 项目: delion   文件: ChromeActivity.java
@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));
}
 
源代码28 项目: delion   文件: ChromeActivity.java
/**
 * Initializes the {@link CompositorViewHolder} with the relevant content it needs to properly
 * show content on the screen.
 * @param layoutManager             A {@link LayoutManagerDocument} instance.  This class is
 *                                  responsible for driving all high level screen content and
 *                                  determines which {@link Layout} is shown when.
 * @param urlBar                    The {@link View} representing the URL bar (must be
 *                                  focusable) or {@code null} if none exists.
 * @param contentContainer          A {@link ViewGroup} that can have content attached by
 *                                  {@link Layout}s.
 * @param controlContainer          A {@link ControlContainer} instance to draw.
 */
protected void initializeCompositorContent(
        LayoutManagerDocument layoutManager, View urlBar, ViewGroup contentContainer,
        ControlContainer controlContainer) {
    if (controlContainer != null) {
        mFullscreenManager = createFullscreenManager(controlContainer);
    }

    if (mContextualSearchManager != null) {
        mContextualSearchManager.initialize(contentContainer);
        mContextualSearchManager.setSearchContentViewDelegate(layoutManager);
    }

    layoutManager.addSceneChangeObserver(this);
    mCompositorViewHolder.setLayoutManager(layoutManager);
    mCompositorViewHolder.setFocusable(false);
    mCompositorViewHolder.setControlContainer(controlContainer);
    mCompositorViewHolder.setFullscreenHandler(mFullscreenManager);
    mCompositorViewHolder.setUrlBar(urlBar);
    mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector(), this,
            getTabContentManager(), contentContainer, mContextualSearchManager,
            mReaderModeManager);

    if (controlContainer != null
            && DeviceClassManager.enableToolbarSwipe(FeatureUtilities.isDocumentMode(this))) {
        controlContainer.setSwipeHandler(
                getCompositorViewHolder().getLayoutManager().getTopSwipeHandler());
    }
}
 
源代码29 项目: AndroidChromium   文件: ChromeTabbedActivity.java
@Override
protected int getControlContainerLayoutId() {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        return R.layout.bottom_control_container;
    }
    return R.layout.control_container;
}
 
源代码30 项目: AndroidChromium   文件: ChromeTabbedActivity.java
@Override
protected int getToolbarLayoutId() {
    if (DeviceFormFactor.isTablet(getApplicationContext())) return R.layout.toolbar_tablet;

    if (FeatureUtilities.isChromeHomeEnabled()) return R.layout.bottom_toolbar_phone;
    return R.layout.toolbar_phone;
}