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;
}
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;
}
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;
}
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();
}
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;
}
Aggregations