org.chromium.chrome.browser.NativePage Java Examples

The following examples show how to use org.chromium.chrome.browser.NativePage. 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: Tab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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) {
    // While detached for reparenting we don't have an owning Activity, or TabModelSelector,
    // so we can't create the native page. The native page will be created once reparenting is
    // completed.
    if (mIsDetached) return false;
    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;
}
 
Example #2
Source File: Tab.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * 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) {
    // While detached for reparenting we don't have an owning Activity, or TabModelSelector,
    // so we can't create the native page. The native page will be created once reparenting is
    // completed.
    if (mIsDetachedForReparenting) return false;
    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;
}
 
Example #3
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        if (tab.isIncognito()) {
            return new ChromeHomeIncognitoNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        } else {
            return new ChromeHomeNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        }
    } else if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, new TabShim(tab), tabModelSelector);
    }
}
 
Example #4
Source File: NativePageFactory.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, tab, tabModelSelector);
    }
}
 
Example #5
Source File: NativePageAssassin.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #6
Source File: NativePageFactory.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private static NativePageType nativePageType(String url, NativePage candidatePage,
        boolean isIncognito) {
    if (url == null) return NativePageType.NONE;

    Uri uri = Uri.parse(url);
    if (!CHROME_NATIVE_SCHEME.equals(uri.getScheme())) {
        return NativePageType.NONE;
    }

    String host = uri.getHost();
    if (candidatePage != null && candidatePage.getHost().equals(host)) {
        return NativePageType.CANDIDATE;
    }

    if (UrlConstants.NTP_HOST.equals(host)) {
        return NativePageType.NTP;
    } else if (UrlConstants.BOOKMARKS_HOST.equals(host)) {
        return NativePageType.BOOKMARKS;
    } else if (UrlConstants.DOWNLOADS_HOST.equals(host)) {
        return NativePageType.DOWNLOADS;
    } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) {
        return NativePageType.RECENT_TABS;
    } else if (UrlConstants.PHYSICAL_WEB_HOST.equals(host)) {
        if (ChromeFeatureList.isEnabled("PhysicalWeb")) {
            return NativePageType.PHYSICAL_WEB;
        } else {
            return NativePageType.NONE;
        }
    } else {
        return NativePageType.NONE;
    }
}
 
Example #7
Source File: NativePageFactory.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: TabContentManager.java    From delion with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the given {@code nativePage} if it's not already showing.
 * @param nativePage The {@link NativePage} to show.
 */
private void showNativePage(NativePage nativePage) {
    if (mNativePage == nativePage) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = nativePage;
    pushNativePageStateToNavigationEntry();
    // Notifying of theme color change before content change because some of
    // the observers depend on the theme information being correct in
    // onContentChanged().
    updateThemeColorIfNeeded(false);
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #10
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Hides the current {@link NativePage}, if any, and shows the {@link ContentViewCore}'s view.
 */
protected void showRenderedPage() {
    updateTitle();

    if (mNativePage == null) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #11
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: TabContentManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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;
        }
    }

    float 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;
}
 
Example #13
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static NativePageType nativePageType(String url, NativePage candidatePage,
        boolean isIncognito) {
    if (url == null) return NativePageType.NONE;

    Uri uri = Uri.parse(url);
    if (!UrlConstants.CHROME_NATIVE_SCHEME.equals(uri.getScheme())) {
        return NativePageType.NONE;
    }

    String host = uri.getHost();
    if (candidatePage != null && candidatePage.getHost().equals(host)) {
        return NativePageType.CANDIDATE;
    }

    if (UrlConstants.NTP_HOST.equals(host)) {
        return NativePageType.NTP;
    } else if (UrlConstants.BOOKMARKS_HOST.equals(host)) {
        return NativePageType.BOOKMARKS;
    } else if (UrlConstants.DOWNLOADS_HOST.equals(host)) {
        return NativePageType.DOWNLOADS;
    } else if (UrlConstants.HISTORY_HOST.equals(host)) {
        return NativePageType.HISTORY;
    } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) {
        return NativePageType.RECENT_TABS;
    } else if (UrlConstants.PHYSICAL_WEB_DIAGNOSTICS_HOST.equals(host)) {
        if (ChromeFeatureList.isEnabled("PhysicalWeb")) {
            return NativePageType.PHYSICAL_WEB;
        } else {
            return NativePageType.NONE;
        }
    } else {
        return NativePageType.NONE;
    }
}
 
Example #14
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@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 HISTORY:
            page = sNativePageBuilder.buildHistoryPage(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;
}
 
Example #15
Source File: NativePageAssassin.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #16
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the given {@code nativePage} if it's not already showing.
 * @param nativePage The {@link NativePage} to show.
 */
private void showNativePage(NativePage nativePage) {
    if (mNativePage == nativePage) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = nativePage;
    pushNativePageStateToNavigationEntry();
    // Notifying of theme color change before content change because some of
    // the observers depend on the theme information being correct in
    // onContentChanged().
    updateThemeColorIfNeeded(false);
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #17
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Hides the current {@link NativePage}, if any, and shows the {@link ContentViewCore}'s view.
 */
protected void showRenderedPage() {
    updateTitle();

    if (mNativePage == null) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #18
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called to swap out the current view with the one passed in.
 *
 * @param newContentViewCore The content view that should be swapped into the tab.
 * @param deleteOldNativeWebContents Whether to delete the native web
 *         contents of old view.
 * @param didStartLoad Whether
 *         WebContentsObserver::DidStartProvisionalLoadForFrame() has
 *         already been called.
 * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has
 *         already been called.
 */
public void swapContentViewCore(ContentViewCore newContentViewCore,
        boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) {
    int originalWidth = 0;
    int originalHeight = 0;
    if (mContentViewCore != null) {
        originalWidth = mContentViewCore.getViewportWidthPix();
        originalHeight = mContentViewCore.getViewportHeightPix();
        mContentViewCore.onHide();
    }

    Rect bounds = new Rect();
    if (originalWidth == 0 && originalHeight == 0) {
        bounds = ExternalPrerenderHandler.estimateContentSize(
                (Application) getApplicationContext(), false);
        originalWidth = bounds.right - bounds.left;
        originalHeight = bounds.bottom - bounds.top;
    }

    destroyContentViewCore(deleteOldNativeWebContents);
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    // Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
    // next onShow() call would send a resize message with the current ContentViewCore size
    // (zero) to the renderer process, although the new size will be set soon.
    // However, this size fluttering may confuse Blink and rendered result can be broken
    // (see http://crbug.com/340987).
    newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
    if (!bounds.isEmpty()) {
        nativeOnPhysicalBackingSizeChanged(mNativeTabAndroid,
                newContentViewCore.getWebContents(), bounds.right, bounds.bottom);
    }
    newContentViewCore.onShow();
    setContentViewCore(newContentViewCore);

    destroyNativePageInternal(previousNativePage);
    for (TabObserver observer : mObservers) {
        observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
    }
}
 
Example #19
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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.getResources().getConfiguration().keyboard
            == Configuration.KEYBOARD_QWERTY;
}
 
Example #20
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called to swap out the current view with the one passed in.
 *
 * @param newContentViewCore The content view that should be swapped into the tab.
 * @param deleteOldNativeWebContents Whether to delete the native web
 *         contents of old view.
 * @param didStartLoad Whether
 *         WebContentsObserver::DidStartProvisionalLoadForFrame() has
 *         already been called.
 * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has
 *         already been called.
 */
public void swapContentViewCore(ContentViewCore newContentViewCore,
        boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) {
    int originalWidth = 0;
    int originalHeight = 0;
    if (mContentViewCore != null) {
        originalWidth = mContentViewCore.getViewportWidthPix();
        originalHeight = mContentViewCore.getViewportHeightPix();
        mContentViewCore.onHide();
    }
    destroyContentViewCore(deleteOldNativeWebContents);
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    setContentViewCore(newContentViewCore);
    // Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
    // next onShow() call would send a resize message with the current ContentViewCore size
    // (zero) to the renderer process, although the new size will be set soon.
    // However, this size fluttering may confuse Blink and rendered result can be broken
    // (see http://crbug.com/340987).
    mContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
    mContentViewCore.onShow();
    mContentViewCore.attachImeAdapter();

    // If the URL has already committed (e.g. prerendering), tell process management logic that
    // it can rely on the process visibility signal for binding management.
    // TODO: Call ChildProcessLauncher#determinedVisibility() at a more intuitive time.
    // See crbug.com/537671
    if (!mContentViewCore.getWebContents().getLastCommittedUrl().equals("")) {
        ChildProcessLauncher.determinedVisibility(mContentViewCore.getCurrentRenderProcessId());
    }

    destroyNativePageInternal(previousNativePage);
    for (TabObserver observer : mObservers) {
        observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
    }
}
 
Example #21
Source File: NativePageAssassin.java    From delion with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #22
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the given {@code nativePage} if it's not already showing.
 * @param nativePage The {@link NativePage} to show.
 */
private void showNativePage(NativePage nativePage) {
    if (mNativePage == nativePage) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = nativePage;
    pushNativePageStateToNavigationEntry();
    // Notifying of theme color change before content change because some of
    // the observers depend on the theme information being correct in
    // onContentChanged().
    updateThemeColorIfNeeded(false);
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #23
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Hides the current {@link NativePage}, if any, and shows the {@link ContentViewCore}'s view.
 */
protected void showRenderedPage() {
    updateTitle();

    if (mNativePage == null) return;
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
 
Example #24
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source File: NativePageFactory.java    From delion with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static NativePage createNativePageForURL(String url, NativePage candidatePage,
        Tab tab, TabModelSelector tabModelSelector, Activity 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 RECENT_TABS:
            page = sNativePageBuilder.buildRecentTabsPage(activity, tab);
            break;
        case PHYSICAL_WEB:
            page = sNativePageBuilder.buildPhysicalWebDiagnosticsPage(activity);
            break;
        default:
            assert false;
            return null;
    }
    page.updateForUrl(url);
    return page;
}
 
Example #26
Source File: ToolbarManager.java    From delion with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #27
Source File: NativePageFactory.java    From delion with Apache License 2.0 5 votes vote down vote up
private static NativePageType nativePageType(String url, NativePage candidatePage,
        boolean isIncognito) {
    if (url == null) return NativePageType.NONE;

    Uri uri = Uri.parse(url);
    if (!CHROME_NATIVE_SCHEME.equals(uri.getScheme())) {
        return NativePageType.NONE;
    }

    String host = uri.getHost();
    if (candidatePage != null && candidatePage.getHost().equals(host)) {
        return NativePageType.CANDIDATE;
    }

    if (UrlConstants.NTP_HOST.equals(host)) {
        return NativePageType.NTP;
    } else if (UrlConstants.BOOKMARKS_HOST.equals(host)) {
        return NativePageType.BOOKMARKS;
    } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) {
        return NativePageType.RECENT_TABS;
    } else if (UrlConstants.PHYSICAL_WEB_HOST.equals(host)) {
        if (ChromeFeatureList.isEnabled("PhysicalWeb")) {
            return NativePageType.PHYSICAL_WEB;
        } else {
            return NativePageType.NONE;
        }
    } else {
        return NativePageType.NONE;
    }
}
 
Example #28
Source File: TabContentManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: NativePageFactory.java    From delion with Apache License 2.0 5 votes vote down vote up
protected NativePage buildNewTabPage(Activity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, tab, tabModelSelector);
    }
}
 
Example #30
Source File: NativePageFactory.java    From delion with Apache License 2.0 4 votes vote down vote up
protected NativePage buildPhysicalWebDiagnosticsPage(Activity activity) {
    return new PhysicalWebDiagnosticsPage(activity);
}