This source file includes following definitions.
- onFinishInflate
- initialize
- setStartupUrl
- setOverlayVideoMode
- getCurrentTab
- createTab
- isContentViewRenderViewInitialized
- setCurrentTab
package org.chromium.chrome.shell;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.ui.base.WindowAndroid;
public class TabManager extends LinearLayout {
private static final String DEFAULT_URL = "http://www.google.com";
private WindowAndroid mWindow;
private ContentVideoViewClient mContentVideoViewClient;
private ViewGroup mContentViewHolder;
private ContentViewRenderView mContentViewRenderView;
private ChromeShellToolbar mToolbar;
private ChromeShellTab mCurrentTab;
private String mStartupUrl = DEFAULT_URL;
public TabManager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
}
public void initialize(WindowAndroid window, ContentVideoViewClient videoViewClient) {
assert window != null;
mWindow = window;
assert videoViewClient != null;
mContentVideoViewClient = videoViewClient;
mContentViewHolder = (ViewGroup) findViewById(R.id.content_container);
mToolbar = (ChromeShellToolbar) findViewById(R.id.toolbar);
mContentViewRenderView = new ContentViewRenderView(getContext(), mWindow) {
@Override
protected void onReadyToRender() {
if (mCurrentTab == null) createTab(mStartupUrl);
}
};
mContentViewHolder.addView(mContentViewRenderView,
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
}
public void setStartupUrl(String startupUrl) {
mStartupUrl = startupUrl;
}
public void setOverlayVideoMode(boolean enabled) {
if (mContentViewRenderView == null) return;
mContentViewRenderView.setOverlayVideoMode(enabled);
}
public ChromeShellTab getCurrentTab() {
return mCurrentTab;
}
public void createTab(String url) {
if (!isContentViewRenderViewInitialized()) return;
ContentViewClient client = new ContentViewClient() {
@Override
public ContentVideoViewClient getContentVideoViewClient() {
return mContentVideoViewClient;
}
};
ChromeShellTab tab = new ChromeShellTab(getContext(), url, mWindow, client);
setCurrentTab(tab);
}
private boolean isContentViewRenderViewInitialized() {
return mContentViewRenderView != null && mContentViewRenderView.isInitialized();
}
private void setCurrentTab(ChromeShellTab tab) {
if (mCurrentTab != null) {
mContentViewHolder.removeView(mCurrentTab.getContentView());
mCurrentTab.destroy();
}
mCurrentTab = tab;
mToolbar.showTab(mCurrentTab);
mContentViewHolder.addView(mCurrentTab.getContentView());
mContentViewRenderView.setCurrentContentView(mCurrentTab.getContentView());
mCurrentTab.getContentView().requestFocus();
mCurrentTab.getContentView().onShow();
}
}