use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.
the class LocationBarLayout method updateOmniboxResultsContainerVisibility.
private void updateOmniboxResultsContainerVisibility(boolean visible) {
boolean currentlyVisible = mOmniboxResultsContainer.getVisibility() == VISIBLE;
if (currentlyVisible == visible)
return;
ChromeActivity activity = (ChromeActivity) mWindowAndroid.getActivity().get();
if (visible) {
mOmniboxResultsContainer.setVisibility(VISIBLE);
if (activity != null)
activity.addViewObscuringAllTabs(mOmniboxResultsContainer);
} else {
mOmniboxResultsContainer.setVisibility(INVISIBLE);
if (activity != null)
activity.removeViewObscuringAllTabs(mOmniboxResultsContainer);
}
}
use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.
the class ChromeDownloadDelegate method closeBlankTab.
/**
* Close a blank tab just opened for the download purpose.
* @return true iff the tab was (already) closed.
*/
private boolean closeBlankTab() {
if (mTab == null) {
// We do not want caller to dismiss infobar.
return true;
}
WebContents contents = mTab.getWebContents();
boolean isInitialNavigation = contents == null || contents.getNavigationController().isInitialNavigation();
if (isInitialNavigation) {
// Tab is created just for download, close it.
Activity activity = mTab.getWindowAndroid().getActivity().get();
if (!(activity instanceof ChromeActivity))
return true;
TabModelSelector selector = ((ChromeActivity) activity).getTabModelSelector();
return selector == null ? true : selector.closeTab(mTab);
}
return false;
}
use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.
the class Tab method detachAndStartReparenting.
/**
* Begins the tab reparenting process. Detaches the tab from its current activity and fires
* an Intent to reparent the tab into its new host activity.
*
* @param intent An optional intent with the desired component, flags, or extras to use when
* launching the new host activity. This intent's URI and action will be
* overriden. This may be null if no intent customization is needed.
* @param startActivityOptions Options to pass to {@link Activity#startActivity(Intent, Bundle)}
* @param finalizeCallback A callback that will be called after the tab is attached to the new
* host activity in {@link #attachAndFinishReparenting}.
* @return Whether reparenting succeeded. If false, the tab was not removed and the intent was
* not fired.
*/
public boolean detachAndStartReparenting(Intent intent, Bundle startActivityOptions, Runnable finalizeCallback) {
ChromeActivity activity = getActivity();
if (activity == null)
return false;
if (intent == null)
intent = new Intent();
if (intent.getComponent() == null) {
intent.setClass(mThemedApplicationContext, ChromeLauncherActivity.class);
}
intent.setAction(Intent.ACTION_VIEW);
if (TextUtils.isEmpty(intent.getDataString()))
intent.setData(Uri.parse(getUrl()));
if (isIncognito()) {
intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
}
IntentHandler.addTrustedIntentExtras(intent, activity);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_REPARENTING)) {
TabModelSelector tabModelSelector = getTabModelSelector();
if (tabModelSelector == null)
return false;
mIsDetachedForReparenting = true;
// Add the tab to AsyncTabParamsManager before removing it from the current model to
// ensure the global count of tabs is correct. See crbug.com/611806.
intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId);
AsyncTabParamsManager.add(mId, new TabReparentingParams(this, intent, finalizeCallback));
tabModelSelector.getModel(mIncognito).removeTab(this);
// TODO(mthiesse): File a bug when crbug isn't down.
if (mContentViewCore != null)
mContentViewCore.updateWindowAndroid(null);
attachTabContentManager(null);
}
activity.startActivity(intent, startActivityOptions);
return true;
}
use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.
the class LocationBarLayout method onUrlFocusChange.
/**
* Triggered when the URL input field has gained or lost focus.
* @param hasFocus Whether the URL field has gained focus.
*/
public void onUrlFocusChange(boolean hasFocus) {
mUrlHasFocus = hasFocus;
updateButtonVisibility();
updateNavigationButton();
Tab currentTab = getCurrentTab();
if (hasFocus) {
if (mNativeInitialized)
RecordUserAction.record("FocusLocation");
mUrlBar.deEmphasizeUrl();
} else {
mUrlFocusedFromFakebox = false;
mUrlFocusedWithoutAnimations = false;
hideSuggestions();
// Focus change caused by a close-tab may result in an invalid current tab.
if (currentTab != null) {
setUrlToPageUrl();
emphasizeUrl();
}
}
if (getToolbarDataProvider().isUsingBrandColor()) {
updateVisualsForState();
if (mUrlHasFocus)
mUrlBar.selectAll();
}
changeLocationBarIcon();
updateVerboseStatusVisibility();
updateLocationBarIconContainerVisibility();
mUrlBar.setCursorVisible(hasFocus);
if (!mUrlFocusedWithoutAnimations)
handleUrlFocusAnimation(hasFocus);
if (hasFocus && currentTab != null && !currentTab.isIncognito()) {
if (mNativeInitialized && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()) {
GeolocationHeader.primeLocationForGeoHeader(getContext());
} else {
mDeferredNativeRunnables.add(new Runnable() {
@Override
public void run() {
if (TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()) {
GeolocationHeader.primeLocationForGeoHeader(getContext());
}
}
});
}
}
if (mNativeInitialized) {
startZeroSuggest();
} else {
mDeferredNativeRunnables.add(new Runnable() {
@Override
public void run() {
if (TextUtils.isEmpty(mUrlBar.getQueryText())) {
startZeroSuggest();
}
}
});
}
if (!hasFocus) {
mHasStartedNewOmniboxEditSession = false;
mNewOmniboxEditSessionTimestamp = -1;
}
if (hasFocus && currentTab != null) {
ChromeActivity activity = (ChromeActivity) mWindowAndroid.getActivity().get();
if (activity != null) {
GeolocationSnackbarController.maybeShowSnackbar(activity.getSnackbarManager(), LocationBarLayout.this, currentTab.isIncognito(), GEOLOCATION_SNACKBAR_SHOW_DELAY_MS);
}
}
}
use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.
the class PrintShareActivity method handlePrintAction.
private void handlePrintAction() {
int triggeringTaskId = IntentUtils.safeGetIntExtra(getIntent(), ShareHelper.EXTRA_TASK_ID, 0);
List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities();
ChromeActivity triggeringActivity = null;
for (int i = 0; i < activities.size(); i++) {
Activity activity = activities.get(i).get();
if (activity == null)
continue;
// of this activity will match that of the triggering activity.
if (activity.getTaskId() == triggeringTaskId && activity instanceof ChromeActivity) {
triggeringActivity = (ChromeActivity) activity;
break;
}
}
if (triggeringActivity == null)
return;
unregisterActivity(triggeringActivity);
triggeringActivity.onMenuOrKeyboardAction(R.id.print_id, true);
}
Aggregations