Search in sources :

Example 1 with PrintingController

use of org.chromium.printing.PrintingController in project AndroidChromium by JackyAndroid.

the class ChromeActivity method onShareMenuItemSelected.

/**
     * Triggered when the share menu item is selected.
     * This creates and shows a share intent picker dialog or starts a share intent directly.
     * @param shareDirectly Whether it should share directly with the activity that was most
     *                      recently used to share.
     * @param isIncognito Whether currentTab is incognito.
     */
@VisibleForTesting
public void onShareMenuItemSelected(final boolean shareDirectly, final boolean isIncognito) {
    final Tab currentTab = getActivityTab();
    if (currentTab == null)
        return;
    PrintingController printingController = PrintingControllerImpl.getInstance();
    if (printingController != null && !currentTab.isNativePage() && !printingController.isBusy() && PrefServiceBridge.getInstance().isPrintingEnabled()) {
        PrintShareActivity.enablePrintShareOption(this, new Runnable() {

            @Override
            public void run() {
                triggerShare(currentTab, shareDirectly, isIncognito);
            }
        });
        return;
    }
    triggerShare(currentTab, shareDirectly, isIncognito);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) PrintingController(org.chromium.printing.PrintingController) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 2 with PrintingController

use of org.chromium.printing.PrintingController in project AndroidChromium by JackyAndroid.

the class ChromeActivity method onMenuOrKeyboardAction.

/**
     * Handles menu item selection and keyboard shortcuts.
     *
     * @param id The ID of the selected menu item (defined in main_menu.xml) or
     *           keyboard shortcut (defined in values.xml).
     * @param fromMenu Whether this was triggered from the menu.
     * @return Whether the action was handled.
     */
public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) {
    if (id == R.id.preferences_id) {
        PreferencesLauncher.launchSettingsPage(this, null);
        RecordUserAction.record("MobileMenuSettings");
    } else if (id == R.id.show_menu) {
        showAppMenuForKeyboardEvent();
    }
    if (id == R.id.update_menu_id) {
        UpdateMenuItemHelper.getInstance().onMenuItemClicked(this);
        return true;
    }
    // All the code below assumes currentTab is not null, so return early if it is null.
    final Tab currentTab = getActivityTab();
    if (currentTab == null) {
        return false;
    } else if (id == R.id.forward_menu_id) {
        if (currentTab.canGoForward()) {
            currentTab.goForward();
            RecordUserAction.record("MobileMenuForward");
            RecordUserAction.record("MobileTabClobbered");
        }
    } else if (id == R.id.bookmark_this_page_id) {
        addOrEditBookmark(currentTab);
        RecordUserAction.record("MobileMenuAddToBookmarks");
    } else if (id == R.id.offline_page_id) {
        DownloadUtils.downloadOfflinePage(this, currentTab);
        RecordUserAction.record("MobileMenuDownloadPage");
    } else if (id == R.id.reload_menu_id) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
            RecordUserAction.record("MobileMenuStop");
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileMenuReload");
        }
    } else if (id == R.id.info_menu_id) {
        WebsiteSettingsPopup.show(this, currentTab, null, WebsiteSettingsPopup.OPENED_FROM_MENU);
    } else if (id == R.id.open_history_menu_id) {
        currentTab.loadUrl(new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.AUTO_TOPLEVEL));
        RecordUserAction.record("MobileMenuHistory");
        StartupMetrics.getInstance().recordOpenedHistory();
    } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) {
        onShareMenuItemSelected(id == R.id.direct_share_menu_id, getCurrentTabModel().isIncognito());
    } else if (id == R.id.print_id) {
        PrintingController printingController = PrintingControllerImpl.getInstance();
        if (printingController != null && !printingController.isBusy() && PrefServiceBridge.getInstance().isPrintingEnabled()) {
            printingController.startPrint(new TabPrinter(currentTab), new PrintManagerDelegateImpl(this));
            RecordUserAction.record("MobileMenuPrint");
        }
    } else if (id == R.id.add_to_homescreen_id) {
        AddToHomescreenManager addToHomescreenManager = new AddToHomescreenManager(this, currentTab);
        addToHomescreenManager.start();
        RecordUserAction.record("MobileMenuAddToHomescreen");
    } else if (id == R.id.request_desktop_site_id) {
        final boolean reloadOnChange = !currentTab.isNativePage();
        final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAgent();
        currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnChange);
        RecordUserAction.record("MobileMenuRequestDesktopSite");
    } else if (id == R.id.reader_mode_prefs_id) {
        if (currentTab.getWebContents() != null) {
            RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened");
            AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme);
            builder.setView(DistilledPagePrefsView.create(this));
            builder.show();
        }
    } else if (id == R.id.help_id) {
        // Since reading back the compositor is asynchronous, we need to do the readback
        // before starting the GoogleHelp.
        String helpContextId = HelpAndFeedback.getHelpContextIdFromUrl(this, currentTab.getUrl(), getCurrentTabModel().isIncognito());
        HelpAndFeedback.getInstance(this).show(this, helpContextId, currentTab.getProfile(), currentTab.getUrl());
        RecordUserAction.record("MobileMenuFeedback");
    } else {
        return false;
    }
    return true;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) PrintManagerDelegateImpl(org.chromium.printing.PrintManagerDelegateImpl) Tab(org.chromium.chrome.browser.tab.Tab) TabPrinter(org.chromium.chrome.browser.printing.TabPrinter) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams) PrintingController(org.chromium.printing.PrintingController) AddToHomescreenManager(org.chromium.chrome.browser.webapps.AddToHomescreenManager)

Example 3 with PrintingController

use of org.chromium.printing.PrintingController in project AndroidChromium by JackyAndroid.

the class Tab method setPendingPrint.

@CalledByNative
public void setPendingPrint() {
    PrintingController printingController = PrintingControllerImpl.getInstance();
    if (printingController == null)
        return;
    printingController.setPendingPrint(new TabPrinter(this), new PrintManagerDelegateImpl(getActivity()));
}
Also used : PrintManagerDelegateImpl(org.chromium.printing.PrintManagerDelegateImpl) TabPrinter(org.chromium.chrome.browser.printing.TabPrinter) PrintingController(org.chromium.printing.PrintingController) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

PrintingController (org.chromium.printing.PrintingController)3 TabPrinter (org.chromium.chrome.browser.printing.TabPrinter)2 Tab (org.chromium.chrome.browser.tab.Tab)2 PrintManagerDelegateImpl (org.chromium.printing.PrintManagerDelegateImpl)2 AlertDialog (android.support.v7.app.AlertDialog)1 VisibleForTesting (org.chromium.base.VisibleForTesting)1 CalledByNative (org.chromium.base.annotations.CalledByNative)1 AddToHomescreenManager (org.chromium.chrome.browser.webapps.AddToHomescreenManager)1 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)1