org.chromium.chrome.browser.banners.AppBannerManager Java Examples

The following examples show how to use org.chromium.chrome.browser.banners.AppBannerManager. 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: ProcessInitializationHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Performs the post native initialization.
 */
protected void handlePostNativeInitialization() {
    final ChromeApplication application =
            (ChromeApplication) ContextUtils.getApplicationContext();

    DataReductionProxySettings.reconcileDataReductionProxyEnabledState(application);
    ChromeActivitySessionTracker.getInstance().initializeWithNative();
    ChromeApplication.removeSessionCookies();
    AppBannerManager.setAppDetailsDelegate(application.createAppDetailsDelegate());
    ChromeLifetimeController.initialize();

    PrefServiceBridge.getInstance().migratePreferences(application);
}
 
Example #2
Source File: ProcessInitializationHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Performs the post native initialization.
 */
protected void handlePostNativeInitialization() {
    final ChromeApplication application =
            (ChromeApplication) ContextUtils.getApplicationContext();

    DataReductionProxySettings.reconcileDataReductionProxyEnabledState(application);
    ChromeActivitySessionTracker.getInstance().initializeWithNative();
    ChromeApplication.removeSessionCookies();
    AppBannerManager.setAppDetailsDelegate(AppHooks.get().createAppDetailsDelegate());
    ChromeLifetimeController.initialize();

    PrefServiceBridge.getInstance().migratePreferences(application);

    if (ChromeFeatureList.isEnabled(ChromeFeatureList.NEW_PHOTO_PICKER)) {
        UiUtils.setPhotoPickerDelegate(new UiUtils.PhotoPickerDelegate() {
            private PhotoPickerDialog mDialog;

            @Override
            public void showPhotoPicker(
                    Context context, PhotoPickerListener listener, boolean allowMultiple) {
                mDialog = new PhotoPickerDialog(context, listener, allowMultiple);
                mDialog.getWindow().getAttributes().windowAnimations =
                        R.style.PhotoPickerDialogAnimation;
                mDialog.show();
            }

            @Override
            public void dismissPhotoPicker() {
                mDialog.dismiss();
                mDialog = null;
            }
        });
    }

    SearchWidgetProvider.initialize();
}
 
Example #3
Source File: AppMenuPropertiesDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the visibility and labels of the "Add to Home screen" and "Open WebAPK" menu items.
 */
protected void prepareAddToHomescreenMenuItem(
        Menu menu, Tab currentTab, boolean canShowHomeScreenMenuItem) {
    // Record whether or not we have finished installability checks for this page when we're
    // preparing the menu to be displayed. This will let us determine if it is feasible to
    // change the add to homescreen menu item based on whether a site is a PWA.
    currentTab.getAppBannerManager().recordMenuOpen();

    MenuItem homescreenItem = menu.findItem(R.id.add_to_homescreen_id);
    MenuItem openWebApkItem = menu.findItem(R.id.open_webapk_id);
    if (canShowHomeScreenMenuItem) {
        Context context = ContextUtils.getApplicationContext();
        long addToHomeScreenStart = SystemClock.elapsedRealtime();
        ResolveInfo resolveInfo =
                WebApkValidator.queryResolveInfo(context, currentTab.getUrl());
        RecordHistogram.recordTimesHistogram("Android.PrepareMenu.OpenWebApkVisibilityCheck",
                SystemClock.elapsedRealtime() - addToHomeScreenStart, TimeUnit.MILLISECONDS);

        boolean openWebApkItemVisible =
                resolveInfo != null && resolveInfo.activityInfo.packageName != null;

        if (openWebApkItemVisible) {
            String appName = resolveInfo.loadLabel(context.getPackageManager()).toString();
            openWebApkItem.setTitle(context.getString(R.string.menu_open_webapk, appName));

            homescreenItem.setVisible(false);
            openWebApkItem.setVisible(true);
        } else {
            homescreenItem.setTitle(AppBannerManager.getHomescreenLanguageOption());
            homescreenItem.setVisible(true);
            openWebApkItem.setVisible(false);
        }
    } else {
        homescreenItem.setVisible(false);
        openWebApkItem.setVisible(false);
    }
}
 
Example #4
Source File: CustomTabDelegateFactory.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public AppBannerManager createAppBannerManager(Tab tab) {
    return null;
}
 
Example #5
Source File: Tab.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes {@link Tab} with {@code webContents}.  If {@code webContents} is {@code null} a
 * new {@link WebContents} will be created for this {@link Tab}.
 * @param webContents       A {@link WebContents} object or {@code null} if one should be
 *                          created.
 * @param tabContentManager A {@link TabContentManager} instance or {@code null} if the web
 *                          content will be managed/displayed manually.
 * @param delegateFactory   The {@link TabDelegateFactory} to be used for delegate creation.
 * @param initiallyHidden   Only used if {@code webContents} is {@code null}.  Determines
 *                          whether or not the newly created {@link WebContents} will be hidden
 *                          or not.
 * @param unfreeze          Whether there should be an attempt to restore state at the end of
 *                          the initialization.
 */
public final void initialize(WebContents webContents, TabContentManager tabContentManager,
        TabDelegateFactory delegateFactory, boolean initiallyHidden, boolean unfreeze) {
    try {
        TraceEvent.begin("Tab.initialize");

        mDelegateFactory = delegateFactory;
        initializeNative();

        RevenueStats.getInstance().tabCreated(this);

        if (AppBannerManager.isEnabled()) {
            mAppBannerManager = mDelegateFactory.createAppBannerManager(this);
            if (mAppBannerManager != null) addObserver(mAppBannerManager);
        }

        mTopControlsVisibilityDelegate =
                mDelegateFactory.createTopControlsVisibilityDelegate(this);

        // Attach the TabContentManager if we have one.  This will bind this Tab's content layer
        // to this manager.
        // TODO(dtrainor): Remove this and move to a pull model instead of pushing the layer.
        attachTabContentManager(tabContentManager);

        // If there is a frozen WebContents state or a pending lazy load, don't create a new
        // WebContents.
        if (getFrozenContentsState() != null || getPendingLoadParams() != null) {
            if (unfreeze) unfreezeContents();
            return;
        }

        boolean creatingWebContents = webContents == null;
        if (creatingWebContents) {
            webContents = WebContentsFactory.createWebContents(isIncognito(), initiallyHidden);
        }

        ContentViewCore contentViewCore = ContentViewCore.fromWebContents(webContents);

        if (contentViewCore == null) {
            initContentViewCore(webContents);
        } else {
            setContentViewCore(contentViewCore);
        }

        if (!creatingWebContents && webContents.isLoadingToDifferentDocument()) {
            didStartPageLoad(webContents.getUrl(), false);
        }
    } finally {
        if (mTimestampMillis == INVALID_TIMESTAMP) {
            mTimestampMillis = System.currentTimeMillis();
        }

        TraceEvent.end("Tab.initialize");
    }
}
 
Example #6
Source File: Tab.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return the AppBannerManager.
 */
@VisibleForTesting
public AppBannerManager getAppBannerManagerForTesting() {
    return mAppBannerManager;
}
 
Example #7
Source File: Tab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return the AppBannerManager.
 */
public AppBannerManager getAppBannerManager() {
    return AppBannerManager.getAppBannerManagerForWebContents(getWebContents());
}
 
Example #8
Source File: AppBannerInfoBarAndroid.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private static String getAddToHomescreenText() {
    return ContextUtils.getApplicationContext().getString(
            AppBannerManager.getAppBannerLanguageOption());
}
 
Example #9
Source File: Tab.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return the AppBannerManager.
 */
public AppBannerManager getAppBannerManager() {
    return AppBannerManager.getAppBannerManagerForWebContents(getWebContents());
}
 
Example #10
Source File: AppBannerInfoBarAndroid.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private static String getAddToHomescreenText() {
    return ContextUtils.getApplicationContext().getString(
            AppBannerManager.getAppBannerLanguageOption());
}
 
Example #11
Source File: TabDelegateFactory.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Creates the {@link AppBannerManager} the tab will be initialized with.
 * @param tab The associated {@link Tab}.
 * @return {@link AppBannerManager} to be used for the given tab. May be null.
 */
public AppBannerManager createAppBannerManager(Tab tab) {
    return new AppBannerManager(tab, tab.getApplicationContext());
}