import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.content.browser.ContentViewRenderView.CompositingSurfaceType;
import org.chromium.content.browser.ContentViewStatics;
-import org.chromium.content.browser.LoadUrlParams;
-import org.chromium.content.browser.NavigationHistory;
import org.chromium.content.common.CleanupReference;
import org.chromium.content_public.browser.JavaScriptCallback;
+import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.content_public.browser.NavigationHistory;
+import org.chromium.content_public.browser.NavigationController;
+import org.chromium.content_public.browser.WebContents;
import org.chromium.media.MediaPlayerBridge;
import org.chromium.ui.base.ActivityWindowAndroid;
import org.chromium.ui.gfx.DeviceDisplayInfo;
private XWalkSettings mSettings;
private XWalkGeolocationPermissions mGeolocationPermissions;
private XWalkLaunchScreenManager mLaunchScreenManager;
+ private NavigationController mNavigationController;
+ private WebContents mWebContents;
long mNativeContent;
- long mWebContents;
+ long mNativeWebContents;
static void setJavascriptInterfaceClass(Class<? extends Annotation> clazz) {
assert(javascriptInterfaceClass == null);
// bind all the native->java relationships.
mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeContent));
- mWebContents = nativeGetWebContents(mNativeContent);
+ mNativeWebContents = nativeGetWebContents(mNativeContent);
// Initialize ContentView.
mContentViewCore = new ContentViewCore(getContext());
mContentView = ContentView.newInstance(getContext(), mContentViewCore);
- mContentViewCore.initialize(mContentView, mContentView, mWebContents, mWindow);
+ mContentViewCore.initialize(mContentView, mContentView, mNativeWebContents, mWindow);
+ mWebContents = mContentViewCore.getWebContents();
+ mNavigationController = mWebContents.getNavigationController();
addView(mContentView, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
mContentViewCore.setContentViewClient(mContentsClientBridge);
mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
// For addJavascriptInterface
- mContentsClientBridge.installWebContentsObserver(mContentViewCore.getWebContents());
+ mContentsClientBridge.installWebContentsObserver(mWebContents);
// Set DIP scale.
mContentsClientBridge.setDIPScale(DeviceDisplayInfo.create(getContext()).getDIPScale());
// the members mAllowUniversalAccessFromFileURLs and mAllowFileAccessFromFileURLs
// won't be changed from false to true at the same time in the constructor of
// XWalkSettings class.
- mSettings = new XWalkSettings(getContext(), mWebContents, false);
+ mSettings = new XWalkSettings(getContext(), mNativeWebContents, false);
// Enable AllowFileAccessFromFileURLs, so that files under file:// path could be
// loaded by XMLHttpRequest.
mSettings.setAllowFileAccessFromFileURLs(true);
void doLoadUrl(String url, String content) {
// Handle the same url loading by parameters.
if (url != null && !url.isEmpty() &&
- TextUtils.equals(url, mContentViewCore.getUrl())) {
- mContentViewCore.reload(true);
+ TextUtils.equals(url, mWebContents.getUrl())) {
+ mNavigationController.reload(true);
} else {
LoadUrlParams params = null;
if (content == null || content.isEmpty()) {
content, "text/html", false, url, null);
}
params.setOverrideUserAgent(LoadUrlParams.UA_OVERRIDE_TRUE);
- mContentViewCore.loadUrl(params);
+ mNavigationController.loadUrl(params);
}
mContentView.requestFocus();
public void reload(int mode) {
switch (mode) {
case XWalkViewInternal.RELOAD_IGNORE_CACHE:
- mContentViewCore.reloadIgnoringCache(true);
+ mNavigationController.reloadIgnoringCache(true);
break;
case XWalkViewInternal.RELOAD_NORMAL:
default:
- mContentViewCore.reload(true);
+ mNavigationController.reload(true);
}
}
public String getUrl() {
- String url = mContentViewCore.getUrl();
+ String url = mWebContents.getUrl();
if (url == null || url.trim().isEmpty()) return null;
return url;
}
public String getTitle() {
- String title = mContentViewCore.getTitle().trim();
+ String title = mWebContents.getTitle().trim();
if (title == null) title = "";
return title;
}
}
public void clearHistory() {
- mContentViewCore.clearHistory();
+ mNavigationController.clearHistory();
}
public boolean canGoBack() {
- return mContentViewCore.canGoBack();
+ return mNavigationController.canGoBack();
}
public void goBack() {
- mContentViewCore.goBack();
+ mNavigationController.goBack();
}
public boolean canGoForward() {
- return mContentViewCore.canGoForward();
+ return mNavigationController.canGoForward();
}
public void goForward() {
- mContentViewCore.goForward();
+ mNavigationController.goForward();
}
void navigateTo(int offset) {
- mContentViewCore.goToOffset(offset);
+ mNavigationController.goToOffset(offset);
}
public void stopLoading() {
- mContentViewCore.stopLoading();
+ mWebContents.stop();
mContentsClientBridge.onStopLoading();
}
}
public String getOriginalUrl() {
- NavigationHistory history = mContentViewCore.getNavigationHistory();
+ NavigationHistory history = mNavigationController.getNavigationHistory();
int currentIndex = history.getCurrentEntryIndex();
if (currentIndex >= 0 && currentIndex < history.getEntryCount()) {
return history.getEntryAtIndex(currentIndex).getOriginalUrl();
}
public XWalkNavigationHistoryInternal getNavigationHistory() {
- return new XWalkNavigationHistoryInternal(mXWalkView, mContentViewCore.getNavigationHistory());
+ return new XWalkNavigationHistoryInternal(mXWalkView, mNavigationController.getNavigationHistory());
}
public static final String SAVE_RESTORE_STATE_KEY = "XWALKVIEW_STATE";
// already restored. See WebContentsImpl::UpdateTitleForEntry. So we
// call the callback explicitly here.
if (result) {
- mContentsClientBridge.onUpdateTitle(mContentViewCore.getTitle());
+ mContentsClientBridge.onUpdateTitle(mWebContents.getTitle());
}
return result ? getNavigationHistory() : null;
void exitFullscreen() {
if (hasEnteredFullscreen()) {
- mContentsClientBridge.exitFullscreen(mWebContents);
+ mContentsClientBridge.exitFullscreen(mNativeWebContents);
}
}