Commit 421eac47 authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Extract AsyncTabCreator interface from TabDelegate.

Modularize the interface and its dependencies:
- AsyncTabParams
- AsyncTabCreationParams

Change-Id: I5b785cae99907b43dc4188f1aa09c240ae3b47ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2305116
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791034}
parent 8659fab3
......@@ -1529,7 +1529,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/tabbed_mode/TabbedNavigationBarColorController.java",
"java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java",
"java/src/org/chromium/chrome/browser/tabbed_mode/TabbedSystemUiCoordinator.java",
"java/src/org/chromium/chrome/browser/tabmodel/AsyncTabParams.java",
"java/src/org/chromium/chrome/browser/tabmodel/AsyncTabParamsManager.java",
"java/src/org/chromium/chrome/browser/tabmodel/ChromeTabCreator.java",
"java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java",
......@@ -1550,7 +1549,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/tabmodel/TabReparentingParams.java",
"java/src/org/chromium/chrome/browser/tabmodel/TabWindowManager.java",
"java/src/org/chromium/chrome/browser/tabmodel/TabbedModeTabPersistencePolicy.java",
"java/src/org/chromium/chrome/browser/tabmodel/document/AsyncTabCreationParams.java",
"java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java",
"java/src/org/chromium/chrome/browser/tasks/ConditionalTabStripUtils.java",
"java/src/org/chromium/chrome/browser/tasks/EngagementTimeUtil.java",
......
......@@ -27,7 +27,7 @@ import org.chromium.chrome.browser.payments.PaymentRequestImpl;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
import org.chromium.chrome.browser.webapps.ChromeWebApkHost;
import org.chromium.chrome.browser.webapps.WebappDataStorage;
......
......@@ -44,9 +44,9 @@ import org.chromium.chrome.browser.tab.TabDelegateFactory;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tab.TabStateBrowserControlsVisibilityDelegate;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
import org.chromium.chrome.browser.ui.native_page.NativePage;
import org.chromium.chrome.browser.webapps.WebDisplayMode;
......
......@@ -37,7 +37,7 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.components.offline_items_collection.LaunchLocation;
......
......@@ -27,8 +27,9 @@ import org.chromium.chrome.browser.tab.TabBuilder;
import org.chromium.chrome.browser.tab.TabIdManager;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tab.TabState;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreator;
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
import org.chromium.chrome.browser.tabmodel.TabCreator;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.PageTransition;
......@@ -36,7 +37,7 @@ import org.chromium.ui.base.PageTransition;
/**
* Asynchronously creates Tabs by creating/starting up Activities.
*/
public class TabDelegate extends TabCreator {
public class TabDelegate extends AsyncTabCreator {
private final boolean mIsIncognito;
/**
......@@ -92,14 +93,7 @@ public class TabDelegate extends TabCreator {
return true;
}
/**
* Creates a tab in the "other" window in multi-window mode. This will only work if
* {@link MultiWindowUtils#isOpenInOtherWindowSupported} is true for the given activity.
*
* @param loadUrlParams Parameters specifying the URL to load and other navigation details.
* @param activity The current {@link Activity}
* @param parentId The ID of the parent tab, or {@link Tab#INVALID_TAB_ID}.
*/
@Override
public void createTabInOtherWindow(
LoadUrlParams loadUrlParams, Activity activity, int parentId) {
Intent intent = createNewTabIntent(
......@@ -128,12 +122,7 @@ public class TabDelegate extends TabCreator {
return null;
}
/**
* Creates a Tab to host the given WebContents asynchronously.
* @param asyncParams Parameters to create the Tab with, including the URL.
* @param type Information about how the tab was launched.
* @param parentId ID of the parent tab, if it exists.
*/
@Override
public void createNewTab(
AsyncTabCreationParams asyncParams, @TabLaunchType int type, int parentId) {
assert asyncParams != null;
......@@ -160,7 +149,7 @@ public class TabDelegate extends TabCreator {
return intent;
}
protected final void addAsyncTabExtras(AsyncTabCreationParams asyncParams, int parentId,
private void addAsyncTabExtras(AsyncTabCreationParams asyncParams, int parentId,
boolean isChromeUI, int assignedTabId, Intent intent) {
ComponentName componentName = asyncParams.getComponentName();
if (componentName == null) {
......@@ -195,10 +184,7 @@ public class TabDelegate extends TabCreator {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
/**
* Passes the supplied web app launch intent to the IntentHandler.
* @param intent Web app launch intent.
*/
@Override
public void createNewStandaloneFrame(Intent intent) {
assert intent != null;
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
......
......@@ -14,7 +14,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content_public.browser.LoadUrlParams;
......
......@@ -50,10 +50,10 @@ import org.chromium.chrome.browser.init.StartupTabPreloader;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.tabmodel.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl;
import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.browser.toolbar.ToolbarManager;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController;
......
......@@ -6,6 +6,9 @@ import("//build/config/android/rules.gni")
android_library("java") {
sources = [
"android/java/src/org/chromium/chrome/browser/tabmodel/AsyncTabCreationParams.java",
"android/java/src/org/chromium/chrome/browser/tabmodel/AsyncTabCreator.java",
"android/java/src/org/chromium/chrome/browser/tabmodel/AsyncTabParams.java",
"android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java",
"android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModelFilter.java",
"android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModelSelectorObserver.java",
......
......@@ -2,14 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.tabmodel.document;
package org.chromium.chrome.browser.tabmodel;
import android.content.ComponentName;
import org.chromium.chrome.browser.ServiceTabLauncher;
import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.AsyncTabParams;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
......@@ -21,10 +18,10 @@ public class AsyncTabCreationParams implements AsyncTabParams {
/** Parameters used for opening a URL in the new Tab. */
private final LoadUrlParams mLoadUrlParams;
/** WebContents object to initialize the Tab with. Set only by the {@link TabDelegate}. */
/** WebContents object to initialize the Tab with. Set only by the TabDelegate. */
private final WebContents mWebContents;
/** The tab launch request ID from the {@link ServiceTabLauncher}. **/
/** The tab launch request ID from the ServiceTabLauncher. **/
private final Integer mRequestId;
/** Specifies which component to fire the Intent at. */
......@@ -35,19 +32,19 @@ public class AsyncTabCreationParams implements AsyncTabParams {
this(loadUrlParams, null, null, null);
}
/** Called by {@link TabDelegate} for creating new a Tab with a pre-existing WebContents. */
/** Called by TabDelegate for creating new a Tab with a pre-existing WebContents. */
public AsyncTabCreationParams(LoadUrlParams loadUrlParams, WebContents webContents) {
this(loadUrlParams, webContents, null, null);
assert webContents != null;
}
/** Called by {@link ServiceTabLauncher} to create tabs via service workers. */
/** Called by ServiceTabLauncher to create tabs via service workers. */
public AsyncTabCreationParams(LoadUrlParams loadUrlParams, Integer requestId) {
this(loadUrlParams, null, requestId, null);
assert requestId != null;
}
/** Called by {@link OfflinePageDownloadBridge} to create tabs for Offline Pages. */
/** Called by OfflinePageDownloadBridge to create tabs for Offline Pages. */
public AsyncTabCreationParams(LoadUrlParams loadUrlParams, ComponentName name) {
this(loadUrlParams, null, null, name);
assert name != null;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.tabmodel;
import android.app.Activity;
import android.content.Intent;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.content_public.browser.LoadUrlParams;
/**
* Creates {@link Tab}s asynchronously.
*/
public abstract class AsyncTabCreator extends TabCreator {
/**
* Creates a tab in the "other" window in multi-window mode. This will only work if
* MultiWindowUtils#isOpenInOtherWindowSupported() is true for the given activity.
*
* @param loadUrlParams Parameters specifying the URL to load and other navigation details.
* @param activity The current {@link Activity}
* @param parentId The ID of the parent tab, or {@link Tab#INVALID_TAB_ID}.
*/
public abstract void createTabInOtherWindow(
LoadUrlParams loadUrlParams, Activity activity, int parentId);
/**
* Creates a Tab to host the given WebContents asynchronously.
* @param asyncParams Parameters to create the Tab with, including the URL.
* @param type Information about how the tab was launched.
* @param parentId ID of the parent tab, if it exists.
*/
public abstract void createNewTab(
AsyncTabCreationParams asyncParams, @TabLaunchType int type, int parentId);
/**
* Passes the supplied web app launch intent to the IntentHandler.
* @param intent Web app launch intent.
*/
public abstract void createNewStandaloneFrame(Intent intent);
}
......@@ -16,7 +16,6 @@ import org.chromium.content_public.browser.WebContents;
* Interface for handling tab related async operations over multiple activities.
*/
public interface AsyncTabParams {
/**
* @return The {@link LoadUrlParams} associated with the initial URL to load.
*/
......@@ -25,22 +24,26 @@ public interface AsyncTabParams {
/**
* @return The request ID (tab ID) for this {@link AsyncTabParams}.
*/
@Nullable Integer getRequestId();
@Nullable
Integer getRequestId();
/**
* @return The {@link WebContents} associated with this {@link AsyncTabParams}.
*/
@Nullable WebContents getWebContents();
@Nullable
WebContents getWebContents();
/**
* @return The {@link ComponentName} that should handle this Intent.
*/
@Nullable ComponentName getComponentName();
@Nullable
ComponentName getComponentName();
/**
* @return The tab that would be reparenting through this {@link AsyncTabParams}.
*/
@Nullable Tab getTabToReparent();
@Nullable
Tab getTabToReparent();
/**
* Destroy any internal fields if it is necessary.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment