本文整理汇总了Java中org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager类的典型用法代码示例。如果您正苦于以下问题:Java AsyncTabParamsManager类的具体用法?Java AsyncTabParamsManager怎么用?Java AsyncTabParamsManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncTabParamsManager类属于org.chromium.chrome.browser.tabmodel包,在下文中一共展示了AsyncTabParamsManager类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTabIdFromIntent
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
/**
* Check whether or not the Intent contains an ID for document mode.
* @param intent Intent to check.
* @return ID for the document that has the given intent as base intent, or
* {@link Tab.INVALID_TAB_ID} if it couldn't be retrieved.
*/
public static int getTabIdFromIntent(Intent intent) {
if (intent == null || intent.getData() == null) return Tab.INVALID_TAB_ID;
// Avoid AsyncTabCreationParams related flows early returning here.
if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
return IntentUtils.safeGetIntExtra(
intent, IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID);
}
Uri data = intent.getData();
if (!TextUtils.equals(data.getScheme(), UrlConstants.DOCUMENT_SCHEME)) {
return Tab.INVALID_TAB_ID;
}
try {
return Integer.parseInt(data.getHost());
} catch (NumberFormatException e) {
return Tab.INVALID_TAB_ID;
}
}
示例2: detach
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
/**
* Detaches a tab from its current activity if any.
*
* In details, this function:
* - Tags the tab using mIsDetached.
* - Registers some information for later reparenting in {@link AsyncTabParamsManager}.
* - Removes the tab from its current {@link TabModelSelector}, effectively severing
* the {@link Activity} to {@link Tab} link.
*
* @param intent to be stored within a {@link TabReparentingParams}
* @param finalizeCallback to be stored within a {@link TabReparentingParams}
*/
private void detach(Intent intent, Runnable finalizeCallback) {
mIsDetached = 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.
if (intent == null) intent = new Intent();
intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId);
AsyncTabParamsManager.add(mId, new TabReparentingParams(this, intent, finalizeCallback));
TabModelSelector tabModelSelector = getTabModelSelector();
if (tabModelSelector != null) {
tabModelSelector.getModel(mIncognito).removeTab(this);
}
// TODO(yusufo): We can't call updateWindowAndroid here and set mWindowAndroid to null
// because many code paths (including navigation) expect the tab to always be associated
// with an activity, and will crash. crbug.com/657007
if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(null);
attachTabContentManager(null);
}
示例3: onStart
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
@Override
public void onStart() {
if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
mCompositorViewHolder.prepareForTabReparenting();
}
super.onStart();
if (mContextReporter != null) mContextReporter.enable();
if (mPartnerBrowserRefreshNeeded) {
mPartnerBrowserRefreshNeeded = false;
PartnerBrowserCustomizations.initializeAsync(getApplicationContext(),
PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
@Override
public void run() {
if (PartnerBrowserCustomizations.isIncognitoDisabled()) {
terminateIncognitoSession();
}
}
});
}
if (mCompositorViewHolder != null) mCompositorViewHolder.onStart();
mSnackbarManager.onStart();
// Explicitly call checkAccessibility() so things are initialized correctly when Chrome has
// been re-started after closing due to the last tab being closed when homepage is enabled.
// See crbug.com/541546.
checkAccessibility();
mScreenWidthDp = getResources().getConfiguration().screenWidthDp;
}
示例4: detachAndStartReparenting
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
/**
* 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(yusufo): We can't call updateWindowAndroid here and set mWindowAndroid to null
// because many code paths (including navigation) expect the tab to always be associated
// with an activity, and will crash. crbug.com/657007
if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(null);
attachTabContentManager(null);
}
activity.startActivity(intent, startActivityOptions);
return true;
}
示例5: onStart
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
@Override
public void onStart() {
if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
mCompositorViewHolder.prepareForTabReparenting();
}
super.onStart();
if (mContextReporter != null) mContextReporter.enable();
if (mPartnerBrowserRefreshNeeded) {
mPartnerBrowserRefreshNeeded = false;
PartnerBrowserCustomizations.initializeAsync(getApplicationContext(),
PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
@Override
public void run() {
if (PartnerBrowserCustomizations.isIncognitoDisabled()) {
terminateIncognitoSession();
}
}
});
}
if (mCompositorViewHolder != null) mCompositorViewHolder.onStart();
mSnackbarManager.onStart();
// Explicitly call checkAccessibility() so things are initialized correctly when Chrome has
// been re-started after closing due to the last tab being closed when homepage is enabled.
// See crbug.com/541546.
checkAccessibility();
mUiMode = getResources().getConfiguration().uiMode;
mScreenWidthDp = getResources().getConfiguration().screenWidthDp;
}
示例6: createNewTabIntent
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
private Intent createNewTabIntent(
AsyncTabCreationParams asyncParams, int parentId, boolean isChromeUI) {
int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVALID_TAB_ID);
AsyncTabParamsManager.add(assignedTabId, asyncParams);
Intent intent = new Intent(
Intent.ACTION_VIEW, Uri.parse(asyncParams.getLoadUrlParams().getUrl()));
ComponentName componentName = asyncParams.getComponentName();
if (componentName == null) {
intent.setClass(ContextUtils.getApplicationContext(), ChromeLauncherActivity.class);
} else {
intent.setComponent(componentName);
}
Map<String, String> extraHeaders = asyncParams.getLoadUrlParams().getExtraHeaders();
if (extraHeaders != null && !extraHeaders.isEmpty()) {
Bundle bundle = new Bundle();
for (Map.Entry<String, String> header : extraHeaders.entrySet()) {
bundle.putString(header.getKey(), header.getValue());
}
intent.putExtra(Browser.EXTRA_HEADERS, bundle);
}
intent.putExtra(IntentHandler.EXTRA_TAB_ID, assignedTabId);
intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, mIsIncognito);
intent.putExtra(IntentHandler.EXTRA_PARENT_TAB_ID, parentId);
if (isChromeUI) {
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
ContextUtils.getApplicationContext().getPackageName());
intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
}
Activity parentActivity = ActivityDelegate.getActivityForTabId(parentId);
if (parentActivity != null && parentActivity.getIntent() != null) {
intent.putExtra(IntentHandler.EXTRA_PARENT_INTENT, parentActivity.getIntent());
}
if (asyncParams.getRequestId() != null) {
intent.putExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EXTRA,
asyncParams.getRequestId().intValue());
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
示例7: createNewTabIntent
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; //导入依赖的package包/类
private Intent createNewTabIntent(
AsyncTabCreationParams asyncParams, int parentId, boolean isChromeUI) {
int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVALID_TAB_ID);
AsyncTabParamsManager.add(assignedTabId, asyncParams);
Intent intent = new Intent(
Intent.ACTION_VIEW, Uri.parse(asyncParams.getLoadUrlParams().getUrl()));
ComponentName componentName = asyncParams.getComponentName();
if (componentName == null) {
intent.setClass(ContextUtils.getApplicationContext(), ChromeLauncherActivity.class);
} else {
intent.setComponent(componentName);
}
Map<String, String> extraHeaders = asyncParams.getLoadUrlParams().getExtraHeaders();
if (extraHeaders != null && !extraHeaders.isEmpty()) {
Bundle bundle = new Bundle();
for (Map.Entry<String, String> header : extraHeaders.entrySet()) {
bundle.putString(header.getKey(), header.getValue());
}
intent.putExtra(Browser.EXTRA_HEADERS, bundle);
}
intent.putExtra(IntentHandler.EXTRA_TAB_ID, assignedTabId);
intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, mIsIncognito);
intent.putExtra(IntentHandler.EXTRA_PARENT_TAB_ID, parentId);
if (mIsIncognito || isChromeUI) {
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
ContextUtils.getApplicationContext().getPackageName());
}
if (isChromeUI) intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
Activity parentActivity = ActivityDelegate.getActivityForTabId(parentId);
if (parentActivity != null && parentActivity.getIntent() != null) {
intent.putExtra(IntentHandler.EXTRA_PARENT_INTENT, parentActivity.getIntent());
}
if (asyncParams.getRequestId() != null) {
intent.putExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EXTRA,
asyncParams.getRequestId().intValue());
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}