use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class LocationBarLayout method loadUrl.
private void loadUrl(String url, int transition) {
Tab currentTab = getCurrentTab();
// side is initialized
assert mNativeInitialized : "Loading URL before native side initialized";
if (currentTab != null && (currentTab.isNativePage() || NewTabPage.isNTPUrl(currentTab.getUrl()))) {
NewTabPageUma.recordOmniboxNavigation(url, transition);
// the page as it does when you click and press enter on any other site.
if (url.isEmpty())
url = currentTab.getUrl();
}
// Loads the |url| in the current ContentView and gives focus to the ContentView.
if (currentTab != null && !url.isEmpty()) {
LoadUrlParams loadUrlParams = new LoadUrlParams(url);
loadUrlParams.setVerbatimHeaders(GeolocationHeader.getGeoHeader(getContext(), url, currentTab.isIncognito()));
loadUrlParams.setTransitionType(transition | PageTransition.FROM_ADDRESS_BAR);
currentTab.loadUrl(loadUrlParams);
setUrlToPageUrl();
RecordUserAction.record("MobileOmniboxUse");
RecordUserAction.record("MobileTabClobbered");
} else {
setUrlToPageUrl();
}
if (currentTab != null)
currentTab.requestFocus();
// Prevent any upcoming omnibox suggestions from showing. We have to do this after we load
// the URL as this will hide the suggestions and trigger a cancel of the prerendered page.
stopAutocomplete(true);
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class LocationBarLayout method startZeroSuggest.
/**
* Make a zero suggest request if native is loaded, the URL bar has focus, and the
* current tab is not incognito.
*/
private void startZeroSuggest() {
// Reset "edited" state in the omnibox if zero suggest is triggered -- new edits
// now count as a new session.
mHasStartedNewOmniboxEditSession = false;
mNewOmniboxEditSessionTimestamp = -1;
Tab currentTab = getCurrentTab();
if (mNativeInitialized && mUrlHasFocus && currentTab != null && !currentTab.isIncognito()) {
mAutocomplete.startZeroSuggest(currentTab.getProfile(), mUrlBar.getQueryText(), currentTab.getUrl(), mUrlFocusedFromFakebox);
}
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class LocationBarLayout method updateUseDarkColors.
/**
* Checks the current specs and updates {@link LocationBar#mUseDarkColors} if necessary.
* @return Whether {@link LocationBar#mUseDarkColors} has been updated.
*/
private boolean updateUseDarkColors() {
Tab tab = getCurrentTab();
boolean brandColorNeedsLightText = false;
if (getToolbarDataProvider().isUsingBrandColor() && !mUrlHasFocus) {
int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
brandColorNeedsLightText = ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
}
boolean useDarkColors = tab == null || !(tab.isIncognito() || brandColorNeedsLightText);
boolean hasChanged = useDarkColors != mUseDarkColors;
mUseDarkColors = useDarkColors;
return hasChanged;
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class ChromeActivity method onPauseWithNative.
@Override
public void onPauseWithNative() {
RecordUserAction.record("MobileGoToBackground");
Tab tab = getActivityTab();
if (tab != null) {
getTabContentManager().cacheTabThumbnail(tab);
}
markSessionEnd();
super.onPauseWithNative();
}
use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class ChromeActivity method onWindowFocusChanged.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Tab tab = getActivityTab();
if (tab == null)
return;
if (hasFocus) {
tab.onActivityShown();
} else {
boolean stopped = ApplicationStatus.getStateForActivity(this) == ActivityState.STOPPED;
if (stopped)
tab.onActivityHidden();
}
}
Aggregations