use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class FullScreenActivity method preInflationStartup.
@Override
public void preInflationStartup() {
super.preInflationStartup();
setTabCreators(createTabDelegate(false), createTabDelegate(true));
setTabModelSelector(new SingleTabModelSelector(this, false, false) {
@Override
public Tab openNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent, boolean incognito) {
getTabCreator(incognito).createNewTab(loadUrlParams, type, parent);
return null;
}
});
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class FullScreenActivity method createTab.
/**
* Creates the {@link Tab} used by the FullScreenActivity.
* If the {@code savedInstanceState} exists, then the user did not intentionally close the app
* by swiping it away in the recent tasks list. In that case, we try to restore the tab from
* disk.
*/
private Tab createTab() {
Tab tab = null;
boolean unfreeze = false;
int tabId = Tab.INVALID_TAB_ID;
String tabUrl = null;
if (getSavedInstanceState() != null) {
tabId = getSavedInstanceState().getInt(BUNDLE_TAB_ID, Tab.INVALID_TAB_ID);
tabUrl = getSavedInstanceState().getString(BUNDLE_TAB_URL);
}
if (tabId != Tab.INVALID_TAB_ID && tabUrl != null && getActivityDirectory() != null) {
// Restore the tab.
TabState tabState = TabState.restoreTabState(getActivityDirectory(), tabId);
tab = new Tab(tabId, Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), TabLaunchType.FROM_RESTORE, TabCreationState.FROZEN_ON_RESTORE, tabState);
unfreeze = true;
}
if (tab == null) {
tab = new Tab(Tab.INVALID_TAB_ID, Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), TabLaunchType.FROM_CHROME_UI, null, null);
}
tab.initialize(null, getTabContentManager(), createTabDelegateFactory(), false, unfreeze);
mWebContentsObserver = new WebContentsObserver(tab.getWebContents()) {
@Override
public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFrame, String url, int transitionType) {
if (isMainFrame) {
// Notify the renderer to permanently hide the top controls since they do
// not apply to fullscreen content views.
getActivityTab().updateTopControlsState(getActivityTab().getTopControlsStateConstraints(), true);
}
}
};
return tab;
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class TabPersistentStore method saveNextTab.
private void saveNextTab() {
if (mSaveTabTask != null)
return;
if (!mTabsToSave.isEmpty()) {
Tab tab = mTabsToSave.removeFirst();
mSaveTabTask = new SaveTabTask(tab);
mSaveTabTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
} else {
saveTabListAsynchronously();
}
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class TabWindowManager method getIncognitoTabCount.
/**
* @return The total number of incognito tabs across all tab model selectors.
*/
public int getIncognitoTabCount() {
int count = 0;
for (int i = 0; i < mSelectors.size(); i++) {
if (mSelectors.get(i) != null) {
count += mSelectors.get(i).getModel(true).getCount();
}
}
// Count tabs that are moving between activities (e.g. a tab that was recently reparented
// and hasn't been attached to its new activity yet).
SparseArray<AsyncTabParams> asyncTabParams = AsyncTabParamsManager.getAsyncTabParams();
for (int i = 0; i < asyncTabParams.size(); i++) {
Tab tab = asyncTabParams.valueAt(i).getTabToReparent();
if (tab != null && tab.isIncognito())
count++;
}
return count;
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class VrShellDelegate method enterVRIfNecessary.
/**
* Enters VR Shell, displaying browser UI and tab contents in VR.
*
* This function performs native initialization, and so must only be called after native
* libraries are ready.
* @param inWebVR If true should begin displaying WebVR content rather than the VrShell UI.
* @return Whether or not we are in VR when this function returns.
*/
@CalledByNative
public boolean enterVRIfNecessary(boolean inWebVR) {
if (!mVrShellEnabled || mNativeVrShellDelegate == 0)
return false;
Tab tab = mActivity.getActivityTab();
// entered without any current tabs.
if (tab == null || tab.getContentViewCore() == null) {
return false;
}
if (mInVr)
return true;
// VrShell must be initialized in Landscape mode due to a bug in the GVR library.
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
if (!createVrShell()) {
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
return false;
}
addVrViews();
setupVrModeWindowFlags();
mVrShell.initializeNative(tab, this);
if (inWebVR)
mVrShell.setWebVrModeEnabled(true);
mVrShell.setVrModeEnabled(true);
mInVr = true;
tab.updateFullscreenEnabledState();
return true;
}
Aggregations