Search in sources :

Example 6 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method maybeShowNativePage.

/**
     * Shows a native page for url if it's a valid chrome-native URL. Otherwise, does nothing.
     * @param url The url of the current navigation.
     * @param forceReload If true, the current native page (if any) will not be reused, even if it
     *                    matches the URL.
     * @return True, if a native page was displayed for url.
     */
boolean maybeShowNativePage(String url, boolean forceReload) {
    NativePage candidateForReuse = forceReload ? null : getNativePage();
    NativePage nativePage = NativePageFactory.createNativePageForURL(url, candidateForReuse, this, getTabModelSelector(), getActivity());
    if (nativePage != null) {
        showNativePage(nativePage);
        notifyPageTitleChanged();
        notifyFaviconChanged();
        return true;
    }
    return false;
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage)

Example 7 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class ToolbarManager method shouldShowCusrsorInLocationBar.

private boolean shouldShowCusrsorInLocationBar() {
    Tab tab = mToolbarModel.getTab();
    if (tab == null)
        return false;
    NativePage nativePage = tab.getNativePage();
    if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) {
        return false;
    }
    Context context = mToolbar.getContext();
    return DeviceFormFactor.isTablet(context) && context.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) Context(android.content.Context) Tab(org.chromium.chrome.browser.tab.Tab) IncognitoNewTabPage(org.chromium.chrome.browser.ntp.IncognitoNewTabPage) IncognitoNewTabPage(org.chromium.chrome.browser.ntp.IncognitoNewTabPage) NewTabPage(org.chromium.chrome.browser.ntp.NewTabPage)

Example 8 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class TabContentManager method readbackNativePage.

private Bitmap readbackNativePage(final Tab tab, float scale) {
    Bitmap bitmap = null;
    NativePage page = tab.getNativePage();
    if (page == null) {
        return bitmap;
    }
    View viewToDraw = page.getView();
    if (viewToDraw == null || viewToDraw.getWidth() == 0 || viewToDraw.getHeight() == 0) {
        return bitmap;
    }
    if (page instanceof InvalidationAwareThumbnailProvider) {
        if (!((InvalidationAwareThumbnailProvider) page).shouldCaptureThumbnail()) {
            return null;
        }
    }
    int overlayTranslateY = mContentOffsetProvider.getOverlayTranslateY();
    try {
        bitmap = Bitmap.createBitmap((int) (viewToDraw.getWidth() * mThumbnailScale), (int) ((viewToDraw.getHeight() - overlayTranslateY) * mThumbnailScale), Bitmap.Config.ARGB_8888);
    } catch (OutOfMemoryError ex) {
        return null;
    }
    Canvas c = new Canvas(bitmap);
    c.scale(scale, scale);
    c.translate(0.f, -overlayTranslateY);
    if (page instanceof InvalidationAwareThumbnailProvider) {
        ((InvalidationAwareThumbnailProvider) page).captureThumbnail(c);
    } else {
        viewToDraw.draw(c);
    }
    return bitmap;
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) View(android.view.View)

Example 9 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class NativePageAssassin method freeze.

private void freeze(Tab tab) {
    if (tab == null)
        return;
    NativePage pageToFreeze = tab.getNativePage();
    if (pageToFreeze == null || pageToFreeze instanceof FrozenNativePage || pageToFreeze.getView().getParent() != null) {
        return;
    }
    tab.freezeNativePage();
}
Also used : FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage) NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage)

Example 10 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class NativePageFactory method createNativePageForURL.

@VisibleForTesting
static NativePage createNativePageForURL(String url, NativePage candidatePage, Tab tab, TabModelSelector tabModelSelector, ChromeActivity activity, boolean isIncognito) {
    NativePage page;
    switch(nativePageType(url, candidatePage, isIncognito)) {
        case NONE:
            return null;
        case CANDIDATE:
            page = candidatePage;
            break;
        case NTP:
            page = sNativePageBuilder.buildNewTabPage(activity, tab, tabModelSelector);
            break;
        case BOOKMARKS:
            page = sNativePageBuilder.buildBookmarksPage(activity, tab);
            break;
        case DOWNLOADS:
            page = sNativePageBuilder.buildDownloadsPage(activity, tab);
            break;
        case RECENT_TABS:
            page = sNativePageBuilder.buildRecentTabsPage(activity, tab);
            break;
        case PHYSICAL_WEB:
            page = sNativePageBuilder.buildPhysicalWebDiagnosticsPage(activity, tab);
            break;
        default:
            assert false;
            return null;
    }
    page.updateForUrl(url);
    return page;
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) VisibleForTesting(org.chromium.base.VisibleForTesting)

Aggregations

NativePage (org.chromium.chrome.browser.NativePage)10 FrozenNativePage (org.chromium.chrome.browser.FrozenNativePage)7 SuppressLint (android.annotation.SuppressLint)1 Application (android.app.Application)1 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Rect (android.graphics.Rect)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.FrameLayout.LayoutParams)1 VisibleForTesting (org.chromium.base.VisibleForTesting)1 ChromeApplication (org.chromium.chrome.browser.ChromeApplication)1 SwipeRefreshHandler (org.chromium.chrome.browser.SwipeRefreshHandler)1 ChromeDownloadDelegate (org.chromium.chrome.browser.download.ChromeDownloadDelegate)1 InfoBarContainer (org.chromium.chrome.browser.infobar.InfoBarContainer)1 IncognitoNewTabPage (org.chromium.chrome.browser.ntp.IncognitoNewTabPage)1 NewTabPage (org.chromium.chrome.browser.ntp.NewTabPage)1 Tab (org.chromium.chrome.browser.tab.Tab)1