org.chromium.chrome.browser.firstrun.FirstRunStatus Java Examples

The following examples show how to use org.chromium.chrome.browser.firstrun.FirstRunStatus. 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: ChromeActionModeCallback.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    notifyContextualActionBarVisibilityChanged(true);

    int allowedActionModes = ActionModeCallbackHelper.MENU_ITEM_PROCESS_TEXT
            | ActionModeCallbackHelper.MENU_ITEM_SHARE;
    // Disable options that expose additional Chrome functionality prior to the FRE being
    // completed (i.e. creation of a new tab).
    if (FirstRunStatus.getFirstRunFlowComplete()) {
        allowedActionModes |= ActionModeCallbackHelper.MENU_ITEM_WEB_SEARCH;
    }
    mHelper.setAllowedMenuItems(allowedActionModes);

    mHelper.onCreateActionMode(mode, menu);
    return true;
}
 
Example #2
Source File: ContextualSearchTabHelper.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @return whether Contextual Search is enabled and active in this tab.
 */
private boolean isContextualSearchActive(ContentViewCore cvc) {
    ContextualSearchManager manager = getContextualSearchManager();
    if (manager == null) return false;

    return !cvc.getWebContents().isIncognito()
            && FirstRunStatus.getFirstRunFlowComplete()
            && !PrefServiceBridge.getInstance().isContextualSearchDisabled()
            && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()
            // Svelte and Accessibility devices are incompatible with the first-run flow and
            // Talkback has poor interaction with tap to search (see http://crbug.com/399708 and
            // http://crbug.com/396934).
            && !manager.isRunningInCompatibilityMode()
            && !(mTab.isShowingErrorPage() || mTab.isShowingInterstitialPage())
            && isDeviceOnline(manager);
}
 
Example #3
Source File: EmbedContentViewActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean retVal = super.onCreateOptionsMenu(menu);
    if (!FirstRunStatus.getFirstRunFlowComplete(this)) return retVal;
    menu.add(Menu.NONE, R.id.menu_id_open_in_chrome, Menu.NONE, R.string.menu_open_in_chrome);
    return true;
}
 
Example #4
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void finishNativeInitialization() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.finishNativeInitialization");

        launchFirstRunExperience();

        ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(this);
        // Promos can only be shown when we start with ACTION_MAIN intent and
        // after FRE is complete.
        if (!mIntentWithEffect && FirstRunStatus.getFirstRunFlowComplete(this)) {
            // Only show promos on the second oppurtunity. This is because we show FRE on the
            // first oppurtunity, and we don't want to show such content back to back.
            if (preferenceManager.getPromosSkippedOnFirstStart()) {
                // Data reduction promo should be temporarily suppressed if the sign in promo is
                // shown to avoid nagging users too much.
                if (!SigninPromoUtil.launchSigninPromoIfNeeded(this)) {
                    DataReductionPromoScreen.launchDataReductionPromo(this);
                }
            } else {
                preferenceManager.setPromosSkippedOnFirstStart(true);
            }
        }

        refreshSignIn();

        initializeUI();

        // The dataset has already been created, we need to initialize our state.
        mTabModelSelectorImpl.notifyChanged();

        getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,
                Window.PROGRESS_VISIBILITY_OFF);

        // Check for incognito tabs to handle the case where Chrome was swiped away in the
        // background.
        int incognitoCount = TabWindowManager.getInstance().getIncognitoTabCount();
        if (incognitoCount == 0) IncognitoNotificationManager.dismissIncognitoNotification();

        super.finishNativeInitialization();
    } finally {
        TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization");
    }
}
 
Example #5
Source File: EmbedContentViewActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean retVal = super.onCreateOptionsMenu(menu);
    if (!FirstRunStatus.getFirstRunFlowComplete()) return retVal;
    return true;
}
 
Example #6
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void finishNativeInitialization() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.finishNativeInitialization");

        launchFirstRunExperience();

        refreshSignIn();

        ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(this);
        // Promos can only be shown when we start with ACTION_MAIN intent and
        // after FRE is complete.
        if (!mIntentWithEffect && FirstRunStatus.getFirstRunFlowComplete()) {
            // Only show promos on the second oppurtunity. This is because we show FRE on the
            // first oppurtunity, and we don't want to show such content back to back.
            if (preferenceManager.getPromosSkippedOnFirstStart()) {
                // Data reduction promo should be temporarily suppressed if the sign in promo is
                // shown to avoid nagging users too much.
                if (!SigninPromoUtil.launchSigninPromoIfNeeded(this)) {
                    DataReductionPromoScreen.launchDataReductionPromo(this);
                }
            } else {
                preferenceManager.setPromosSkippedOnFirstStart(true);
            }

            // Notify users experimenting with WebAPKs if they need to do extra steps to enable
            // WebAPKs.
            ChromeWebApkHost.launchWebApkRequirementsDialogIfNeeded(this);
        }

        initializeUI();

        // The dataset has already been created, we need to initialize our state.
        mTabModelSelectorImpl.notifyChanged();

        getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,
                Window.PROGRESS_VISIBILITY_OFF);

        // Check for incognito tabs to handle the case where Chrome was swiped away in the
        // background.
        int incognitoCount = TabWindowManager.getInstance().getIncognitoTabCount();
        if (incognitoCount == 0) IncognitoNotificationManager.dismissIncognitoNotification();

        // LocaleManager can only function after the native library is loaded.
        mLocaleManager = LocaleManager.getInstance();
        mLocaleManager.showSearchEnginePromoIfNeeded(this);

        super.finishNativeInitialization();
    } finally {
        TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization");
    }
}
 
Example #7
Source File: ChromeContextMenuPopulator.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public List<Pair<Integer, List<ContextMenuItem>>> buildContextMenu(
        ContextMenu menu, Context context, ContextMenuParams params) {
    // Add all items in a group
    Set<ContextMenuItem> supportedOptions = new HashSet<>();
    if (FirstRunStatus.getFirstRunFlowComplete()) {
        supportedOptions.addAll(BASE_WHITELIST);
        if (mMode == FULLSCREEN_TAB_MODE) {
            supportedOptions.addAll(FULLSCREEN_TAB_MODE_WHITELIST);
        } else if (mMode == CUSTOM_TAB_MODE) {
            supportedOptions.addAll(CUSTOM_TAB_MODE_WHITELIST);
        } else {
            supportedOptions.addAll(NORMAL_MODE_WHITELIST);
        }
    } else {
        supportedOptions.add(ChromeContextMenuItem.COPY_LINK_ADDRESS);
        supportedOptions.add(ChromeContextMenuItem.COPY_LINK_TEXT);
        supportedOptions.add(ChromeContextMenuItem.COPY);
    }

    Set<ContextMenuItem> disabledOptions = getDisabledOptions(params);
    // Split the items into their respective groups.
    List<Pair<Integer, List<ContextMenuItem>>> groupedItems = new ArrayList<>();
    if (params.isAnchor()
            && !ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU)) {
        populateItemGroup(LINK, R.string.contextmenu_link_title, groupedItems, supportedOptions,
                disabledOptions);
    }
    if (params.isImage()) {
        populateItemGroup(IMAGE, R.string.contextmenu_image_title, groupedItems,
                supportedOptions, disabledOptions);
    }
    if (params.isVideo()) {
        populateItemGroup(VIDEO, R.string.contextmenu_video_title, groupedItems,
                supportedOptions, disabledOptions);
    }
    if (params.isAnchor()
            && ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU)) {
        populateItemGroup(LINK, R.string.contextmenu_link_title, groupedItems, supportedOptions,
                disabledOptions);
    }

    // If there are no groups there still needs to be a way to add items from the OTHER_GROUP
    // and CUSTOM_TAB_GROUP.
    if (groupedItems.isEmpty()) {
        int titleResId = R.string.contextmenu_link_title;

        if (params.isVideo()) {
            titleResId = R.string.contextmenu_video_title;
        } else if (params.isImage()) {
            titleResId = R.string.contextmenu_image_title;
        }
        groupedItems.add(new Pair<Integer, List<ContextMenuItem>>(
                titleResId, new ArrayList<ContextMenuItem>()));
    }

    // These items don't belong to any official group so they are added to a possible visible
    // list.
    int index = ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU)
            ? groupedItems.size() - 1
            : 0;
    addValidItems(groupedItems.get(groupedItems.size() - 1 - index).second, OTHER_GROUP,
            supportedOptions, disabledOptions);
    if (mMode == CUSTOM_TAB_MODE) {
        addValidItemsToFront(groupedItems.get(index).second, CUSTOM_TAB_GROUP, supportedOptions,
                disabledOptions);
    }

    // If there are no items from the extra items within OTHER_GROUP and CUSTOM_TAB_GROUP, then
    // it's removed since there is nothing to show at all.
    if (groupedItems.get(index).second.isEmpty()) {
        groupedItems.remove(index);
    }

    return groupedItems;
}
 
Example #8
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void finishNativeInitialization() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.finishNativeInitialization");

        refreshSignIn();

        initializeUI();

        // The dataset has already been created, we need to initialize our state.
        mTabModelSelectorImpl.notifyChanged();

        ApiCompatibilityUtils.setWindowIndeterminateProgress(getWindow());

        // Check for incognito tabs to handle the case where Chrome was swiped away in the
        // background.
        if (TabWindowManager.getInstance().canDestroyIncognitoProfile()) {
            IncognitoNotificationManager.dismissIncognitoNotification();
        }

        // LocaleManager can only function after the native library is loaded.
        mLocaleManager = LocaleManager.getInstance();
        boolean searchEnginePromoShown =
                mLocaleManager.showSearchEnginePromoIfNeeded(this, null);

        ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
        // Promos can only be shown when we start with ACTION_MAIN intent and
        // after FRE is complete. Native initialization can finish before the FRE flow is
        // complete, and this will only show promos on the second opportunity. This is
        // because the FRE is shown on the first opportunity, and we don't want to show such
        // content back to back.
        if (!searchEnginePromoShown && !mIntentWithEffect
                && FirstRunStatus.getFirstRunFlowComplete()
                && preferenceManager.getPromosSkippedOnFirstStart()) {
            // Data reduction promo should be temporarily suppressed if the sign in promo is
            // shown to avoid nagging users too much.
            if (!SigninPromoUtil.launchSigninPromoIfNeeded(this)) {
                DataReductionPromoScreen.launchDataReductionPromo(this);
            }
        } else {
            preferenceManager.setPromosSkippedOnFirstStart(true);
        }

        super.finishNativeInitialization();
    } finally {
        TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization");
    }
}
 
Example #9
Source File: CustomTabAppMenuPropertiesDelegate.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void prepareMenu(Menu menu) {
    Tab currentTab = mActivity.getActivityTab();
    if (currentTab != null) {
        MenuItem forwardMenuItem = menu.findItem(R.id.forward_menu_id);
        forwardMenuItem.setEnabled(currentTab.canGoForward());

        mReloadMenuItem = menu.findItem(R.id.reload_menu_id);
        mReloadMenuItem.setIcon(R.drawable.btn_reload_stop);
        loadingStateChanged(currentTab.isLoading());

        MenuItem shareItem = menu.findItem(R.id.share_row_menu_id);
        shareItem.setVisible(mShowShare);
        shareItem.setEnabled(mShowShare);
        if (mShowShare) {
            ShareHelper.configureDirectShareMenuItem(
                    mActivity, menu.findItem(R.id.direct_share_menu_id));
        }

        MenuItem iconRow = menu.findItem(R.id.icon_row_menu_id);
        MenuItem openInChromeItem = menu.findItem(R.id.open_in_browser_id);
        MenuItem bookmarkItem = menu.findItem(R.id.bookmark_this_page_id);
        MenuItem downloadItem = menu.findItem(R.id.offline_page_id);

        boolean addToHomeScreenVisible = true;

        // Hide request desktop site on all chrome:// pages except for the NTP. Check request
        // desktop site if it's activated on this page.
        MenuItem requestItem = menu.findItem(R.id.request_desktop_site_id);
        updateRequestDesktopSiteMenuItem(requestItem, currentTab);

        if (mIsMediaViewer) {
            // Most of the menu items don't make sense when viewing media.
            iconRow.setVisible(false);
            openInChromeItem.setVisible(false);
            menu.findItem(R.id.find_in_page_id).setVisible(false);
            menu.findItem(R.id.request_desktop_site_id).setVisible(false);
            addToHomeScreenVisible = false;
        } else {
            openInChromeItem.setTitle(
                    DefaultBrowserInfo.getTitleOpenInDefaultBrowser(mIsOpenedByChrome));
            updateBookmarkMenuItem(bookmarkItem, currentTab);
        }
        bookmarkItem.setVisible(mShowStar);
        downloadItem.setVisible(mShowDownload);
        if (!FirstRunStatus.getFirstRunFlowComplete()) {
            openInChromeItem.setVisible(false);
            bookmarkItem.setVisible(false);
            downloadItem.setVisible(false);
            addToHomeScreenVisible = false;
        }

        downloadItem.setEnabled(DownloadUtils.isAllowedToDownloadPage(currentTab));

        String url = currentTab.getUrl();
        boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX)
                || url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
        if (isChromeScheme) {
            addToHomeScreenVisible = false;
        }

        // Add custom menu items. Make sure they are only added once.
        if (!mIsCustomEntryAdded) {
            mIsCustomEntryAdded = true;
            for (int i = 0; i < mMenuEntries.size(); i++) {
                MenuItem item = menu.add(0, 0, 1, mMenuEntries.get(i));
                mItemToIndexMap.put(item, i);
            }
        }

        prepareAddToHomescreenMenuItem(menu, currentTab, addToHomeScreenVisible);
    }
}