1 // Copyright (c) 2013-2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.xwalk.app.runtime;
7 import android.app.Activity;
8 import android.content.Context;
9 import android.content.Intent;
10 import android.view.View;
11 import android.widget.FrameLayout;
13 import org.xwalk.app.XWalkRuntimeActivityBase;
14 import org.xwalk.core.SharedXWalkView;
15 import org.xwalk.core.XWalkView;
16 import org.xwalk.core.XWalkPreferences;
19 * The implementation class for runtime core. It calls the methods provided
20 * by runtime core and customizes the behaviors for runtime.
22 class XWalkCoreProviderImpl implements XWalkRuntimeViewProvider {
23 private Context mContext;
24 private Activity mActivity;
25 private XWalkView mXWalkView;
27 public XWalkCoreProviderImpl(Context context, Activity activity) {
30 init(context, (XWalkRuntimeActivityBase)activity);
33 private void init(Context context, XWalkRuntimeActivityBase activity) {
34 // TODO(yongsheng): do customizations for XWalkView. There will
35 // be many callback classes which are needed to be implemented.
36 mXWalkView = new SharedXWalkView(context, activity);
40 public void loadAppFromUrl(String url) {
41 mXWalkView.load(url, null);
45 public void loadAppFromManifest(String manifestUrl) {
46 mXWalkView.loadAppFromManifest(manifestUrl, null);
50 public void onCreate() {
54 public void onResume() {
58 public void onPause() {
62 public void onDestroy() {
66 public void onActivityResult(int requestCode, int resultCode, Intent data) {
67 mXWalkView.onActivityResult(requestCode, resultCode, data);
71 public boolean onNewIntent(Intent intent) {
72 return mXWalkView.onNewIntent(intent);
76 public void enableRemoteDebugging(String frontEndUrl, String socketName) {
77 // TODO(yongsheng): Enable two parameters once they're supported in XWalkView.
78 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
82 public void disableRemoteDebugging() {
83 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, false);
87 public String getVersion() {
88 return mXWalkView.getXWalkVersion();
92 public View getView() {
96 // For instrumentation test.
98 public String getTitleForTest() {
99 return mXWalkView.getTitle();
103 public void setCallbackForTest(Object callback) {
104 XWalkRuntimeTestHelper testHelper = new XWalkRuntimeTestHelper(mContext, mXWalkView);
105 testHelper.setCallbackForTest(callback);
106 mXWalkView.setUIClient(testHelper.getUIClient());
107 mXWalkView.setResourceClient(testHelper.getResourceClient());
111 public void loadDataForTest(String data, String mimeType, boolean isBase64Encoded) {
112 mXWalkView.load("", data);