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.chromium.content.browser.LoadUrlParams;
14 import org.xwalk.core.XWalkView;
15 import org.xwalk.core.XWalkPreferences;
18 * The implementation class for runtime core. It calls the methods provided
19 * by runtime core and customizes the behaviors for runtime.
21 class XWalkCoreProviderImpl implements XWalkRuntimeViewProvider {
22 private Context mContext;
23 private Activity mActivity;
24 private XWalkView mXWalkView;
26 public XWalkCoreProviderImpl(Context context, Activity activity) {
29 init(context, activity);
32 private void init(Context context, Activity activity) {
33 // TODO(yongsheng): do customizations for XWalkView. There will
34 // be many callback classes which are needed to be implemented.
35 mXWalkView = new XWalkView(context, activity);
39 public void loadAppFromUrl(String url) {
40 mXWalkView.load(url, null);
44 public void loadAppFromManifest(String manifestUrl) {
45 mXWalkView.loadAppFromManifest(manifestUrl, null);
49 public void onCreate() {
53 public void onResume() {
54 mXWalkView.resumeTimers();
59 public void onPause() {
60 mXWalkView.pauseTimers();
65 public void onDestroy() {
66 mXWalkView.onDestroy();
70 public void onActivityResult(int requestCode, int resultCode, Intent data) {
71 mXWalkView.onActivityResult(requestCode, resultCode, data);
75 public boolean onNewIntent(Intent intent) {
76 return mXWalkView.onNewIntent(intent);
80 public void enableRemoteDebugging(String frontEndUrl, String socketName) {
81 // TODO(yongsheng): Enable two parameters once they're supported in XWalkView.
82 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
86 public void disableRemoteDebugging() {
87 XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, false);
91 public String getVersion() {
92 return mXWalkView.getXWalkVersion();
96 public View getView() {
100 // For instrumentation test.
102 public String getTitleForTest() {
103 return mXWalkView.getTitle();
107 public void setCallbackForTest(Object callback) {
108 XWalkRuntimeTestHelper testHelper = new XWalkRuntimeTestHelper(mContext, mXWalkView);
109 testHelper.setCallbackForTest(callback);
110 mXWalkView.setUIClient(testHelper.getUIClient());
111 mXWalkView.setResourceClient(testHelper.getResourceClient());
115 public void loadDataForTest(String data, String mimeType, boolean isBase64Encoded) {
116 mXWalkView.load("", data);