This source file includes following definitions.
- CalledByNative
- onUpdated
- pushTab
- finalize
- destroy
- setRecentlyClosedCallback
- getRecentlyClosedTabs
- openRecentlyClosedTab
- openRecentlyClosedTab
- clearRecentlyClosedTabs
- nativeInit
- nativeDestroy
- nativeSetRecentlyClosedCallback
- nativeGetRecentlyClosedTabs
- nativeOpenRecentlyClosedTab
- nativeClearRecentlyClosedTabs
package org.chromium.chrome.browser;
import org.chromium.base.CalledByNative;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.ui.WindowOpenDisposition;
import java.util.ArrayList;
import java.util.List;
public class RecentlyClosedBridge {
private long mNativeRecentlyClosedTabsBridge;
public interface RecentlyClosedCallback {
@CalledByNative("RecentlyClosedCallback")
void onUpdated();
}
public static class RecentlyClosedTab {
public final int id;
public final String title;
public final String url;
private RecentlyClosedTab(int id, String title, String url) {
this.id = id;
this.title = title;
this.url = url;
}
}
@CalledByNative
private static void pushTab(
List<RecentlyClosedTab> tabs, int id, String title, String url) {
RecentlyClosedTab tab = new RecentlyClosedTab(id, title, url);
tabs.add(tab);
}
public RecentlyClosedBridge(Profile profile) {
mNativeRecentlyClosedTabsBridge = nativeInit(profile);
}
@Override
protected void finalize() {
assert mNativeRecentlyClosedTabsBridge == 0;
}
public void destroy() {
assert mNativeRecentlyClosedTabsBridge != 0;
nativeDestroy(mNativeRecentlyClosedTabsBridge);
mNativeRecentlyClosedTabsBridge = 0;
}
public void setRecentlyClosedCallback(RecentlyClosedCallback callback) {
nativeSetRecentlyClosedCallback(mNativeRecentlyClosedTabsBridge, callback);
}
public List<RecentlyClosedTab> getRecentlyClosedTabs(int maxTabCount) {
List<RecentlyClosedTab> tabs = new ArrayList<RecentlyClosedTab>();
boolean received = nativeGetRecentlyClosedTabs(mNativeRecentlyClosedTabsBridge, tabs,
maxTabCount);
return received ? tabs : null;
}
public boolean openRecentlyClosedTab(Tab tab, RecentlyClosedTab recentTab) {
return openRecentlyClosedTab(tab, recentTab, WindowOpenDisposition.CURRENT_TAB);
}
public boolean openRecentlyClosedTab(Tab tab, RecentlyClosedTab recentTab,
int windowOpenDisposition) {
return nativeOpenRecentlyClosedTab(mNativeRecentlyClosedTabsBridge, tab, recentTab.id,
windowOpenDisposition);
}
public void clearRecentlyClosedTabs() {
nativeClearRecentlyClosedTabs(mNativeRecentlyClosedTabsBridge);
}
private native long nativeInit(Profile profile);
private native void nativeDestroy(long nativeRecentlyClosedTabsBridge);
private native void nativeSetRecentlyClosedCallback(
long nativeRecentlyClosedTabsBridge, RecentlyClosedCallback callback);
private native boolean nativeGetRecentlyClosedTabs(
long nativeRecentlyClosedTabsBridge, List<RecentlyClosedTab> tabs, int maxTabCount);
private native boolean nativeOpenRecentlyClosedTab(long nativeRecentlyClosedTabsBridge,
Tab tab, int recentTabId, int windowOpenDisposition);
private native void nativeClearRecentlyClosedTabs(long nativeRecentlyClosedTabsBridge);
}