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.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.core.XWalkView;
14 import org.xwalk.core.XWalkPreferences;
17 * The implementation class for runtime core. It calls the methods provided
18 * by runtime core and customizes the behaviors for runtime.
20 class XWalkCoreProviderImpl implements XWalkRuntimeViewProvider {
21 private Context mContext;
22 private Activity mActivity;
23 private XWalkView mXWalkView;
25 public XWalkCoreProviderImpl(Context context, Activity activity) {
28 init(context, activity);
31 private void init(Context context, Activity activity) {
32 // TODO(yongsheng): do customizations for XWalkView. There will
33 // be many callback classes which are needed to be implemented.
34 mXWalkView = new XWalkView(context, activity);
38 public void loadAppFromUrl(String url) {
39 mXWalkView.load(url, null);
43 public void loadAppFromManifest(String manifestUrl) {
44 mXWalkView.loadAppFromManifest(manifestUrl, null);
48 public void onCreate() {
52 public void onStart() {
56 public void onResume() {
60 public void onPause() {
64 public void onStop() {
68 public void onDestroy() {
72 public void onActivityResult(int requestCode, int resultCode, Intent data) {
73 mXWalkView.onActivityResult(requestCode, resultCode, data);
77 public boolean onNewIntent(Intent intent) {
78 return mXWalkView.onNewIntent(intent);
82 public void enableRemoteDebugging(String frontEndUrl, String socketName) {
83 // TODO(yongsheng): Enable two parameters once they're supported in XWalkView.
84 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
88 public void disableRemoteDebugging() {
89 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, false);
93 public String getVersion() {
94 return mXWalkView.getXWalkVersion();
98 public View getView() {
102 // For instrumentation test.
104 public String getTitleForTest() {
105 return mXWalkView.getTitle();
109 public void setCallbackForTest(Object callback) {
110 XWalkRuntimeTestHelper testHelper = new XWalkRuntimeTestHelper(mContext, mXWalkView);
111 testHelper.setCallbackForTest(callback);
112 mXWalkView.setUIClient(testHelper.getUIClient());
113 mXWalkView.setResourceClient(testHelper.getResourceClient());
117 public void loadDataForTest(String data, String mimeType, boolean isBase64Encoded) {
118 mXWalkView.load("", data);