This source file includes following definitions.
- isLoading
- loadUrlWithSanitization
- loadUrlWithSanitization
- createWebContentsDelegate
- createAutoLoginProcessor
- createContextMenuPopulator
- onLoadStarted
- onLoadStopped
package org.chromium.chrome.shell;
import android.content.Context;
import android.text.TextUtils;
import org.chromium.chrome.browser.Tab;
import org.chromium.chrome.browser.UrlUtilities;
import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator;
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
import org.chromium.chrome.browser.infobar.AutoLoginProcessor;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.LoadUrlParams;
import org.chromium.content_public.Referrer;
import org.chromium.ui.base.WindowAndroid;
public class ChromeShellTab extends Tab {
private boolean mIsLoading;
public ChromeShellTab(Context context, String url, WindowAndroid window,
ContentViewClient contentViewClient) {
super(false, context, window);
initialize();
initContentView();
setContentViewClient(contentViewClient);
loadUrlWithSanitization(url);
}
public boolean isLoading() {
return mIsLoading;
}
public void loadUrlWithSanitization(String url, byte[] postData) {
if (url == null) return;
url = UrlUtilities.fixupUrl(url);
if (TextUtils.isEmpty(url)) return;
ContentView contentView = getContentView();
if (TextUtils.equals(url, contentView.getUrl())) {
contentView.getContentViewCore().reload(true);
} else {
if (postData == null) {
contentView.loadUrl(new LoadUrlParams(url));
} else {
contentView.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, postData));
}
}
}
public void loadUrlWithSanitization(String url) {
loadUrlWithSanitization(url, null);
}
@Override
protected TabChromeWebContentsDelegateAndroid createWebContentsDelegate() {
return new ChromeShellTabChromeWebContentsDelegateAndroid();
}
@Override
protected AutoLoginProcessor createAutoLoginProcessor() {
return new AutoLoginProcessor() {
@Override
public void processAutoLoginResult(String accountName,
String authToken, boolean success, String result) {
getInfoBarContainer().processAutoLogin(accountName, authToken,
success, result);
}
};
}
@Override
protected ContextMenuPopulator createContextMenuPopulator() {
return new ChromeContextMenuPopulator(new TabChromeContextMenuItemDelegate() {
@Override
public void onOpenImageUrl(String url, Referrer referrer) {
loadUrlWithSanitization(url);
}
});
}
private class ChromeShellTabChromeWebContentsDelegateAndroid
extends TabChromeWebContentsDelegateAndroid {
@Override
public void onLoadStarted() {
mIsLoading = true;
}
@Override
public void onLoadStopped() {
mIsLoading = false;
}
}
}