}
public void supplyContentsForPopup(XWalkContent newContents) {
+ if (mNativeContent == 0) return;
+
long popupNativeXWalkContent = nativeReleasePopupXWalkContent(mNativeContent);
if (popupNativeXWalkContent == 0) {
Log.w(TAG, "Popup XWalkView bind failed: no pending content.");
}
public void loadUrl(String url, String data) {
+ if (mNativeContent == 0) return;
+
if ((url == null || url.isEmpty()) &&
(data == null || data.isEmpty())) {
return;
}
public void reload(int mode) {
+ if (mNativeContent == 0) return;
+
switch (mode) {
case XWalkViewInternal.RELOAD_IGNORE_CACHE:
mNavigationController.reloadIgnoringCache(true);
}
public String getUrl() {
+ if (mNativeContent == 0) return null;
String url = mWebContents.getUrl();
if (url == null || url.trim().isEmpty()) return null;
return url;
}
public String getTitle() {
+ if (mNativeContent == 0) return null;
String title = mWebContents.getTitle().trim();
if (title == null) title = "";
return title;
}
public void addJavascriptInterface(Object object, String name) {
+ if (mNativeContent == 0) return;
mContentViewCore.addPossiblyUnsafeJavascriptInterface(object, name,
javascriptInterfaceClass);
}
public void evaluateJavascript(String script, ValueCallback<String> callback) {
+ if (mNativeContent == 0) return;
final ValueCallback<String> fCallback = callback;
JavaScriptCallback coreCallback = null;
if (fCallback != null) {
}
public void setUIClient(XWalkUIClientInternal client) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setUIClient(client);
}
public void setResourceClient(XWalkResourceClientInternal client) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setResourceClient(client);
}
public void setXWalkWebChromeClient(XWalkWebChromeClient client) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setXWalkWebChromeClient(client);
}
public XWalkWebChromeClient getXWalkWebChromeClient() {
+ if (mNativeContent == 0) return null;
return mContentsClientBridge.getXWalkWebChromeClient();
}
public void setXWalkClient(XWalkClient client) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setXWalkClient(client);
}
public void setDownloadListener(DownloadListener listener) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setDownloadListener(listener);
}
public void setNavigationHandler(XWalkNavigationHandler handler) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setNavigationHandler(handler);
}
public void setNotificationService(XWalkNotificationService service) {
+ if (mNativeContent == 0) return;
mContentsClientBridge.setNotificationService(service);
}
public void onPause() {
+ if (mNativeContent == 0) return;
mContentViewCore.onHide();
}
public void onResume() {
+ if (mNativeContent == 0) return;
mContentViewCore.onShow();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (mNativeContent == 0) return;
mWindow.onActivityResult(requestCode, resultCode, data);
}
public boolean onNewIntent(Intent intent) {
+ if (mNativeContent == 0) return false;
return mContentsClientBridge.onNewIntent(intent);
}
}
public void clearHistory() {
+ if (mNativeContent == 0) return;
mNavigationController.clearHistory();
}
public boolean canGoBack() {
- return mNavigationController.canGoBack();
+ return (mNativeContent == 0) ? false : mNavigationController.canGoBack();
}
public void goBack() {
+ if (mNativeContent == 0) return;
mNavigationController.goBack();
}
public boolean canGoForward() {
- return mNavigationController.canGoForward();
+ return (mNativeContent == 0) ? false : mNavigationController.canGoForward();
}
public void goForward() {
+ if (mNativeContent == 0) return;
mNavigationController.goForward();
}
}
public void stopLoading() {
+ if (mNativeContent == 0) return;
mWebContents.stop();
mContentsClientBridge.onStopLoading();
}
// details in content_view_statics.cc.
// We need follow up after upstream updates that.
public void pauseTimers() {
- if (timerPaused) return;
+ if (timerPaused || (mNativeContent == 0)) return;
ContentViewStatics.setWebKitSharedTimersSuspended(true);
timerPaused = true;
}
public void resumeTimers() {
- if (!timerPaused) return;
+ if (!timerPaused || (mNativeContent == 0)) return;
ContentViewStatics.setWebKitSharedTimersSuspended(false);
timerPaused = false;
}
public String getOriginalUrl() {
+ if (mNativeContent == 0) return null;
NavigationHistory history = mNavigationController.getNavigationHistory();
int currentIndex = history.getCurrentEntryIndex();
if (currentIndex >= 0 && currentIndex < history.getEntryCount()) {
return nativeGetVersion(mNativeContent);
}
+ public void setBackgroundColor(int color) {
+ if (mNativeContent == 0) return;
+ nativeSetBackgroundColor(mNativeContent, color);
+ }
+
public void setNetworkAvailable(boolean networkUp) {
if (mNativeContent == 0) return;
nativeSetJsOnlineProperty(mNativeContent, networkUp);
// For instrumentation test.
public void installWebContentsObserverForTest(XWalkContentsClient contentClient) {
+ if (mNativeContent == 0) return;
contentClient.installWebContentsObserver(mContentViewCore.getWebContents());
}
}
public XWalkNavigationHistoryInternal getNavigationHistory() {
+ if (mNativeContent == 0) return null;
+
return new XWalkNavigationHistoryInternal(mXWalkView, mNavigationController.getNavigationHistory());
}
public static final String SAVE_RESTORE_STATE_KEY = "XWALKVIEW_STATE";
public XWalkNavigationHistoryInternal saveState(Bundle outState) {
- if (outState == null) return null;
+ if (mNativeContent == 0 || outState == null) return null;
byte[] state = nativeGetState(mNativeContent);
if (state == null) return null;
}
public XWalkNavigationHistoryInternal restoreState(Bundle inState) {
- if (inState == null) return null;
+ if (mNativeContent == 0 || inState == null) return null;
byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
if (state == null) return null;
@CalledByNative
private void onGeolocationPermissionsShowPrompt(String origin) {
+ if (mNativeContent == 0) return;
// Reject if geolocation is disabled, or the origin has a retained deny.
if (!mSettings.getGeolocationEnabled()) {
nativeInvokeGeolocationCallback(mNativeContent, false, origin);
mContentsClientBridge.onGeolocationPermissionsHidePrompt();
}
- public void enableRemoteDebugging(int allowedUid) {
+ public void enableRemoteDebugging() {
// Chrome looks for "devtools_remote" pattern in the name of a unix domain socket
// to identify a debugging page
final String socketName = getContext().getApplicationContext().getPackageName() + "_devtools_remote";
if (mDevToolsServer == null) {
mDevToolsServer = new XWalkDevToolsServer(socketName);
- mDevToolsServer.allowConnectionFromUid(allowedUid);
- mDevToolsServer.setRemoteDebuggingEnabled(true);
+ mDevToolsServer.setRemoteDebuggingEnabled(
+ true, XWalkDevToolsServer.Security.ALLOW_SOCKET_ACCESS);
}
}
- // Enables remote debugging and returns the URL at which the dev tools server is listening
- // for commands. Only the current process is allowed to connect to the server.
- void enableRemoteDebugging() {
- enableRemoteDebugging(getContext().getApplicationInfo().uid);
- }
-
void disableRemoteDebugging() {
if (mDevToolsServer == null) return;
long nativeXWalkContent, boolean value, String requestingFrame);
private native byte[] nativeGetState(long nativeXWalkContent);
private native boolean nativeSetState(long nativeXWalkContent, byte[] state);
+ private native void nativeSetBackgroundColor(long nativeXWalkContent, int color);
}