Java Code Examples for org.chromium.chrome.browser.tab.Tab#getNativePage()
The following examples show how to use
org.chromium.chrome.browser.tab.Tab#getNativePage() .
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: VrShellDelegate.java From AndroidChromium with Apache License 2.0 | 6 votes |
private boolean canEnterVR(Tab tab) { if (!LibraryLoader.isInitialized()) { return false; } // If vr isn't in the build, or we haven't initialized yet, or vr shell is not enabled and // this is not a web vr request, then return immediately. if (!mVrAvailable || mNativeVrShellDelegate == 0 || (!isVrShellEnabled() && !(mRequestedWebVR || mListeningForWebVrActivate))) { return false; } // TODO(mthiesse): When we have VR UI for opening new tabs, etc., allow VR Shell to be // entered without any current tabs. if (tab == null || tab.getContentViewCore() == null) { return false; } // For now we don't handle native pages. crbug.com/661609 if (tab.getNativePage() != null || tab.isShowingSadTab()) { return false; } // crbug.com/667781 if (MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity)) { return false; } return true; }
Example 2
Source File: NativePageAssassin.java From AndroidChromium with Apache License 2.0 | 5 votes |
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 3
Source File: ToolbarManager.java From 365browser with Apache License 2.0 | 5 votes |
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 4
Source File: NativePageAssassin.java From 365browser with Apache License 2.0 | 5 votes |
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 5
Source File: TabContentManager.java From 365browser with Apache License 2.0 | 5 votes |
/** * Cache the content of a tab as a thumbnail. * @param tab The tab whose content we will cache. */ public void cacheTabThumbnail(final Tab tab) { if (mNativeTabContentManager != 0 && mSnapshotsEnabled) { if (tab.getNativePage() != null) { Bitmap nativePageBitmap = readbackNativePage(tab, mThumbnailScale); if (nativePageBitmap == null) return; nativeCacheTabWithBitmap(mNativeTabContentManager, tab, nativePageBitmap, mThumbnailScale); nativePageBitmap.recycle(); } else { if (tab.getWebContents() == null) return; nativeCacheTab(mNativeTabContentManager, tab, mThumbnailScale); } } }
Example 6
Source File: TabContentManager.java From 365browser with Apache License 2.0 | 5 votes |
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 7
Source File: LayoutManagerDocument.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void initLayoutTabFromHost(final int tabId) { if (getTabModelSelector() == null || getActiveLayout() == null) return; TabModelSelector selector = getTabModelSelector(); Tab tab = selector.getTabById(tabId); if (tab == null) return; LayoutTab layoutTab = mTabCache.get(tabId); if (layoutTab == null) return; String url = tab.getUrl(); boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX); int themeColor = tab.getThemeColor(); boolean canUseLiveTexture = tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage; boolean isNtp = tab.getNativePage() instanceof NewTabPage; boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground( mContext.getResources(), isNtp, themeColor), ColorUtils.getTextBoxAlphaForToolbarBackground(tab)); if (needsUpdate) requestUpdate(); mHost.requestRender(); }
Example 8
Source File: ColorUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return Alpha for the textbox given a Tab. */ public static float getTextBoxAlphaForToolbarBackground(Tab tab) { int color = tab.getThemeColor(); if (tab.getNativePage() instanceof NewTabPage) { if (((NewTabPage) tab.getNativePage()).isLocationBarShownInNTP()) return 0f; } return shouldUseOpaqueTextboxBackground(color) ? 1f : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA; }
Example 9
Source File: ColorUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The base color for the textbox given a toolbar background color. */ public static int getTextBoxColorForToolbarBackground(Resources res, Tab tab, int color) { if (shouldUseOpaqueTextboxBackground(color)) { // NTP should have no visible textbox in the toolbar, so just return the toolbar's // background color. if (tab.getNativePage() instanceof NewTabPage) { return ApiCompatibilityUtils.getColor(res, R.color.ntp_bg); } return Color.WHITE; } return getColorWithOverlay(color, Color.WHITE, LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA); }
Example 10
Source File: ToolbarModelImpl.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public NewTabPage getNewTabPageForCurrentTab() { Tab currentTab = getTab(); if (currentTab != null && currentTab.getNativePage() instanceof NewTabPage) { return (NewTabPage) currentTab.getNativePage(); } return null; }
Example 11
Source File: ToolbarManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
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 delion with Apache License 2.0 | 5 votes |
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 13
Source File: TabContentManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Cache the content of a tab as a thumbnail. * @param tab The tab whose content we will cache. */ public void cacheTabThumbnail(final Tab tab) { if (mNativeTabContentManager != 0 && mSnapshotsEnabled) { if (tab.getNativePage() != null) { Bitmap nativePageBitmap = readbackNativePage(tab, mThumbnailScale); if (nativePageBitmap == null) return; nativeCacheTabWithBitmap(mNativeTabContentManager, tab, nativePageBitmap, mThumbnailScale); nativePageBitmap.recycle(); } else { if (tab.getWebContents() == null) return; nativeCacheTab(mNativeTabContentManager, tab, mThumbnailScale); } } }
Example 14
Source File: TabContentManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
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 15
Source File: ColorUtils.java From delion with Apache License 2.0 | 5 votes |
/** * @return Alpha for the textbox given a Tab. */ public static float getTextBoxAlphaForToolbarBackground(Tab tab) { int color = tab.getThemeColor(); if (tab.getNativePage() instanceof NewTabPage) { if (((NewTabPage) tab.getNativePage()).isLocationBarShownInNTP()) return 0f; } return shouldUseOpaqueTextboxBackground(color) ? 1f : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA; }
Example 16
Source File: ColorUtils.java From delion with Apache License 2.0 | 5 votes |
/** * @return The base color for the textbox given a toolbar background color. */ public static int getTextBoxColorForToolbarBackground(Resources res, Tab tab, int color) { if (shouldUseOpaqueTextboxBackground(color)) { // NTP should have no visible textbox in the toolbar, so just return the toolbar's // background color. if (tab.getNativePage() instanceof NewTabPage) { return NtpColorUtils.getToolbarBackgroundColorResource(res); } return Color.WHITE; } return getColorWithOverlay(color, Color.WHITE, LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA); }
Example 17
Source File: ToolbarModelImpl.java From 365browser with Apache License 2.0 | 5 votes |
@Override public NewTabPage getNewTabPageForCurrentTab() { Tab currentTab = getTab(); if (currentTab != null && currentTab.getNativePage() instanceof NewTabPage) { return (NewTabPage) currentTab.getNativePage(); } return null; }
Example 18
Source File: ToolbarManager.java From delion with Apache License 2.0 | 5 votes |
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 19
Source File: NativePageAssassin.java From delion with Apache License 2.0 | 5 votes |
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 20
Source File: TabContentManager.java From delion with Apache License 2.0 | 5 votes |
/** * Cache the content of a tab as a thumbnail. * @param tab The tab whose content we will cache. */ public void cacheTabThumbnail(final Tab tab) { if (mNativeTabContentManager != 0 && mSnapshotsEnabled) { if (tab.getNativePage() != null) { Bitmap nativePageBitmap = readbackNativePage(tab, mThumbnailScale); if (nativePageBitmap == null) return; nativeCacheTabWithBitmap(mNativeTabContentManager, tab, nativePageBitmap, mThumbnailScale); nativePageBitmap.recycle(); } else { nativeCacheTab(mNativeTabContentManager, tab, tab.getContentViewCore(), mThumbnailScale); } } }