import org.chromium.base.CommandLine;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.content.browser.TracingControllerAndroid;
-import org.xwalk.core.XWalkDefaultWebChromeClient;
+import org.xwalk.core.XWalkNavigationHistory;
+import org.xwalk.core.XWalkPreferences;
+import org.xwalk.core.XWalkResourceClient;
+import org.xwalk.core.XWalkUIClient;
import org.xwalk.core.XWalkView;
public class XWalkViewShellActivity extends FragmentActivity
- implements ActionBar.TabListener, XWalkViewSectionFragment.OnXWalkViewCreatedListener{
+ implements ActionBar.TabListener, XWalkViewSectionFragment.OnXWalkViewCreatedListener {
public static final String COMMAND_LINE_FILE = "/data/local/tmp/xwview-shell-command-line";
private static final String TAG = XWalkViewShellActivity.class.getName();
public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs";
getTracingController().unregisterReceiver(this);
} catch (SecurityException e) {
Log.w(TAG, "failed to unregister tracing receiver: " + e.getMessage());
+ } catch (IllegalArgumentException e) {
+ Log.w(TAG, "failed to unregister tracing receiver: " + e.getMessage());
}
}
if (bundle.containsKey("url")) {
String extra = bundle.getString("url");
if (mActiveView != null)
- mActiveView.loadUrl(sanitizeUrl(extra));
+ mActiveView.load(sanitizeUrl(extra), null);
}
}
};
}
@Override
- public void onPause() {
- super.onPause();
- mSectionsPagerAdapter.onPause();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mSectionsPagerAdapter.onResume();
- }
-
- @Override
public void onDestroy() {
super.onDestroy();
unregisterReceiver(mReceiver);
unregisterTracingReceiver();
- mSectionsPagerAdapter.onDestroy();
}
@Override
}
@Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- if (mActiveView != null) {
- return mActiveView.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
- }
- return super.onKeyUp(keyCode, event);
- }
-
- @Override
public void onNewIntent(Intent intent) {
if (mActiveView != null) {
if (!mActiveView.onNewIntent(intent)) super.onNewIntent(intent);
}
if (mActiveView == null) return true;
- mActiveView.loadUrl(sanitizeUrl(mUrlTextView.getText().toString()));
+ mActiveView.load(sanitizeUrl(mUrlTextView.getText().toString()), null);
mUrlTextView.clearFocus();
setKeyboardVisibilityForUrl(false);
return true;
mPrevButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- if (mActiveView == null) return;
- if (mActiveView.canGoBack()) mActiveView.goBack();
+ if (mActiveView != null &&
+ mActiveView.getNavigationHistory().canGoBack()) {
+ mActiveView.getNavigationHistory().navigate(
+ XWalkNavigationHistory.Direction.BACKWARD, 1);
+ }
}
});
mNextButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- if (mActiveView == null) return;
- if (mActiveView.canGoForward()) mActiveView.goForward();
+ if (mActiveView != null &&
+ mActiveView.getNavigationHistory().canGoForward()) {
+ mActiveView.getNavigationHistory().navigate(
+ XWalkNavigationHistory.Direction.FORWARD, 1);
+ }
}
});
mStopButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- if (mActiveView == null) return;
- mActiveView.stopLoading();
+ if (mActiveView != null) mActiveView.stopLoading();
}
});
mReloadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- if (mActiveView == null) return;
- mActiveView.reload();
+ if (mActiveView != null) mActiveView.reload(XWalkView.RELOAD_NORMAL);
}
});
}
private void initializeXWalkViewClients(XWalkView xwalkView) {
- xwalkView.setXWalkWebChromeClient(new XWalkDefaultWebChromeClient(this, xwalkView) {
+ xwalkView.setResourceClient(new XWalkResourceClient(xwalkView) {
+ @Override
public void onProgressChanged(XWalkView view, int newProgress) {
if (view != mActiveView) return;
mToolbar.removeCallbacks(mClearProgressRunnable);
}
mUrlTextView.setText(mActiveView.getUrl());
}
+ });
+
+ xwalkView.setUIClient(new XWalkUIClient(xwalkView) {
+ @Override
public void onReceivedTitle(XWalkView view, String title) {
mSectionsPagerAdapter.setPageTitle(view, title);
}
}
initializeXWalkViewClients(view);
mProgressMap.put(view, 0);
- view.enableRemoteDebugging();
+ XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
}
}