Search in sources :

Example 1 with DomDistillerService

use of org.chromium.components.dom_distiller.core.DomDistillerService in project AndroidChromium by JackyAndroid.

the class DomDistillerServiceFactory method getForProfile.

/**
     * Returns Java DomDistillerService for given Profile.
     */
public static DomDistillerService getForProfile(Profile profile) {
    ThreadUtils.assertOnUiThread();
    DomDistillerService service = sServiceMap.get(profile);
    if (service == null) {
        service = nativeGetForProfile(profile);
        sServiceMap.put(profile, service);
    }
    return service;
}
Also used : DomDistillerService(org.chromium.components.dom_distiller.core.DomDistillerService)

Example 2 with DomDistillerService

use of org.chromium.components.dom_distiller.core.DomDistillerService in project AndroidChromium by JackyAndroid.

the class ToolbarModelImpl method isStoredArticle.

private boolean isStoredArticle(String url) {
    DomDistillerService domDistillerService = DomDistillerServiceFactory.getForProfile(mTab.getProfile());
    String entryIdFromUrl = DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id");
    if (TextUtils.isEmpty(entryIdFromUrl))
        return false;
    return domDistillerService.hasEntry(entryIdFromUrl);
}
Also used : DomDistillerService(org.chromium.components.dom_distiller.core.DomDistillerService)

Example 3 with DomDistillerService

use of org.chromium.components.dom_distiller.core.DomDistillerService in project AndroidChromium by JackyAndroid.

the class CustomTabToolbar method isStoredArticle.

private boolean isStoredArticle(String url) {
    DomDistillerService domDistillerService = DomDistillerServiceFactory.getForProfile(Profile.getLastUsedProfile());
    String entryIdFromUrl = DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id");
    if (TextUtils.isEmpty(entryIdFromUrl))
        return false;
    return domDistillerService.hasEntry(entryIdFromUrl);
}
Also used : DomDistillerService(org.chromium.components.dom_distiller.core.DomDistillerService)

Example 4 with DomDistillerService

use of org.chromium.components.dom_distiller.core.DomDistillerService in project AndroidChromium by JackyAndroid.

the class CustomTabToolbar method setUrlToPageUrl.

@Override
public void setUrlToPageUrl() {
    if (getCurrentTab() == null) {
        mUrlBar.setUrl("", null);
        return;
    }
    String url = getCurrentTab().getUrl().trim();
    // is "about:blank". We should not display it.
    if (NativePageFactory.isNativePageUrl(url, getCurrentTab().isIncognito()) || UrlConstants.ABOUT_BLANK.equals(url)) {
        mUrlBar.setUrl("", null);
        return;
    }
    String displayText = getToolbarDataProvider().getText();
    Pair<String, String> urlText = LocationBarLayout.splitPathFromUrlDisplayText(displayText);
    displayText = urlText.first;
    if (DomDistillerUrlUtils.isDistilledPage(url)) {
        if (isStoredArticle(url)) {
            Profile profile = getCurrentTab().getProfile();
            DomDistillerService domDistillerService = DomDistillerServiceFactory.getForProfile(profile);
            String originalUrl = domDistillerService.getUrlForEntry(DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id"));
            displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
        } else if (DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url) != null) {
            String originalUrl = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
            displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
        }
    }
    if (mUrlBar.setUrl(url, displayText)) {
        mUrlBar.deEmphasizeUrl();
        mUrlBar.emphasizeUrl();
    }
}
Also used : DomDistillerService(org.chromium.components.dom_distiller.core.DomDistillerService) Profile(org.chromium.chrome.browser.profiles.Profile)

Example 5 with DomDistillerService

use of org.chromium.components.dom_distiller.core.DomDistillerService in project AndroidChromium by JackyAndroid.

the class ToolbarModelImpl method getText.

@Override
public String getText() {
    if (mTab != null && mTab.isBlimpTab())
        return mTab.getUrl().trim();
    String displayText = super.getText();
    if (mTab == null || mTab.isFrozen())
        return displayText;
    String url = mTab.getUrl().trim();
    if (DomDistillerUrlUtils.isDistilledPage(url)) {
        if (isStoredArticle(url)) {
            DomDistillerService domDistillerService = DomDistillerServiceFactory.getForProfile(mTab.getProfile());
            String originalUrl = domDistillerService.getUrlForEntry(DomDistillerUrlUtils.getValueForKeyInUrl(url, "entry_id"));
            displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
        } else if (DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url) != null) {
            String originalUrl = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
            displayText = DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl);
        }
    } else if (mTab.isOfflinePage() && mTab.getSecurityLevel() == ConnectionSecurityLevel.NONE) {
        String originalUrl = mTab.getOriginalUrl();
        displayText = OfflinePageUtils.stripSchemeFromOnlineUrl(DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl));
    }
    return displayText;
}
Also used : DomDistillerService(org.chromium.components.dom_distiller.core.DomDistillerService)

Aggregations

DomDistillerService (org.chromium.components.dom_distiller.core.DomDistillerService)5 Profile (org.chromium.chrome.browser.profiles.Profile)1