diff --git a/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionClient.java b/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionClient.java
index 5896f96fd9..03fe53e1ef 100644
--- a/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionClient.java
+++ b/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionClient.java
@@ -25,7 +25,7 @@
*/
public class XWalkExtensionClient extends CrossPackageWrapper {
- private final static String EXTENSION_CLASS_NAME = "org.xwalk.core.extension.XWalkExtensionClientImpl";
+ private final static String EXTENSION_CLASS_NAME = "org.xwalk.core.internal.extension.XWalkExtensionClientImpl";
private Object mInstance;
private Method mGetExtensionName;
private Method mGetJsApi;
diff --git a/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionContextClient.java b/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionContextClient.java
index 9796466652..720398cdcb 100644
--- a/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionContextClient.java
+++ b/app/android/runtime_client/src/org/xwalk/app/runtime/extension/XWalkExtensionContextClient.java
@@ -23,7 +23,7 @@
*/
public final class XWalkExtensionContextClient extends CrossPackageWrapper {
private final static String EXTENSION_CLASS_NAME =
- "org.xwalk.core.extension.XWalkExtensionContextWrapper";
+ "org.xwalk.core.internal.extension.XWalkExtensionContextWrapper";
private Object mInstance;
private Method mGetContext;
private Method mGetActivity;
diff --git a/app/tools/android/make_apk.py b/app/tools/android/make_apk.py
index 4437248ef2..c11b1d2c78 100755
--- a/app/tools/android/make_apk.py
+++ b/app/tools/android/make_apk.py
@@ -316,7 +316,7 @@ def Execution(options, name):
res_ui_java = os.path.join('gen', 'ui_java')
res_content_java = os.path.join('gen', 'content_java')
- res_xwalk_java = os.path.join('gen', 'xwalk_core_java')
+ res_xwalk_java = os.path.join('gen', 'xwalk_core_internal_java')
res_dirs = ('-DADDITIONAL_RES_DIRS='
+ os.path.join(res_ui_java, 'res_crunched') + ' '
+ os.path.join(res_ui_java, 'res_v14_compatibility') + ' '
@@ -331,7 +331,7 @@ def Execution(options, name):
+ os.path.join('libs_res', 'runtime') + ' '
+ os.path.join(res_xwalk_java, 'res_grit'))
res_packages = ('-DADDITIONAL_RES_PACKAGES=org.chromium.ui '
- 'org.xwalk.core org.chromium.content')
+ 'org.xwalk.core.internal org.chromium.content')
res_r_text_files = ('-DADDITIONAL_R_TEXT_FILES='
+ os.path.join(res_ui_java, 'java_R', 'R.txt') + ' '
+ os.path.join(res_xwalk_java, 'java_R', 'R.txt') + ' '
diff --git a/build/android/generate_app_packaging_tool.py b/build/android/generate_app_packaging_tool.py
index e501026611..8dace51bba 100755
--- a/build/android/generate_app_packaging_tool.py
+++ b/build/android/generate_app_packaging_tool.py
@@ -76,7 +76,7 @@ def PrepareFromXwalk(src_dir, target_dir):
os.path.join(target_dir, 'libs_res/content')),
(os.path.join(source_code_dir, 'ui/android/java/res'),
os.path.join(target_dir, 'libs_res/ui')),
- (os.path.join(source_code_dir, 'xwalk/runtime/android/core/res'),
+ (os.path.join(source_code_dir, 'xwalk/runtime/android/core_internal/res'),
os.path.join(target_dir, 'libs_res/runtime')),
(os.path.join(gen_res_src_dir, 'ui_java/java_R'),
@@ -97,14 +97,16 @@ def PrepareFromXwalk(src_dir, target_dir):
(os.path.join(gen_res_src_dir, 'content_java/res_v14_compatibility'),
os.path.join(gen_res_target_dir, 'content_java/res_v14_compatibility')),
- (os.path.join(gen_res_src_dir, 'xwalk_core_java/java_R'),
- os.path.join(gen_res_target_dir, 'xwalk_core_java/java_R')),
- (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_crunched'),
- os.path.join(gen_res_target_dir, 'xwalk_core_java/res_crunched')),
- (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_grit'),
- os.path.join(gen_res_target_dir, 'xwalk_core_java/res_grit')),
- (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_v14_compatibility'),
- os.path.join(gen_res_target_dir, 'xwalk_core_java/res_v14_compatibility')),
+ (os.path.join(gen_res_src_dir, 'xwalk_core_internal_java/java_R'),
+ os.path.join(gen_res_target_dir, 'xwalk_core_internal_java/java_R')),
+ (os.path.join(gen_res_src_dir, 'xwalk_core_internal_java/res_crunched'),
+ os.path.join(gen_res_target_dir, 'xwalk_core_internal_java/res_crunched')),
+ (os.path.join(gen_res_src_dir, 'xwalk_core_internal_java/res_grit'),
+ os.path.join(gen_res_target_dir, 'xwalk_core_internal_java/res_grit')),
+ (os.path.join(gen_res_src_dir,
+ 'xwalk_core_internal_java/res_v14_compatibility'),
+ os.path.join(gen_res_target_dir,
+ 'xwalk_core_internal_java/res_v14_compatibility')),
# The app wrapper code. It's the template Java code.
(os.path.join(source_code_dir, 'xwalk/app/android/app_template'),
diff --git a/extensions/android/java/src/org/xwalk/core/extensions/XWalkExtensionAndroid.java b/extensions/android/java/src/org/xwalk/core/internal/extensions/XWalkExtensionAndroid.java
similarity index 98%
rename from extensions/android/java/src/org/xwalk/core/extensions/XWalkExtensionAndroid.java
rename to extensions/android/java/src/org/xwalk/core/internal/extensions/XWalkExtensionAndroid.java
index ea52ff12e6..5198ba72cb 100644
--- a/extensions/android/java/src/org/xwalk/core/extensions/XWalkExtensionAndroid.java
+++ b/extensions/android/java/src/org/xwalk/core/internal/extensions/XWalkExtensionAndroid.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extensions;
+package org.xwalk.core.internal.extensions;
import android.util.Log;
diff --git a/runtime/android/core_empty/src/org/xwalk/core/README.md b/runtime/android/core_empty/src/org/xwalk/core/README.md
new file mode 100644
index 0000000000..71377f6463
--- /dev/null
+++ b/runtime/android/core_empty/src/org/xwalk/core/README.md
@@ -0,0 +1,9 @@
+# Source folder for xwalk core reflection related java targets.
+## Why it's empty
+The source codes for reflection are generated at build time.
+The gyp system still needs a java_in_dir to work.
+So there is no java src here.
+## Why put me here
+To make git keep the folder, the src directory is needed to
+build an apk.
+
diff --git a/runtime/android/core/res/values/strings.xml b/runtime/android/core_internal/res/values/strings.xml
similarity index 100%
rename from runtime/android/core/res/values/strings.xml
rename to runtime/android/core_internal/res/values/strings.xml
diff --git a/runtime/android/core_internal/resource_map/org/xwalk/core/internal/R.java b/runtime/android/core_internal/resource_map/org/xwalk/core/internal/R.java
new file mode 100644
index 0000000000..9ab28ec75b
--- /dev/null
+++ b/runtime/android/core_internal/resource_map/org/xwalk/core/internal/R.java
@@ -0,0 +1,188 @@
+// Copyright 2014 Intel Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.xwalk.core.internal;
+
+/**
+ * Provide XWalk Core internal resources to XWalk Core layer.
+ * The main purpose is to dynamically set the value of following
+ * resources ids when building xwalk core as a library project.
+ * In such case, the ant build system won't generate R.java
+ * for package org.xwalk.core.internal. However, the code inside
+ * org.xwalk.core.internal uses org.xwalk.core.internal.R.
+ */
+
+public final class R {
+ public static final class attr {
+ public static int select_dialog_multichoice;
+ public static int select_dialog_singlechoice;
+ }
+ public static final class color {
+ public static int autofill_dark_divider_color;
+ public static int autofill_divider_color;
+ public static int color_picker_background_color;
+ public static int color_picker_border_color;
+ }
+ public static final class dimen {
+ public static int autofill_text_divider_height;
+ public static int autofill_text_height;
+ public static int color_button_height;
+ public static int color_picker_gradient_margin;
+ public static int config_min_scaling_span;
+ public static int config_min_scaling_touch_major;
+ public static int link_preview_overlay_radius;
+ }
+ public static final class drawable {
+ public static int autofill_popup_background;
+ public static int autofill_popup_background_down;
+ public static int autofill_popup_background_up;
+ public static int bubble;
+ public static int bubble_arrow_up;
+ public static int color_button_background;
+ public static int color_picker_advanced_select_handle;
+ public static int color_picker_border;
+ public static int ic_menu_search_holo_light;
+ public static int ic_menu_share_holo_light;
+ public static int ondemand_overlay;
+ public static int pageinfo_warning_major;
+ }
+ public static final class id {
+ public static int ampm;
+ public static int arrow_image;
+ public static int autofill_label;
+ public static int autofill_menu_text;
+ public static int autofill_popup_window;
+ public static int autofill_sublabel;
+ public static int color_button_swatch;
+ public static int color_picker_advanced;
+ public static int color_picker_simple;
+ public static int date_picker;
+ public static int date_time_suggestion;
+ public static int date_time_suggestion_label;
+ public static int date_time_suggestion_value;
+ public static int gradient;
+ public static int gradient_border;
+ public static int hour;
+ public static int icon_view;
+ public static int main_text;
+ public static int milli;
+ public static int minute;
+ public static int more_colors_button;
+ public static int more_colors_button_border;
+ public static int pickers;
+ public static int position_in_year;
+ public static int second;
+ public static int second_colon;
+ public static int second_dot;
+ public static int seek_bar;
+ public static int select_action_menu_copy;
+ public static int select_action_menu_cut;
+ public static int select_action_menu_paste;
+ public static int select_action_menu_select_all;
+ public static int select_action_menu_share;
+ public static int select_action_menu_web_search;
+ public static int selected_color_view;
+ public static int selected_color_view_border;
+ public static int sub_text;
+ public static int text;
+ public static int text_wrapper;
+ public static int time_picker;
+ public static int title;
+ public static int top_view;
+ public static int year;
+ }
+ public static final class layout {
+ public static int autofill_text;
+ public static int color_picker_advanced_component;
+ public static int color_picker_dialog_content;
+ public static int color_picker_dialog_title;
+ public static int date_time_picker_dialog;
+ public static int date_time_suggestion;
+ public static int multi_field_time_picker_dialog;
+ public static int two_field_date_picker;
+ public static int validation_message_bubble;
+ }
+ public static final class menu {
+ public static int select_action_menu;
+ }
+ public static final class mipmap {
+ public static int app_icon;
+ }
+ public static final class string {
+ public static int accessibility_content_view;
+ public static int accessibility_date_picker_month;
+ public static int accessibility_date_picker_week;
+ public static int accessibility_date_picker_year;
+ public static int accessibility_datetime_picker_date;
+ public static int accessibility_datetime_picker_time;
+ public static int accessibility_time_picker_ampm;
+ public static int accessibility_time_picker_hour;
+ public static int accessibility_time_picker_milli;
+ public static int accessibility_time_picker_minute;
+ public static int accessibility_time_picker_second;
+ public static int actionbar_share;
+ public static int actionbar_web_search;
+ public static int color_picker_button_black;
+ public static int color_picker_button_blue;
+ public static int color_picker_button_cancel;
+ public static int color_picker_button_cyan;
+ public static int color_picker_button_green;
+ public static int color_picker_button_magenta;
+ public static int color_picker_button_more;
+ public static int color_picker_button_red;
+ public static int color_picker_button_set;
+ public static int color_picker_button_white;
+ public static int color_picker_button_yellow;
+ public static int color_picker_dialog_title;
+ public static int color_picker_hue;
+ public static int color_picker_saturation;
+ public static int color_picker_value;
+ public static int copy_to_clipboard_failure_message;
+ public static int cpu_arch_mismatch_message;
+ public static int cpu_arch_mismatch_title;
+ public static int date_picker_dialog_clear;
+ public static int date_picker_dialog_other_button_label;
+ public static int date_picker_dialog_set;
+ public static int date_picker_dialog_title;
+ public static int date_time_picker_dialog_title;
+ public static int download_already_exists_toast;
+ public static int download_failed_toast;
+ public static int download_finished_toast;
+ public static int download_no_permission_toast;
+ public static int download_start_toast;
+ public static int goto_store_button_label;
+ public static int http_auth_log_in;
+ public static int http_auth_password;
+ public static int http_auth_title;
+ public static int http_auth_user_name;
+ public static int js_alert_title;
+ public static int js_confirm_title;
+ public static int js_prompt_title;
+ public static int low_memory_error;
+ public static int media_player_error_button;
+ public static int media_player_error_text_invalid_progressive_playback;
+ public static int media_player_error_text_unknown;
+ public static int media_player_error_title;
+ public static int media_player_loading_video;
+ public static int month_picker_dialog_title;
+ public static int opening_file_error;
+ public static int profiler_error_toast;
+ public static int profiler_no_storage_toast;
+ public static int profiler_started_toast;
+ public static int profiler_stopped_toast;
+ public static int report_feedback_button_label;
+ public static int ssl_alert_title;
+ public static int time_picker_dialog_am;
+ public static int time_picker_dialog_hour_minute_separator;
+ public static int time_picker_dialog_minute_second_separator;
+ public static int time_picker_dialog_pm;
+ public static int time_picker_dialog_second_subsecond_separator;
+ public static int time_picker_dialog_title;
+ public static int week_picker_dialog_title;
+ }
+ public static final class style {
+ public static int AutofillPopupWindow;
+ public static int SelectPopupDialog;
+ }
+}
diff --git a/runtime/android/core/src/org/xwalk/core/JavascriptInterface.java b/runtime/android/core_internal/src/org/xwalk/core/JavascriptInterface.java
similarity index 89%
rename from runtime/android/core/src/org/xwalk/core/JavascriptInterface.java
rename to runtime/android/core_internal/src/org/xwalk/core/JavascriptInterface.java
index af18ec6847..39f89e5e04 100644
--- a/runtime/android/core/src/org/xwalk/core/JavascriptInterface.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/JavascriptInterface.java
@@ -14,7 +14,7 @@
* Marks a method as being able to be exposed to JavaScript. This is used for
* safety purposes so that only explicitly marked methods get exposed instead
* of every method in a class.
- * See the explanation for {@link XWalkView#addJavascriptInterface(Object, String)}
+ * See the explanation for {@link XWalkViewInternal#addJavascriptInterface(Object, String)}
* about the usage.
*/
@SuppressWarnings("javadoc")
diff --git a/runtime/android/core/src/org/xwalk/core/AndroidProtocolHandler.java b/runtime/android/core_internal/src/org/xwalk/core/internal/AndroidProtocolHandler.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/AndroidProtocolHandler.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/AndroidProtocolHandler.java
index 1373072725..d4cf78ab79 100644
--- a/runtime/android/core/src/org/xwalk/core/AndroidProtocolHandler.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/AndroidProtocolHandler.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.Context;
import android.content.res.AssetManager;
diff --git a/runtime/android/core/src/org/xwalk/core/DownloadListener.java b/runtime/android/core_internal/src/org/xwalk/core/internal/DownloadListener.java
similarity index 91%
rename from runtime/android/core/src/org/xwalk/core/DownloadListener.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/DownloadListener.java
index f2c3771e79..79ce37e318 100644
--- a/runtime/android/core/src/org/xwalk/core/DownloadListener.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/DownloadListener.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
interface DownloadListener {
diff --git a/runtime/android/core/src/org/xwalk/core/ErrorCodeConversionHelper.java b/runtime/android/core_internal/src/org/xwalk/core/internal/ErrorCodeConversionHelper.java
similarity index 76%
rename from runtime/android/core/src/org/xwalk/core/ErrorCodeConversionHelper.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/ErrorCodeConversionHelper.java
index ea2d849a5a..050f0dafca 100644
--- a/runtime/android/core/src/org/xwalk/core/ErrorCodeConversionHelper.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/ErrorCodeConversionHelper.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.net.NetError;
@@ -15,41 +15,41 @@ static int convertErrorCode(int netError) {
// These will be handled by the default case, ERROR_UNKNOWN.
switch (netError) {
case NetError.ERR_UNSUPPORTED_AUTH_SCHEME:
- return XWalkResourceClient.ERROR_UNSUPPORTED_AUTH_SCHEME;
+ return XWalkResourceClientInternal.ERROR_UNSUPPORTED_AUTH_SCHEME;
case NetError.ERR_INVALID_AUTH_CREDENTIALS:
case NetError.ERR_MISSING_AUTH_CREDENTIALS:
case NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT:
- return XWalkResourceClient.ERROR_AUTHENTICATION;
+ return XWalkResourceClientInternal.ERROR_AUTHENTICATION;
case NetError.ERR_TOO_MANY_REDIRECTS:
- return XWalkResourceClient.ERROR_REDIRECT_LOOP;
+ return XWalkResourceClientInternal.ERROR_REDIRECT_LOOP;
case NetError.ERR_UPLOAD_FILE_CHANGED:
- return XWalkResourceClient.ERROR_FILE_NOT_FOUND;
+ return XWalkResourceClientInternal.ERROR_FILE_NOT_FOUND;
case NetError.ERR_INVALID_URL:
- return XWalkResourceClient.ERROR_BAD_URL;
+ return XWalkResourceClientInternal.ERROR_BAD_URL;
case NetError.ERR_DISALLOWED_URL_SCHEME:
case NetError.ERR_UNKNOWN_URL_SCHEME:
- return XWalkResourceClient.ERROR_UNSUPPORTED_SCHEME;
+ return XWalkResourceClientInternal.ERROR_UNSUPPORTED_SCHEME;
case NetError.ERR_IO_PENDING:
case NetError.ERR_NETWORK_IO_SUSPENDED:
- return XWalkResourceClient.ERROR_IO;
+ return XWalkResourceClientInternal.ERROR_IO;
case NetError.ERR_CONNECTION_TIMED_OUT:
case NetError.ERR_TIMED_OUT:
- return XWalkResourceClient.ERROR_TIMEOUT;
+ return XWalkResourceClientInternal.ERROR_TIMEOUT;
case NetError.ERR_FILE_TOO_BIG:
- return XWalkResourceClient.ERROR_FILE;
+ return XWalkResourceClientInternal.ERROR_FILE;
case NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE:
case NetError.ERR_INSUFFICIENT_RESOURCES:
case NetError.ERR_OUT_OF_MEMORY:
- return XWalkResourceClient.ERROR_TOO_MANY_REQUESTS;
+ return XWalkResourceClientInternal.ERROR_TOO_MANY_REQUESTS;
case NetError.ERR_CONNECTION_CLOSED:
case NetError.ERR_CONNECTION_RESET:
@@ -57,14 +57,14 @@ static int convertErrorCode(int netError) {
case NetError.ERR_CONNECTION_ABORTED:
case NetError.ERR_CONNECTION_FAILED:
case NetError.ERR_SOCKET_NOT_CONNECTED:
- return XWalkResourceClient.ERROR_CONNECT;
+ return XWalkResourceClientInternal.ERROR_CONNECT;
case NetError.ERR_INTERNET_DISCONNECTED:
case NetError.ERR_ADDRESS_INVALID:
case NetError.ERR_ADDRESS_UNREACHABLE:
case NetError.ERR_NAME_NOT_RESOLVED:
case NetError.ERR_NAME_RESOLUTION_FAILED:
- return XWalkResourceClient.ERROR_HOST_LOOKUP;
+ return XWalkResourceClientInternal.ERROR_HOST_LOOKUP;
case NetError.ERR_SSL_PROTOCOL_ERROR:
case NetError.ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
@@ -81,13 +81,13 @@ static int convertErrorCode(int netError) {
case NetError.ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
case NetError.ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
case NetError.ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
- return XWalkResourceClient.ERROR_FAILED_SSL_HANDSHAKE;
+ return XWalkResourceClientInternal.ERROR_FAILED_SSL_HANDSHAKE;
case NetError.ERR_PROXY_AUTH_UNSUPPORTED:
case NetError.ERR_PROXY_AUTH_REQUESTED:
case NetError.ERR_PROXY_CONNECTION_FAILED:
case NetError.ERR_UNEXPECTED_PROXY_AUTH:
- return XWalkResourceClient.ERROR_PROXY_AUTHENTICATION;
+ return XWalkResourceClientInternal.ERROR_PROXY_AUTHENTICATION;
// The certificate errors are handled by onReceivedSslError
// and don't need to be reported here.
@@ -101,10 +101,10 @@ static int convertErrorCode(int netError) {
case NetError.ERR_CERT_INVALID:
case NetError.ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
case NetError.ERR_CERT_NON_UNIQUE_NAME:
- return XWalkResourceClient.ERROR_OK;
+ return XWalkResourceClientInternal.ERROR_OK;
default:
- return XWalkResourceClient.ERROR_UNKNOWN;
+ return XWalkResourceClientInternal.ERROR_UNKNOWN;
}
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/InMemorySharedPreferences.java b/runtime/android/core_internal/src/org/xwalk/core/internal/InMemorySharedPreferences.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/InMemorySharedPreferences.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/InMemorySharedPreferences.java
index 37747094ec..dc39b201d3 100644
--- a/runtime/android/core/src/org/xwalk/core/InMemorySharedPreferences.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/InMemorySharedPreferences.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.SharedPreferences;
diff --git a/runtime/android/core/src/org/xwalk/core/InterceptedRequestData.java b/runtime/android/core_internal/src/org/xwalk/core/internal/InterceptedRequestData.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/InterceptedRequestData.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/InterceptedRequestData.java
index da48833d81..35e23112ef 100644
--- a/runtime/android/core/src/org/xwalk/core/InterceptedRequestData.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/InterceptedRequestData.java
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// This file is imported from the upstream.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/PageLoadListener.java b/runtime/android/core_internal/src/org/xwalk/core/internal/PageLoadListener.java
similarity index 88%
rename from runtime/android/core/src/org/xwalk/core/PageLoadListener.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/PageLoadListener.java
index e5f2ad79d7..758ac17327 100644
--- a/runtime/android/core/src/org/xwalk/core/PageLoadListener.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/PageLoadListener.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
interface PageLoadListener {
diff --git a/runtime/android/core_internal/src/org/xwalk/core/internal/ReflectionHelper.java b/runtime/android/core_internal/src/org/xwalk/core/internal/ReflectionHelper.java
new file mode 100644
index 0000000000..70b59a2a2a
--- /dev/null
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/ReflectionHelper.java
@@ -0,0 +1,183 @@
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.xwalk.core.internal;
+
+import android.content.Context;
+import android.content.pm.PackageManager.NameNotFoundException;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.HashMap;
+
+public class ReflectionHelper {
+ static class ConstructorHelper {
+ private String fullClassName;
+ private Object[] paramTypes;
+
+ Constructor> loadConstructor() {
+ Class> clazz = loadClass(fullClassName);
+ Class>[] params = new Class>[paramTypes.length];
+ for (int i = 0; i < paramTypes.length; i++) {
+ Object type = paramTypes[i];
+ if (type instanceof Class>) {
+ params[i] = (Class>) type;
+ } else if (type instanceof String) {
+ params[i] = loadClass((String) type);
+ }
+ }
+ try {
+ return clazz.getConstructor(params);
+ } catch (NoSuchMethodException e) {
+ ReflectionHelper.handleException(e);
+ return null;
+ }
+ }
+
+ ConstructorHelper(String className, Object... paramTypes) {
+ this.fullClassName = className;
+ this.paramTypes = paramTypes;
+ }
+ }
+
+ private static Map, Method> sBridgeWrapperMap = new HashMap, Method>();
+ private static Map> sConstructorMap = new HashMap>();
+ private static Map sConstructorHelperMap =
+ new HashMap();
+ private static ClassLoader sBridgeOrWrapperLoader = null;
+ private static boolean sIsWrapper;
+ private final static String INTERNAL_PACKAGE = "org.xwalk.core.internal";
+ private static boolean sClassLoaderUpdated = true;
+
+ public static void init(boolean crossPackage) {
+ assert isWrapper();
+ if (!crossPackage) {
+ initClassLoader(ReflectionHelper.class.getClassLoader());
+ }
+ }
+
+ public static void initClassLoader(ClassLoader loader) {
+ sBridgeOrWrapperLoader = loader;
+ sBridgeWrapperMap.clear();
+ sConstructorMap.clear();
+ try {
+ for (String name : sConstructorHelperMap.keySet()) {
+ ConstructorHelper helper = sConstructorHelperMap.get(name);
+ if (helper != null) sConstructorMap.put(name, helper.loadConstructor());
+ }
+ if (sIsWrapper) {
+ Class> helperInBridge =
+ sBridgeOrWrapperLoader.loadClass(INTERNAL_PACKAGE + "." + "ReflectionHelper");
+ Method initInBridge = helperInBridge.getMethod("initClassLoader", ClassLoader.class);
+ initInBridge.invoke(null, ReflectionHelper.class.getClassLoader());
+ }
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public static void registerConstructor(String name, String clazz, Object... params) {
+ sConstructorHelperMap.put(name, new ConstructorHelper(clazz, params));
+ }
+
+ public static Class> loadClass(String clazz) {
+ if (sBridgeOrWrapperLoader == null) init(false);
+ try {
+ return sBridgeOrWrapperLoader.loadClass(clazz);
+ } catch (ClassNotFoundException e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public static Method loadMethod(Class> clazz, String name, Class>... paramTypes) {
+ try {
+ return clazz.getMethod(name, paramTypes);
+ } catch (NoSuchMethodException e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public static void handleException(Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ public static void handleException(String e) {
+ handleException(new RuntimeException(e));
+ }
+
+ public static Object createInstance(String name, Object... parameters) {
+ Object ret = null;
+ Constructor> creator = sConstructorMap.get(name);
+ if (creator == null) {
+ ConstructorHelper helper = sConstructorHelperMap.get(name);
+ if (helper != null) {
+ creator = helper.loadConstructor();
+ sConstructorMap.put(name, creator);
+ }
+ }
+ if (creator != null) {
+ try {
+ ret = creator.newInstance(parameters);
+ } catch (IllegalArgumentException e) {
+ handleException(e);
+ } catch (InstantiationException e) {
+ handleException(e);
+ } catch (IllegalAccessException e) {
+ handleException(e);
+ } catch (InvocationTargetException e) {
+ handleException(e);
+ }
+ }
+ return ret;
+ }
+
+ public static Object invokeMethod(Method m, Object instance, Object... parameters) {
+ Object ret = null;
+ if (m != null) {
+ try {
+ ret = m.invoke(instance, parameters);
+ } catch (IllegalArgumentException e) {
+ handleException(e);
+ } catch (IllegalAccessException e) {
+ handleException(e);
+ } catch (InvocationTargetException e) {
+ handleException(e);
+ } catch (NullPointerException e) {
+ handleException(e);
+ }
+ }
+ return ret;
+ }
+
+ public static Object getBridgeOrWrapper(Object instance) {
+ Class> clazz = instance.getClass();
+ Method method = sBridgeWrapperMap.get(clazz);
+ if (method == null) {
+ String methodName = "getBridge";
+ if (sIsWrapper) {
+ methodName = "getWrapper";
+ }
+ try {
+ method = clazz.getMethod(methodName);
+ } catch (NoSuchMethodException e) {
+ handleException(e);
+ }
+ if (method != null) sBridgeWrapperMap.put(clazz, method);
+ }
+ return invokeMethod(method, instance);
+ }
+
+ private static boolean isWrapper() {
+ return !ReflectionHelper.class.getPackage().getName().equals(INTERNAL_PACKAGE);
+ }
+
+ static {
+ sIsWrapper = isWrapper();
+ }
+}
diff --git a/runtime/android/core/src/org/xwalk/core/SslUtil.java b/runtime/android/core_internal/src/org/xwalk/core/internal/SslUtil.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/SslUtil.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/SslUtil.java
index 430daf7746..398c244e1f 100644
--- a/runtime/android/core/src/org/xwalk/core/SslUtil.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/SslUtil.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.net.http.SslCertificate;
import android.net.http.SslError;
diff --git a/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkAPI.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkAPI.java
new file mode 100644
index 0000000000..cf831de22e
--- /dev/null
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkAPI.java
@@ -0,0 +1,17 @@
+package org.xwalk.core.internal;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface XWalkAPI {
+ Class> impl() default Object.class;
+ Class> instance() default Object.class;
+ boolean createInternally() default false;
+ boolean createExternally() default false;
+ boolean noInstance() default false;
+ boolean isConst() default false;
+ Class> extendClass() default Object.class;
+ String[] preWrapperLines() default {};
+ String[] postWrapperLines() default {};
+}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkClient.java
similarity index 77%
rename from runtime/android/core/src/org/xwalk/core/XWalkClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkClient.java
index 140f47fc49..c6408a6de3 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkClient.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.app.AlertDialog;
@@ -33,7 +33,7 @@
/**
* It's the Internal class to handle legacy resource related callbacks not
- * handled by XWalkResourceClient.
+ * handled by XWalkResourceClientInternal.
*
* @hide
*/
@@ -41,27 +41,27 @@ public class XWalkClient {
private Context mContext;
private AlertDialog mDialog;
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
- public XWalkClient(XWalkView view) {
+ public XWalkClient(XWalkViewInternal view) {
mContext = view.getContext();
mXWalkView = view;
}
/**
* Give the host application a chance to take over the control when a new
- * url is about to be loaded in the current XWalkView. If XWalkClient is not
- * provided, by default XWalkView will ask Activity Manager to choose the
+ * url is about to be loaded in the current XWalkViewInternal. If XWalkClient is not
+ * provided, by default XWalkViewInternal will ask Activity Manager to choose the
* proper handler for the url. If XWalkClient is provided, return true
* means the host application handles the url, while return false means the
- * current XWalkView handles the url.
+ * current XWalkViewInternal handles the url.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param url The url to be loaded.
- * @return True if the host application wants to leave the current XWalkView
+ * @return True if the host application wants to leave the current XWalkViewInternal
* and handle the url itself, otherwise return false.
*/
- public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
+ public boolean shouldOverrideUrlLoading(XWalkViewInternal view, String url) {
return false;
}
@@ -72,38 +72,38 @@ public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
* means that onPageStarted will not be called when the contents of an
* embedded frame changes, i.e. clicking a link whose target is an iframe.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param url The url to be loaded.
*/
- public void onPageStarted(XWalkView view, String url) {
+ public void onPageStarted(XWalkViewInternal view, String url) {
}
/**
* Notify the host application that a page has finished loading. This method
* is called only for main frame. When onPageFinished() is called, the
* rendering picture may not be updated yet. To get the notification for the
- * new Picture, use {@link XWalkView.PictureListener#onNewPicture}.
+ * new Picture, use {@link XWalkViewInternal.PictureListener#onNewPicture}.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param url The url of the page.
*/
- public void onPageFinished(XWalkView view, String url) {
+ public void onPageFinished(XWalkViewInternal view, String url) {
}
/**
- * Notify the host application that the renderer of XWalkView is hung.
+ * Notify the host application that the renderer of XWalkViewInternal is hung.
*
- * @param view The XWalkView on which the render is hung.
+ * @param view The XWalkViewInternal on which the render is hung.
*/
- public void onRendererUnresponsive(XWalkView view) {
+ public void onRendererUnresponsive(XWalkViewInternal view) {
}
/**
- * Notify the host application that the renderer of XWalkView is no longer hung.
+ * Notify the host application that the renderer of XWalkViewInternal is no longer hung.
*
- * @param view The XWalkView which becomes responsive now.
+ * @param view The XWalkViewInternal which becomes responsive now.
*/
- public void onRendererResponsive(XWalkView view) {
+ public void onRendererResponsive(XWalkViewInternal view) {
}
/**
@@ -112,14 +112,14 @@ public void onRendererResponsive(XWalkView view) {
* trying to load the resource. The default behavior is to send the cancel
* message.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param cancelMsg The message to send if the host wants to cancel
* @param continueMsg The message to send if the host wants to continue
- * @deprecated This method is no longer called. When the XWalkView encounters
+ * @deprecated This method is no longer called. When the XWalkViewInternal encounters
* a redirect loop, it will cancel the load.
*/
@Deprecated
- public void onTooManyRedirects(XWalkView view, Message cancelMsg,
+ public void onTooManyRedirects(XWalkViewInternal view, Message cancelMsg,
Message continueMsg) {
cancelMsg.sendToTarget();
}
@@ -129,11 +129,11 @@ public void onTooManyRedirects(XWalkView view, Message cancelMsg,
* requested page was a result of a POST. The default is to not resend the
* data.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param dontResend The message to send if the browser should not resend
* @param resend The message to send if the browser should resend data
*/
- public void onFormResubmission(XWalkView view, Message dontResend,
+ public void onFormResubmission(XWalkViewInternal view, Message dontResend,
Message resend) {
dontResend.sendToTarget();
}
@@ -141,11 +141,11 @@ public void onFormResubmission(XWalkView view, Message dontResend,
/**
* Notify the host application to update its visited links database.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param url The url being visited.
* @param isReload True if this url is being reloaded.
*/
- public void doUpdateVisitedHistory(XWalkView view, String url,
+ public void doUpdateVisitedHistory(XWalkViewInternal view, String url,
boolean isReload) {
}
@@ -156,13 +156,13 @@ public void doUpdateVisitedHistory(XWalkView view, String url,
* response to future SSL errors. The default behavior is to cancel the
* load.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param callback The callback class. Passing 'true' means accepting the
* ssl error and continue to load. Passing 'false' means
* forbidding to load the web page.
* @param error The SSL error object.
*/
- public void onReceivedSslError(XWalkView view, ValueCallback callback,
+ public void onReceivedSslError(XWalkViewInternal view, ValueCallback callback,
SslError error) {
final ValueCallback valueCallback = callback;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
@@ -186,11 +186,11 @@ public void onCancel(DialogInterface dialog) {
/**
* Notify the host application that an SSL error occurred while loading a
- * resource, but the XWalkView chose to proceed anyway based on a
+ * resource, but the XWalkViewInternal chose to proceed anyway based on a
* decision retained from a previous response to onReceivedSslError().
* @hide
*/
- public void onProceededAfterSslError(XWalkView view, SslError error) {
+ public void onProceededAfterSslError(XWalkViewInternal view, SslError error) {
}
/**
@@ -201,7 +201,7 @@ public void onProceededAfterSslError(XWalkView view, SslError error) {
* connection is suspended and waiting for the response. The
* default behavior is to cancel, returning no client certificate.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param handler A ClientCertRequestHandler object that will
* handle the user's response.
* @param host_and_port The host and port of the requesting server.
@@ -210,7 +210,7 @@ public void onProceededAfterSslError(XWalkView view, SslError error) {
*/
// TODO: comment this method temporarily, will implemtent later when all
// dependencies are resovled.
- // public void onReceivedClientCertRequest(XWalkView view,
+ // public void onReceivedClientCertRequest(XWalkViewInternal view,
// ClientCertRequestHandler handler, String host_and_port) {
// handler.cancel();
// }
@@ -219,13 +219,13 @@ public void onProceededAfterSslError(XWalkView view, SslError error) {
* Notify the host application to handle an authentication request. The
* default behavior is to cancel the request.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param handler The XWalkHttpAuthHandler that will handle the user's response.
* @param host The host requiring authentication.
* @param realm A description to help store user credentials for future
* visits.
*/
- public void onReceivedHttpAuthRequest(XWalkView view,
+ public void onReceivedHttpAuthRequest(XWalkViewInternal view,
XWalkHttpAuthHandler handler, String host, String realm) {
if (view == null) return;
@@ -263,30 +263,30 @@ public void onCancel(DialogInterface dialog) {
/**
* Give the host application a chance to handle the key event synchronously.
* e.g. menu shortcut key events need to be filtered this way. If return
- * true, XWalkView will not handle the key event. If return false, XWalkView
+ * true, XWalkViewInternal will not handle the key event. If return false, XWalkViewInternal
* will always handle the key event, so none of the super in the view chain
* will see the key event. The default behavior returns false.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param event The key event.
* @return True if the host application wants to handle the key event
* itself, otherwise return false
*/
- public boolean shouldOverrideKeyEvent(XWalkView view, KeyEvent event) {
+ public boolean shouldOverrideKeyEvent(XWalkViewInternal view, KeyEvent event) {
return false;
}
/**
- * Notify the host application that a key was not handled by the XWalkView.
- * Except system keys, XWalkView always consumes the keys in the normal flow
+ * Notify the host application that a key was not handled by the XWalkViewInternal.
+ * Except system keys, XWalkViewInternal always consumes the keys in the normal flow
* or if shouldOverrideKeyEvent returns true. This is called asynchronously
* from where the key is dispatched. It gives the host application a chance
* to handle the unhandled key events.
*
- * @param view The XWalkView that is initiating the callback.
+ * @param view The XWalkViewInternal that is initiating the callback.
* @param event The key event.
*/
- public void onUnhandledKeyEvent(XWalkView view, KeyEvent event) {
+ public void onUnhandledKeyEvent(XWalkViewInternal view, KeyEvent event) {
// TODO: Commment the below code for compile
// ViewRootImpl root = view.getViewRootImpl();
// if (root != null) {
@@ -297,18 +297,18 @@ public void onUnhandledKeyEvent(XWalkView view, KeyEvent event) {
/**
* Notify the host application that a request to automatically log in the
* user has been processed.
- * @param view The XWalkView requesting the login.
+ * @param view The XWalkViewInternal requesting the login.
* @param realm The account realm used to look up accounts.
* @param account An optional account. If not null, the account should be
* checked against accounts on the device. If it is a valid
* account, it should be used to log in the user.
* @param args Authenticator specific arguments used to log in the user.
*/
- public void onReceivedLoginRequest(XWalkView view, String realm,
+ public void onReceivedLoginRequest(XWalkViewInternal view, String realm,
String account, String args) {
}
// TODO(yongsheng): legacy method. Consider removing it?
- public void onLoadResource(XWalkView view, String url) {
+ public void onLoadResource(XWalkViewInternal view, String url) {
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContent.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContent.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/XWalkContent.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContent.java
index 611d8d1582..3709449954 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContent.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContent.java
@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.content.Context;
@@ -36,19 +36,21 @@
import org.chromium.media.MediaPlayerBridge;
import org.chromium.ui.base.ActivityWindowAndroid;
+import org.xwalk.core.JavascriptInterface;
+
@JNINamespace("xwalk")
/**
- * This class is the implementation class for XWalkView by calling internal
+ * This class is the implementation class for XWalkViewInternal by calling internal
* various classes.
*/
-class XWalkContent extends FrameLayout implements XWalkPreferences.KeyValueChangeListener {
+class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyValueChangeListener {
private static String TAG = "XWalkContent";
private ContentViewCore mContentViewCore;
private ContentView mContentView;
private ContentViewRenderView mContentViewRenderView;
private ActivityWindowAndroid mWindow;
private XWalkDevToolsServer mDevToolsServer;
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
private XWalkContentsClientBridge mContentsClientBridge;
private XWalkContentsIoThreadClient mIoThreadClient;
private XWalkWebContentsDelegateAdapter mXWalkContentsDelegateAdapter;
@@ -62,7 +64,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferences.KeyValueChang
String mPendingUrl = null;
String mPendingData = null;
- public XWalkContent(Context context, AttributeSet attrs, XWalkView xwView) {
+ public XWalkContent(Context context, AttributeSet attrs, XWalkViewInternal xwView) {
super(context, attrs);
// Initialize the WebContensDelegate.
@@ -76,7 +78,7 @@ public XWalkContent(Context context, AttributeSet attrs, XWalkView xwView) {
mWindow = new ActivityWindowAndroid(xwView.getActivity());
// Initialize ContentViewRenderView
- boolean animated = XWalkPreferences.getValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW);
+ boolean animated = XWalkPreferencesInternal.getValue(XWalkPreferencesInternal.ANIMATABLE_XWALK_VIEW);
CompositingSurfaceType surfaceType =
animated ? CompositingSurfaceType.TEXTURE_VIEW : CompositingSurfaceType.SURFACE_VIEW;
mContentViewRenderView = new ContentViewRenderView(context, mWindow, surfaceType) {
@@ -131,7 +133,7 @@ protected void onReadyToRender() {
MediaPlayerBridge.setResourceLoadingFilter(
new XWalkMediaPlayerResourceLoadingFilter());
- XWalkPreferences.load(this);
+ XWalkPreferencesInternal.load(this);
}
void doLoadUrl(String url, String content) {
@@ -171,10 +173,10 @@ public void loadUrl(String url, String data) {
public void reload(int mode) {
if (mReadyToLoad) {
switch (mode) {
- case XWalkView.RELOAD_IGNORE_CACHE:
+ case XWalkViewInternal.RELOAD_IGNORE_CACHE:
mContentViewCore.reloadIgnoringCache(true);
break;
- case XWalkView.RELOAD_NORMAL:
+ case XWalkViewInternal.RELOAD_NORMAL:
default:
mContentViewCore.reload(true);
@@ -210,11 +212,11 @@ public void handleJavaScriptResult(String jsonResult) {
mContentViewCore.evaluateJavaScript(script, coreCallback);
}
- public void setUIClient(XWalkUIClient client) {
+ public void setUIClient(XWalkUIClientInternal client) {
mContentsClientBridge.setUIClient(client);
}
- public void setResourceClient(XWalkResourceClient client) {
+ public void setResourceClient(XWalkResourceClientInternal client) {
mContentsClientBridge.setResourceClient(client);
}
@@ -373,13 +375,13 @@ public void loadAppFromManifest(String url, String data) {
}
}
- public XWalkNavigationHistory getNavigationHistory() {
- return new XWalkNavigationHistory(mXWalkView, mContentViewCore.getNavigationHistory());
+ public XWalkNavigationHistoryInternal getNavigationHistory() {
+ return new XWalkNavigationHistoryInternal(mXWalkView, mContentViewCore.getNavigationHistory());
}
public static final String SAVE_RESTORE_STATE_KEY = "XWALKVIEW_STATE";
- public XWalkNavigationHistory saveState(Bundle outState) {
+ public XWalkNavigationHistoryInternal saveState(Bundle outState) {
if (outState == null) return null;
byte[] state = nativeGetState(mXWalkContent);
@@ -389,7 +391,7 @@ public XWalkNavigationHistory saveState(Bundle outState) {
return getNavigationHistory();
}
- public XWalkNavigationHistory restoreState(Bundle inState) {
+ public XWalkNavigationHistoryInternal restoreState(Bundle inState) {
if (inState == null) return null;
byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
@@ -441,7 +443,7 @@ public void onGetFullscreenFlagFromManifest(boolean enterFullscreen) {
public void destroy() {
if (mXWalkContent == 0) return;
- XWalkPreferences.unload(this);
+ XWalkPreferencesInternal.unload(this);
// Reset existing notification service in order to destruct it.
setNotificationService(null);
// Remove its children used for page rendering from view hierarchy.
@@ -486,7 +488,7 @@ public InterceptedRequestData shouldInterceptRequest(final String url,
} else {
if (isMainFrame && webResourceResponse.getData() == null) {
mContentsClientBridge.getCallbackHelper().postOnReceivedError(
- XWalkResourceClient.ERROR_UNKNOWN, null, url);
+ XWalkResourceClientInternal.ERROR_UNKNOWN, null, url);
}
interceptedRequestData = new InterceptedRequestData(webResourceResponse.getMimeType(),
webResourceResponse.getEncoding(),
@@ -599,7 +601,7 @@ void disableRemoteDebugging() {
@Override
public void onKeyValueChanged(String key, boolean value) {
- if (key == XWalkPreferences.REMOTE_DEBUGGING) {
+ if (key == XWalkPreferencesInternal.REMOTE_DEBUGGING) {
if (value) enableRemoteDebugging();
else disableRemoteDebugging();
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContentVideoViewClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentVideoViewClient.java
similarity index 89%
rename from runtime/android/core/src/org/xwalk/core/XWalkContentVideoViewClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentVideoViewClient.java
index c26877a918..df6aa08cf0 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContentVideoViewClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentVideoViewClient.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.content.Context;
@@ -12,14 +12,14 @@
import org.chromium.base.CommandLine;
import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.common.ContentSwitches;
-import org.xwalk.core.XWalkWebChromeClient.CustomViewCallback;
+import org.xwalk.core.internal.XWalkWebChromeClient.CustomViewCallback;
class XWalkContentVideoViewClient implements ContentVideoViewClient {
private XWalkContentsClient mContentsClient;
private Activity mActivity;
- private XWalkView mView;
+ private XWalkViewInternal mView;
- public XWalkContentVideoViewClient(XWalkContentsClient client, Activity activity, XWalkView view) {
+ public XWalkContentVideoViewClient(XWalkContentsClient client, Activity activity, XWalkViewInternal view) {
mContentsClient = client;
mActivity = activity;
mView = view;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContentsClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClient.java
similarity index 94%
rename from runtime/android/core/src/org/xwalk/core/XWalkContentsClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClient.java
index 010d609b5b..449d2b6dc1 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContentsClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClient.java
@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
@@ -60,12 +60,12 @@ public void didFailLoad(boolean isProvisionalLoad,
boolean isMainFrame, int errorCode, String description, String failingUrl) {
if (errorCode == NetError.ERR_ABORTED || !isMainFrame) {
// This error code is generated for the following reasons:
- // - XWalkView.stopLoading is called,
+ // - XWalkViewInternal.stopLoading is called,
// - the navigation is intercepted by the embedder via shouldOverrideNavigation.
//
- // The XWalkView does not notify the embedder of these situations using this
+ // The XWalkViewInternal does not notify the embedder of these situations using this
// error code with the XWalkClient.onReceivedError callback. What's more,
- // the XWalkView does not notify the embedder of sub-frame failures.
+ // the XWalkViewInternal does not notify the embedder of sub-frame failures.
return;
}
onReceivedError(ErrorCodeConversionHelper.convertErrorCode(errorCode),
@@ -109,7 +109,7 @@ final XWalkContentsClientCallbackHelper getCallbackHelper() {
}
//--------------------------------------------------------------------------------------------
- // XWalkView specific methods that map directly to XWalkViewClient / XWalkWebChromeClient
+ // XWalkViewInternal specific methods that map directly to XWalkViewClient / XWalkWebChromeClient
//--------------------------------------------------------------------------------------------
public abstract void getVisitedHistory(ValueCallback callback);
@@ -205,7 +205,7 @@ public void onShowCustomView(View view, XWalkWebChromeClient.CustomViewCallback
public abstract void didFinishLoad(String url);
//--------------------------------------------------------------------------------------------
- // Other XWalkView-specific methods
+ // Other XWalkViewInternal-specific methods
//--------------------------------------------------------------------------------------------
//
public abstract void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches,
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContentsClientBridge.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java
similarity index 94%
rename from runtime/android/core/src/org/xwalk/core/XWalkContentsClientBridge.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java
index ad3784505c..1fa02006d2 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContentsClientBridge.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java
@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.ContentResolver;
import android.content.Intent;
@@ -37,9 +37,9 @@
class XWalkContentsClientBridge extends XWalkContentsClient
implements ContentViewDownloadDelegate {
- private XWalkView mXWalkView;
- private XWalkUIClient mXWalkUIClient;
- private XWalkResourceClient mXWalkResourceClient;
+ private XWalkViewInternal mXWalkView;
+ private XWalkUIClientInternal mXWalkUIClient;
+ private XWalkResourceClientInternal mXWalkResourceClient;
private XWalkClient mXWalkClient;
private XWalkWebChromeClient mXWalkWebChromeClient;
private Bitmap mFavicon;
@@ -75,28 +75,28 @@ public boolean shouldIgnoreNavigation(NavigationParams navigationParams) {
}
}
- public XWalkContentsClientBridge(XWalkView xwView) {
+ public XWalkContentsClientBridge(XWalkViewInternal xwView) {
mXWalkView = xwView;
mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(this);
}
- public void setUIClient(XWalkUIClient client) {
+ public void setUIClient(XWalkUIClientInternal client) {
// If it's null, use Crosswalk implementation.
if (client != null) {
mXWalkUIClient = client;
return;
}
- mXWalkUIClient = new XWalkUIClient(mXWalkView);
+ mXWalkUIClient = new XWalkUIClientInternal(mXWalkView);
}
- public void setResourceClient(XWalkResourceClient client) {
+ public void setResourceClient(XWalkResourceClientInternal client) {
// If it's null, use Crosswalk implementation.
if (client != null) {
mXWalkResourceClient = client;
return;
}
- mXWalkResourceClient = new XWalkResourceClient(mXWalkView);
+ mXWalkResourceClient = new XWalkResourceClientInternal(mXWalkView);
}
@@ -510,27 +510,27 @@ private void proceedSslError(boolean proceed, int id) {
@CalledByNative
private void handleJsAlert(String url, String message, int id) {
if (isOwnerActivityRunning()) {
- XWalkJavascriptResultHandler result = new XWalkJavascriptResultHandler(this, id);
+ XWalkJavascriptResultHandlerInternal result = new XWalkJavascriptResultHandlerInternal(this, id);
mXWalkUIClient.onJavascriptModalDialog(mXWalkView,
- XWalkUIClient.JavascriptMessageType.JAVASCRIPT_ALERT, url, message, "", result);
+ XWalkUIClientInternal.JAVASCRIPT_ALERT, url, message, "", result);
}
}
@CalledByNative
private void handleJsConfirm(String url, String message, int id) {
if (isOwnerActivityRunning()) {
- XWalkJavascriptResultHandler result = new XWalkJavascriptResultHandler(this, id);
+ XWalkJavascriptResultHandlerInternal result = new XWalkJavascriptResultHandlerInternal(this, id);
mXWalkUIClient.onJavascriptModalDialog(mXWalkView,
- XWalkUIClient.JavascriptMessageType.JAVASCRIPT_CONFIRM, url, message, "", result);
+ XWalkUIClientInternal.JAVASCRIPT_CONFIRM, url, message, "", result);
}
}
@CalledByNative
private void handleJsPrompt(String url, String message, String defaultValue, int id) {
if (isOwnerActivityRunning()) {
- XWalkJavascriptResultHandler result = new XWalkJavascriptResultHandler(this, id);
+ XWalkJavascriptResultHandlerInternal result = new XWalkJavascriptResultHandlerInternal(this, id);
mXWalkUIClient.onJavascriptModalDialog(mXWalkView,
- XWalkUIClient.JavascriptMessageType.JAVASCRIPT_PROMPT, url, message, defaultValue,
+ XWalkUIClientInternal.JAVASCRIPT_PROMPT, url, message, defaultValue,
result);
}
}
@@ -538,9 +538,9 @@ private void handleJsPrompt(String url, String message, String defaultValue, int
@CalledByNative
private void handleJsBeforeUnload(String url, String message, int id) {
if (isOwnerActivityRunning()) {
- XWalkJavascriptResultHandler result = new XWalkJavascriptResultHandler(this, id);
+ XWalkJavascriptResultHandlerInternal result = new XWalkJavascriptResultHandlerInternal(this, id);
mXWalkUIClient.onJavascriptModalDialog(mXWalkView,
- XWalkUIClient.JavascriptMessageType.JAVASCRIPT_BEFOREUNLOAD, url, message, "",
+ XWalkUIClientInternal.JAVASCRIPT_BEFOREUNLOAD, url, message, "",
result);
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContentsClientCallbackHelper.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientCallbackHelper.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/XWalkContentsClientCallbackHelper.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientCallbackHelper.java
index 89b4ca4be0..d1ccaad061 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContentsClientCallbackHelper.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientCallbackHelper.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.os.Handler;
import android.os.Looper;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkContentsIoThreadClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsIoThreadClient.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkContentsIoThreadClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsIoThreadClient.java
index 17e39c577b..e2f96bb623 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkContentsIoThreadClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsIoThreadClient.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkCookieManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkCookieManager.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/XWalkCookieManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkCookieManager.java
index 6206cf0682..3748033229 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkCookieManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkCookieManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkDevToolsServer.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDevToolsServer.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkDevToolsServer.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDevToolsServer.java
index b8ae00e8f1..9947f271b1 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkDevToolsServer.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDevToolsServer.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkDownloadListenerImpl.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDownloadListenerImpl.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkDownloadListenerImpl.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDownloadListenerImpl.java
index 31580466cd..4884b83aa5 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkDownloadListenerImpl.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDownloadListenerImpl.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
@@ -22,9 +22,9 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.xwalk.core.AndroidProtocolHandler;
-import org.xwalk.core.DownloadListener;
-import org.xwalk.core.R;
+import org.xwalk.core.internal.AndroidProtocolHandler;
+import org.xwalk.core.internal.DownloadListener;
+import org.xwalk.core.internal.R;
class XWalkDownloadListenerImpl implements DownloadListener {
private static String DOWNLOAD_START_TOAST;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkGeolocationPermissions.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkGeolocationPermissions.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/XWalkGeolocationPermissions.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkGeolocationPermissions.java
index e384ba2d1a..10a9000b39 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkGeolocationPermissions.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkGeolocationPermissions.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.SharedPreferences;
import android.webkit.ValueCallback;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkHttpAuthHandler.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkHttpAuthHandler.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/XWalkHttpAuthHandler.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkHttpAuthHandler.java
index db6078dadd..f2a22e488d 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkHttpAuthHandler.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkHttpAuthHandler.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkInternalResources.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkInternalResources.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/XWalkInternalResources.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkInternalResources.java
index 7768dc85bc..b171f5308f 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkInternalResources.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkInternalResources.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.Context;
import android.util.Log;
@@ -16,7 +16,8 @@ class XWalkInternalResources {
private static boolean loaded = false;
private final static String INTERNAL_RESOURCE_CLASSES[] = {
"org.chromium.content.R",
- "org.chromium.ui.R"
+ "org.chromium.ui.R",
+ "org.xwalk.core.internal.R"
};
private final static String GENERATED_RESOURCE_CLASS = "org.xwalk.core.R";
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkJavascriptResultHandler.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultHandlerInternal.java
similarity index 67%
rename from runtime/android/core/src/org/xwalk/core/XWalkJavascriptResultHandler.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultHandlerInternal.java
index 6298262719..6ea91e9b08 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkJavascriptResultHandler.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultHandlerInternal.java
@@ -2,25 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.ThreadUtils;
-class XWalkJavascriptResultHandler implements XWalkJavascriptResult {
+@XWalkAPI(impl = XWalkJavascriptResultInternal.class, createInternally = true)
+public class XWalkJavascriptResultHandlerInternal implements XWalkJavascriptResultInternal {
private XWalkContentsClientBridge mBridge;
private final int mId;
- XWalkJavascriptResultHandler(XWalkContentsClientBridge bridge, int id) {
+ XWalkJavascriptResultHandlerInternal(XWalkContentsClientBridge bridge, int id) {
mBridge = bridge;
mId = id;
}
+ // Never use this constructor.
+ // It is only used in XWalkJavascriptResultHandlerBridge.
+ XWalkJavascriptResultHandlerInternal() {
+ mBridge = null;
+ mId = -1;
+ }
+
@Override
+ @XWalkAPI
public void confirm() {
confirmWithResult(null);
}
@Override
+ @XWalkAPI
public void confirmWithResult(final String promptResult) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
@@ -34,6 +44,7 @@ public void run() {
}
@Override
+ @XWalkAPI
public void cancel() {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkJavascriptResult.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultInternal.java
similarity index 69%
rename from runtime/android/core/src/org/xwalk/core/XWalkJavascriptResult.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultInternal.java
index fae1cb2a98..68a92c0338 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkJavascriptResult.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkJavascriptResultInternal.java
@@ -2,30 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
/**
- * This interface is used when XWalkUIClient offers a JavaScript
+ * This interface is used when XWalkUIClientInternal offers a JavaScript
* modal dialog (alert, beforeunload or confirm) to enable the client to
- * handle the dialog in their own way. XWalkUIClient will offer an object
+ * handle the dialog in their own way. XWalkUIClientInternal will offer an object
* that implements this interface to the client and when the client has handled
* the dialog, it must either callback with confirm() or cancel() to allow
* processing to continue.
*/
-public interface XWalkJavascriptResult {
+@XWalkAPI(instance = XWalkJavascriptResultHandlerInternal.class)
+public interface XWalkJavascriptResultInternal {
/**
* Handle a confirm with a result from caller.
* @param result the result string from caller.
*/
+ @XWalkAPI
public void confirmWithResult(String result);
/**
* Handle a confirm without a result.
*/
+ @XWalkAPI
public void confirm();
/**
* Handle the result if the caller cancelled the dialog.
*/
+ @XWalkAPI
public void cancel();
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkLaunchScreenManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkLaunchScreenManager.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/XWalkLaunchScreenManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkLaunchScreenManager.java
index 1f57e2c033..67f26bbf07 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkLaunchScreenManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkLaunchScreenManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import java.lang.Runnable;
import java.util.ArrayList;
@@ -58,7 +58,7 @@ public class XWalkLaunchScreenManager
private final static String BORDER_MODE_STRETCH = "stretch";
private final static String BORDER_MODE_ROUND = "round";
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
private Activity mActivity;
private Context mLibContext;
private Dialog mLaunchScreenDialog;
@@ -84,7 +84,7 @@ private enum BorderModeType {
NONE
}
- public XWalkLaunchScreenManager(Context context, XWalkView xwView) {
+ public XWalkLaunchScreenManager(Context context, XWalkViewInternal xwView) {
mXWalkView = xwView;
mLibContext = context;
mActivity = mXWalkView.getActivity();
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkMediaPlayerResourceLoadingFilter.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkMediaPlayerResourceLoadingFilter.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkMediaPlayerResourceLoadingFilter.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkMediaPlayerResourceLoadingFilter.java
index 563db0f9e1..fa4a2cef7b 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkMediaPlayerResourceLoadingFilter.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkMediaPlayerResourceLoadingFilter.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHandler.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandler.java
similarity index 93%
rename from runtime/android/core/src/org/xwalk/core/XWalkNavigationHandler.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandler.java
index 6bc8f17f60..9cfd457682 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHandler.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandler.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.components.navigation_interception.NavigationParams;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHandlerImpl.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandlerImpl.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/XWalkNavigationHandlerImpl.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandlerImpl.java
index 6258d74811..d45b07f665 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHandlerImpl.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHandlerImpl.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.content.ActivityNotFoundException;
@@ -14,7 +14,7 @@
import org.chromium.components.navigation_interception.NavigationParams;
-import org.xwalk.core.XWalkNavigationHandler;
+import org.xwalk.core.internal.XWalkNavigationHandler;
/**
* @hide
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHistory.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHistoryInternal.java
similarity index 58%
rename from runtime/android/core/src/org/xwalk/core/XWalkNavigationHistory.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHistoryInternal.java
index 88022881cd..9f6cf67b8b 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNavigationHistory.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationHistoryInternal.java
@@ -2,34 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import java.io.Serializable;
import org.chromium.content.browser.NavigationHistory;
/**
- * This class represents a navigation history for a XWalkView instance.
+ * This class represents a navigation history for a XWalkViewInternal instance.
* It's not thread-safe and should be only called on UI thread.
*/
-public final class XWalkNavigationHistory implements Cloneable, Serializable {
+@XWalkAPI(createInternally = true)
+public class XWalkNavigationHistoryInternal implements Cloneable, Serializable {
private NavigationHistory mHistory;
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
- XWalkNavigationHistory(XWalkView view, NavigationHistory history) {
+ // Never use this constructor.
+ // It is only used in XWalkNavigationHistoryBridge.
+ XWalkNavigationHistoryInternal() {
+ mXWalkView = null;
+ mHistory = null;
+ }
+
+ XWalkNavigationHistoryInternal(XWalkViewInternal view, NavigationHistory history) {
mXWalkView = view;
mHistory = history;
}
- XWalkNavigationHistory(XWalkNavigationHistory history) {
+ XWalkNavigationHistoryInternal(XWalkNavigationHistoryInternal history) {
mXWalkView = history.mXWalkView;
mHistory = history.mHistory;
}
/**
- * Total size of navigation history for the XWalkView.
+ * Total size of navigation history for the XWalkViewInternal.
* @return the size of total navigation items.
*/
+ @XWalkAPI
public int size() {
return mHistory.getEntryCount();
}
@@ -39,6 +48,7 @@ public int size() {
* @param index the given index.
* @return true if there is an item at the specific index.
*/
+ @XWalkAPI
public boolean hasItemAt(int index) {
return index >=0 && index <= size() - 1;
}
@@ -48,30 +58,34 @@ public boolean hasItemAt(int index) {
* @param index the given index.
* @return the navigation item for the given index.
*/
- public XWalkNavigationItem getItemAt(int index) {
- return new XWalkNavigationItem(mHistory.getEntryAtIndex(index));
+ @XWalkAPI
+ public XWalkNavigationItemInternal getItemAt(int index) {
+ return new XWalkNavigationItemInternal(mHistory.getEntryAtIndex(index));
}
/**
- * Get the current item which XWalkView displays.
+ * Get the current item which XWalkViewInternal displays.
* @return the current navigation item.
*/
- public XWalkNavigationItem getCurrentItem() {
+ @XWalkAPI
+ public XWalkNavigationItemInternal getCurrentItem() {
return getItemAt(getCurrentIndex());
}
/**
- * Test whether XWalkView can go back.
+ * Test whether XWalkViewInternal can go back.
* @return true if it can go back.
*/
+ @XWalkAPI
public boolean canGoBack() {
return mXWalkView.canGoBack();
}
/**
- * Test whether XWalkView can go forward.
+ * Test whether XWalkViewInternal can go forward.
* @return true if it can go forward.
*/
+ @XWalkAPI
public boolean canGoForward() {
return mXWalkView.canGoForward();
}
@@ -79,12 +93,12 @@ public boolean canGoForward() {
/**
* The direction for web page navigation.
*/
- public enum Direction {
- /** The backward direction for web page navigation. */
- BACKWARD,
- /** The forward direction for web page navigation. */
- FORWARD
- }
+ /** The backward direction for web page navigation. */
+ @XWalkAPI(isConst = true)
+ public final static int BACKWARD = 0;
+ /** The forward direction for web page navigation. */
+ @XWalkAPI(isConst = true)
+ public final static int FORWARD = 1;
/**
* Navigates to the specified step from the current navigation item.
@@ -92,7 +106,8 @@ public enum Direction {
* @param direction the direction of navigation.
* @param steps go back or foward with a given steps.
*/
- public void navigate(Direction direction, int steps) {
+ @XWalkAPI
+ public void navigate(int direction, int steps) {
switch(direction) {
case FORWARD:
mXWalkView.navigateTo(steps);
@@ -109,18 +124,20 @@ public void navigate(Direction direction, int steps) {
* Get the index for current navigation item.
* @return current index in the navigation history.
*/
+ @XWalkAPI
public int getCurrentIndex() {
return mHistory.getCurrentEntryIndex();
}
/**
- * Clear all history owned by this XWalkView.
+ * Clear all history owned by this XWalkViewInternal.
*/
+ @XWalkAPI
public void clear() {
mXWalkView.clearHistory();
}
- protected synchronized XWalkNavigationHistory clone() {
- return new XWalkNavigationHistory(this);
+ protected synchronized XWalkNavigationHistoryInternal clone() {
+ return new XWalkNavigationHistoryInternal(this);
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNavigationItem.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationItemInternal.java
similarity index 61%
rename from runtime/android/core/src/org/xwalk/core/XWalkNavigationItem.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationItemInternal.java
index a879a60a13..250a1dc354 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNavigationItem.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNavigationItemInternal.java
@@ -2,21 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.content.browser.NavigationEntry;
/**
- * This class represents a navigation item and is managed in XWalkNavigationHistory.
+ * This class represents a navigation item and is managed in XWalkNavigationHistoryInternal.
*/
-public final class XWalkNavigationItem implements Cloneable {
+@XWalkAPI(createInternally = true)
+public class XWalkNavigationItemInternal implements Cloneable {
private NavigationEntry mEntry;
- XWalkNavigationItem(NavigationEntry entry) {
+ // Never use this constructor.
+ // It is only used in XWalkNavigationItemBridge.
+ XWalkNavigationItemInternal() {
+ mEntry = null;
+ }
+
+ XWalkNavigationItemInternal(NavigationEntry entry) {
mEntry = entry;
}
- XWalkNavigationItem(XWalkNavigationItem item) {
+ XWalkNavigationItemInternal(XWalkNavigationItemInternal item) {
mEntry = item.mEntry;
}
@@ -24,6 +31,7 @@ public final class XWalkNavigationItem implements Cloneable {
* Get the url of current navigation item.
* @return the string of the url.
*/
+ @XWalkAPI
public String getUrl() {
return mEntry.getUrl();
}
@@ -32,6 +40,7 @@ public String getUrl() {
* Get the original url of current navigation item.
* @return the string of the original url.
*/
+ @XWalkAPI
public String getOriginalUrl() {
return mEntry.getOriginalUrl();
}
@@ -40,11 +49,12 @@ public String getOriginalUrl() {
* Get the title of current navigation item.
* @return the string of the title.
*/
+ @XWalkAPI
public String getTitle() {
return mEntry.getTitle();
}
- protected synchronized XWalkNavigationItem clone() {
- return new XWalkNavigationItem(this);
+ protected synchronized XWalkNavigationItemInternal clone() {
+ return new XWalkNavigationItemInternal(this);
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNotificationService.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationService.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/XWalkNotificationService.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationService.java
index bd06aad61c..466cebd716 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNotificationService.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationService.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.Intent;
import android.graphics.Bitmap;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkNotificationServiceImpl.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationServiceImpl.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkNotificationServiceImpl.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationServiceImpl.java
index e860f0c36f..da99005b07 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkNotificationServiceImpl.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkNotificationServiceImpl.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import java.util.HashMap;
@@ -19,9 +19,9 @@
import android.util.AndroidRuntimeException;
import android.util.Log;
-import org.xwalk.core.XWalkContentsClientBridge;
-import org.xwalk.core.XWalkNotificationService;
-import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkContentsClientBridge;
+import org.xwalk.core.internal.XWalkNotificationService;
+import org.xwalk.core.internal.XWalkViewInternal;
/**
* @hide
@@ -37,13 +37,13 @@ public class XWalkNotificationServiceImpl implements XWalkNotificationService {
private Context mContext;
private XWalkContentsClientBridge mBridge;
- private XWalkView mView;
+ private XWalkViewInternal mView;
private NotificationManager mNotificationManager;
private BroadcastReceiver mNotificationCloseReceiver;
private IntentFilter mNotificationCloseIntentFilter;
private HashMap mExistNotificationIds;
- public XWalkNotificationServiceImpl(Context context, XWalkView view) {
+ public XWalkNotificationServiceImpl(Context context, XWalkViewInternal view) {
mContext = context;
mView = view;
mNotificationManager =
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkPreferences.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkPreferencesInternal.java
similarity index 92%
rename from runtime/android/core/src/org/xwalk/core/XWalkPreferences.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkPreferencesInternal.java
index 6605711dfb..9e0418b148 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkPreferences.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkPreferencesInternal.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
@@ -14,9 +14,10 @@
* This class represents the preferences and could be set by callers.
* It is not thread-safe and must be called on the UI thread.
* Afterwards, the preference could be read from all threads and can impact
- * all XWalkView instances.
+ * all XWalkViewInternal instances.
*/
-public final class XWalkPreferences {
+@XWalkAPI(noInstance = true)
+public class XWalkPreferencesInternal {
private static HashMap sPrefMap = new HashMap();
// Here we use WeakReference to make sure the KeyValueChangeListener instance
// can be GC-ed to avoid memory leaking issue.
@@ -28,15 +29,16 @@ public final class XWalkPreferences {
/**
* The key string to enable/disable remote debugging.
*/
+ @XWalkAPI
public static final String REMOTE_DEBUGGING = "remote-debugging";
/**
- * The key string to enable/disable animatable XWalkView. Default value is
+ * The key string to enable/disable animatable XWalkViewInternal. Default value is
* false.
*
- * If this key is set to True, the XWalkView created by Crosswalk can be
+ * If this key is set to True, the XWalkViewInternal created by Crosswalk can be
* transformed and animated. Internally, Crosswalk is alternatively using
- * TextureView as the backend of XWalkView.
+ * TextureView as the backend of XWalkViewInternal.
*
*
* TextureView is a kind of
@@ -44,12 +46,12 @@ public final class XWalkPreferences {
* android.view.View that is different from
*
* SurfaceView. Unlike SurfaceView, it can be resized, transformed and
- * animated. Once this key is set to True, all XWalkView will use TextureView
+ * animated. Once this key is set to True, all XWalkViewInternal will use TextureView
* as the rendering target instead of SurfaceView. The downside of TextureView
* is, it would consume more graphics memory than SurfaceView and may have
* 1~3 extra frames of latency to display updates.
*
- * Note this key MUST be set before creating the first XWalkView, otherwise
+ * Note this key MUST be set before creating the first XWalkViewInternal, otherwise
* a RuntimeException will be thrown.
*/
public static final String ANIMATABLE_XWALK_VIEW = "animatable-xwalk-view";
@@ -65,6 +67,7 @@ public final class XWalkPreferences {
* @param key the string name of the key.
* @param enabled true if setting it as enabled.
*/
+ @XWalkAPI
public static synchronized void setValue(String key, boolean enabled) throws RuntimeException {
checkKey(key);
// If the listener list is not empty, we consider the preference is
@@ -85,6 +88,7 @@ public static synchronized void setValue(String key, boolean enabled) throws Run
* @param key the string name of the key.
* @return true if it's enabled.
*/
+ @XWalkAPI
public static synchronized boolean getValue(String key) throws RuntimeException {
checkKey(key);
return sPrefMap.get(key);
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkResourceClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkResourceClientInternal.java
similarity index 71%
rename from runtime/android/core/src/org/xwalk/core/XWalkResourceClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkResourceClientInternal.java
index 63fa3a7cf6..8d58f83042 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkResourceClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkResourceClientInternal.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.AlertDialog;
import android.content.Context;
@@ -13,100 +13,123 @@
/**
* This class notifies the embedder resource events/callbacks.
*/
-public class XWalkResourceClient {
+@XWalkAPI(createExternally = true)
+public class XWalkResourceClientInternal {
/** Success */
+ @XWalkAPI
public static final int ERROR_OK = 0;
/** Generic error */
+ @XWalkAPI
public static final int ERROR_UNKNOWN = -1;
/** Server or proxy hostname lookup failed */
+ @XWalkAPI
public static final int ERROR_HOST_LOOKUP = -2;
/** Unsupported authentication scheme (not basic or digest) */
+ @XWalkAPI
public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
/** User authentication failed on server */
+ @XWalkAPI
public static final int ERROR_AUTHENTICATION = -4;
/** User authentication failed on proxy */
+ @XWalkAPI
public static final int ERROR_PROXY_AUTHENTICATION = -5;
/** Failed to connect to the server */
+ @XWalkAPI
public static final int ERROR_CONNECT = -6;
/** Failed to read or write to the server */
+ @XWalkAPI
public static final int ERROR_IO = -7;
/** Connection timed out */
+ @XWalkAPI
public static final int ERROR_TIMEOUT = -8;
/** Too many redirects */
+ @XWalkAPI
public static final int ERROR_REDIRECT_LOOP = -9;
/** Unsupported URI scheme */
+ @XWalkAPI
public static final int ERROR_UNSUPPORTED_SCHEME = -10;
/** Failed to perform SSL handshake */
+ @XWalkAPI
public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
/** Malformed URL */
+ @XWalkAPI
public static final int ERROR_BAD_URL = -12;
/** Generic file error */
+ @XWalkAPI
public static final int ERROR_FILE = -13;
/** File not found */
+ @XWalkAPI
public static final int ERROR_FILE_NOT_FOUND = -14;
/** Too many requests during this load */
+ @XWalkAPI
public static final int ERROR_TOO_MANY_REQUESTS = -15;
/**
* Constructor.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
*/
- public XWalkResourceClient(XWalkView view) {
+ @XWalkAPI
+ public XWalkResourceClientInternal(XWalkViewInternal view) {
// Keep the above parameter for future use.
}
/**
- * Notify the client that the XWalkView will load the resource specified
+ * Notify the client that the XWalkViewInternal will load the resource specified
* by the given url.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param url the url for the resource to be loaded.
*/
- public void onLoadStarted(XWalkView view, String url) {
+ @XWalkAPI
+ public void onLoadStarted(XWalkViewInternal view, String url) {
}
/**
- * Notify the client that the XWalkView completes to load the resource
+ * Notify the client that the XWalkViewInternal completes to load the resource
* specified by the given url.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param url the url for the resource done for loading.
*/
- public void onLoadFinished(XWalkView view, String url) {
+ @XWalkAPI
+ public void onLoadFinished(XWalkViewInternal view, String url) {
}
/**
* Notify the client the progress info of loading a specific url.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param progressInPercent the loading process in percent.
*/
- public void onProgressChanged(XWalkView view, int progressInPercent) {
+ @XWalkAPI
+ public void onProgressChanged(XWalkViewInternal view, int progressInPercent) {
}
/**
* Notify the client of a resource request and allow the client to return
- * the data. If the return value is null, the XWalkView
+ * the data. If the return value is null, the XWalkViewInternal
* will continue to load the resource as usual. Otherwise, the return
* response and data will be used. NOTE: This method is called by the
* network thread so clients should exercise caution when accessing private
* data.
- * @param view The {@link org.xwalk.core.XWalkView} that is requesting the
+ * @param view The {@link org.xwalk.core.internal.XWalkViewInternal} that is requesting the
* resource.
* @param url The raw url of the resource.
* @return A {@link android.webkit.WebResourceResponse} containing the
- * response information or null if the XWalkView should load the
+ * response information or null if the XWalkViewInternal should load the
* resource itself.
*/
- public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
+ @XWalkAPI
+ public WebResourceResponse shouldInterceptLoadRequest(XWalkViewInternal view, String url) {
return null;
}
/**
* Report an error to the client.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param errorCode the error id.
* @param description A String describing the error.
* @param failingUrl The url that failed to load.
*/
- public void onReceivedLoadError(XWalkView view, int errorCode, String description,
+ @XWalkAPI
+ public void onReceivedLoadError(XWalkViewInternal view, int errorCode, String description,
String failingUrl) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(view.getContext());
dialogBuilder.setTitle(android.R.string.dialog_alert_title)
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkSettings.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkSettings.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/XWalkSettings.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkSettings.java
index a77515f52c..62f92aa3c7 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkSettings.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkSettings.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.content.Context;
import android.content.pm.PackageManager;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkUIClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkUIClientInternal.java
similarity index 79%
rename from runtime/android/core/src/org/xwalk/core/XWalkUIClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkUIClientInternal.java
index 58d445329d..56e750c51a 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkUIClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkUIClientInternal.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.app.AlertDialog;
@@ -20,7 +20,8 @@
/**
* This class notifies the embedder UI events/callbacks.
*/
-public class XWalkUIClient {
+@XWalkAPI(createExternally = true)
+public class XWalkUIClientInternal {
// Strings for displaying Dialog.
private static String mJSAlertTitle;
@@ -34,14 +35,15 @@ public class XWalkUIClient {
private EditText mPromptText;
private int mSystemUiFlag;
private View mDecorView;
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
private boolean mOriginalFullscreen;
/**
* Constructor.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
*/
- public XWalkUIClient(XWalkView view) {
+ @XWalkAPI
+ public XWalkUIClientInternal(XWalkViewInternal view) {
mContext = view.getContext();
mDecorView = view.getActivity().getWindow().getDecorView();
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
@@ -63,17 +65,19 @@ private void initResources() {
}
/**
- * Request display and focus for this XWalkView.
- * @param view the owner XWalkView instance.
+ * Request display and focus for this XWalkViewInternal.
+ * @param view the owner XWalkViewInternal instance.
*/
- public void onRequestFocus(XWalkView view) {
+ @XWalkAPI
+ public void onRequestFocus(XWalkViewInternal view) {
}
/**
- * Notify the client to close the given XWalkView.
- * @param view the owner XWalkView instance.
+ * Notify the client to close the given XWalkViewInternal.
+ * @param view the owner XWalkViewInternal instance.
*/
- public void onJavascriptCloseWindow(XWalkView view) {
+ @XWalkAPI
+ public void onJavascriptCloseWindow(XWalkViewInternal view) {
if (view != null && view.getActivity() != null) {
view.getActivity().finish();
}
@@ -82,28 +86,31 @@ public void onJavascriptCloseWindow(XWalkView view) {
/**
* The type of JavaScript modal dialog.
*/
- public enum JavascriptMessageType {
- /** JavaScript alert dialog. */
- JAVASCRIPT_ALERT,
- /** JavaScript confirm dialog. */
- JAVASCRIPT_CONFIRM,
- /** JavaScript prompt dialog. */
- JAVASCRIPT_PROMPT,
- /** JavaScript dialog for a window-before-unload notification. */
- JAVASCRIPT_BEFOREUNLOAD
- }
+ /** JavaScript alert dialog. */
+ @XWalkAPI
+ public static final int JAVASCRIPT_ALERT = 0;
+ /** JavaScript confirm dialog. */
+ @XWalkAPI
+ public static final int JAVASCRIPT_CONFIRM = 1;
+ /** JavaScript prompt dialog. */
+ @XWalkAPI
+ public static final int JAVASCRIPT_PROMPT = 2;
+ /** JavaScript dialog for a window-before-unload notification. */
+ @XWalkAPI
+ public static final int JAVASCRIPT_BEFOREUNLOAD = 3;
/**
* Tell the client to display a prompt dialog to the user.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param type the type of JavaScript modal dialog.
* @param url the url of the web page which wants to show this dialog.
* @param message the message to be shown.
* @param defaultValue the default value string. Only valid for Prompt dialog.
* @param result the callback to handle the result from caller.
*/
- public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type, String url,
- String message, String defaultValue, XWalkJavascriptResult result) {
+ @XWalkAPI
+ public boolean onJavascriptModalDialog(XWalkViewInternal view, int type, String url,
+ String message, String defaultValue, XWalkJavascriptResultInternal result) {
switch(type) {
case JAVASCRIPT_ALERT:
return onJsAlert(view, url, message, result);
@@ -123,10 +130,11 @@ public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType typ
/**
* Tell the client to toggle fullscreen mode.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param enterFullscreen true if it has entered fullscreen mode.
*/
- public void onFullscreenToggled(XWalkView view, boolean enterFullscreen) {
+ @XWalkAPI
+ public void onFullscreenToggled(XWalkViewInternal view, boolean enterFullscreen) {
Activity activity = view.getActivity();
if (enterFullscreen) {
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
@@ -165,7 +173,7 @@ public void onFullscreenToggled(XWalkView view, boolean enterFullscreen) {
/**
* Tell the client to open a file chooser.
- * @param view the owner XWalkView instance.
+ * @param view the owner XWalkViewInternal instance.
* @param uploadFile the callback class to handle the result from caller. It MUST
* be invoked in all cases. Leave it not invoked will block all following
* requests to open file chooser.
@@ -174,23 +182,25 @@ public void onFullscreenToggled(XWalkView view, boolean enterFullscreen) {
* @param capture value of the 'capture' attribute of the input tag associated
* with this file picker
*/
- public void openFileChooser(XWalkView view, ValueCallback uploadFile,
+ @XWalkAPI
+ public void openFileChooser(XWalkViewInternal view, ValueCallback uploadFile,
String acceptType, String capture) {
uploadFile.onReceiveValue(null);
}
/**
- * Notify the client that the scale applied to the XWalkView has changed.
- * @param view the owner XWalkView instance.
+ * Notify the client that the scale applied to the XWalkViewInternal has changed.
+ * @param view the owner XWalkViewInternal instance.
* @param oldScale the old scale before scaling.
* @param newScale the current scale factor after scaling.
*/
- public void onScaleChanged(XWalkView view, float oldScale, float newScale) {
+ @XWalkAPI
+ public void onScaleChanged(XWalkViewInternal view, float oldScale, float newScale) {
}
- private boolean onJsAlert(XWalkView view, String url, String message,
- XWalkJavascriptResult result) {
- final XWalkJavascriptResult fResult = result;
+ private boolean onJsAlert(XWalkViewInternal view, String url, String message,
+ XWalkJavascriptResultInternal result) {
+ final XWalkJavascriptResultInternal fResult = result;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
dialogBuilder.setTitle(mJSAlertTitle)
.setMessage(message)
@@ -213,9 +223,9 @@ public void onCancel(DialogInterface dialog) {
return false;
}
- private boolean onJsConfirm(XWalkView view, String url, String message,
- XWalkJavascriptResult result) {
- final XWalkJavascriptResult fResult = result;
+ private boolean onJsConfirm(XWalkViewInternal view, String url, String message,
+ XWalkJavascriptResultInternal result) {
+ final XWalkJavascriptResultInternal fResult = result;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
dialogBuilder.setTitle(mJSConfirmTitle)
.setMessage(message)
@@ -247,9 +257,9 @@ public void onCancel(DialogInterface dialog) {
return false;
}
- private boolean onJsPrompt(XWalkView view, String url, String message,
- String defaultValue, XWalkJavascriptResult result) {
- final XWalkJavascriptResult fResult = result;
+ private boolean onJsPrompt(XWalkViewInternal view, String url, String message,
+ String defaultValue, XWalkJavascriptResultInternal result) {
+ final XWalkJavascriptResultInternal fResult = result;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
dialogBuilder.setTitle(mJSPromptTitle)
.setMessage(message)
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkViewDelegate.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewDelegate.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/XWalkViewDelegate.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewDelegate.java
index 2f44fe9209..c5c95236cd 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkViewDelegate.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewDelegate.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -77,7 +77,7 @@ private static String[] readCommandLine(Context context) {
}
}
- public static void init(XWalkView xwalkView) throws UnsatisfiedLinkError {
+ public static void init(XWalkViewInternal xwalkView) throws UnsatisfiedLinkError {
if (sInitialized) {
return;
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkView.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewInternal.java
similarity index 85%
rename from runtime/android/core/src/org/xwalk/core/XWalkView.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewInternal.java
index c46ff7865e..73865cdcb6 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkView.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewInternal.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.app.AlertDialog;
@@ -26,21 +26,21 @@
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
-import org.xwalk.core.extension.XWalkExtensionManager;
+import org.xwalk.core.internal.extension.XWalkExtensionManager;
/**
- * XWalkView represents an Android view for web apps/pages. Thus most of attributes
+ *
XWalkViewInternal represents an Android view for web apps/pages. Thus most of attributes
* for Android view are valid for this class. Since it internally uses
*
* android.view.SurfaceView for rendering web pages by default, it can't be resized,
* rotated, transformed and animated due to the limitations of SurfaceView.
- * Alternatively, if the preference key {@link XWalkPreferences#ANIMATABLE_XWALK_VIEW}
- * is set to True, XWalkView can be transformed and animated because
+ * Alternatively, if the preference key {@link XWalkPreferencesInternal#ANIMATABLE_XWALK_VIEW}
+ * is set to True, XWalkViewInternal can be transformed and animated because
*
* TextureView is intentionally used to render web pages for animation support.
- * Besides, XWalkView won't be rendered if it's invisible.
+ * Besides, XWalkViewInternal won't be rendered if it's invisible.
*
- * XWalkView needs hardware acceleration to render web pages. As a result, the
+ *
XWalkViewInternal needs hardware acceleration to render web pages. As a result, the
* AndroidManifest.xml of the caller's app must be appended with the attribute
* "android:hardwareAccelerated" and its value must be set as "true".
*
@@ -48,8 +48,8 @@
* android:hardwareAccelerated="true">
*
*
- * Crosswalk provides 2 major callback classes, namely {@link XWalkResourceClient} and
- * {@link XWalkUIClient} for listening to the events related to resource loading and UI.
+ *
Crosswalk provides 2 major callback classes, namely {@link XWalkResourceClientInternal} and
+ * {@link XWalkUIClientInternal} for listening to the events related to resource loading and UI.
* By default, Crosswalk has a default implementation. Callers can override them if needed.
*
* Unlike other Android views, this class has to listen to system events like application life
@@ -60,32 +60,32 @@
* import android.app.Activity;
* import android.os.Bundle;
*
- * import org.xwalk.core.XWalkResourceClient;
- * import org.xwalk.core.XWalkUIClient;
- * import org.xwalk.core.XWalkView;
+ * import org.xwalk.core.internal.XWalkResourceClientInternal;
+ * import org.xwalk.core.internal.XWalkUIClientInternal;
+ * import org.xwalk.core.internal.XWalkViewInternal;
*
* public class MyActivity extends Activity {
- * XWalkView mXwalkView;
+ * XWalkViewInternal mXwalkView;
*
- * class MyResourceClient extends XWalkResourceClient {
- * MyResourceClient(XWalkView view) {
+ * class MyResourceClient extends XWalkResourceClientInternal {
+ * MyResourceClient(XWalkViewInternal view) {
* super(view);
* }
*
* @Override
- * WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
+ * WebResourceResponse shouldInterceptLoadRequest(XWalkViewInternal view, String url) {
* // Handle it here.
* ...
* }
* }
*
- * class MyUIClient extends XWalkUIClient {
- * MyUIClient(XWalkView view) {
+ * class MyUIClient extends XWalkUIClientInternal {
+ * MyUIClient(XWalkViewInternal view) {
* super(view);
* }
*
* @Override
- * void onFullscreenToggled(XWalkView view, String url) {
+ * void onFullscreenToggled(XWalkViewInternal view, String url) {
* // Handle it here.
* ...
* }
@@ -93,7 +93,7 @@
*
* @Override
* protected void onCreate(Bundle savedInstanceState) {
- * mXwalkView = new XWalkView(this, null);
+ * mXwalkView = new XWalkViewInternal(this, null);
* setContentView(mXwalkView);
* mXwalkView.setResourceClient(new MyResourceClient(mXwalkView));
* mXwalkView.setUIClient(new MyUIClient(mXwalkView));
@@ -142,7 +142,8 @@
* }
*
*/
-public class XWalkView extends android.widget.FrameLayout {
+@XWalkAPI(extendClass = FrameLayout.class, createExternally = true)
+public class XWalkViewInternal extends android.widget.FrameLayout {
static final String PLAYSTORE_DETAIL_URI = "market://details?id=";
@@ -153,8 +154,10 @@ public class XWalkView extends android.widget.FrameLayout {
private boolean mIsHidden;
/** Normal reload mode as default. */
+ @XWalkAPI
public static final int RELOAD_NORMAL = 0;
/** Reload mode with bypassing the cache. */
+ @XWalkAPI
public static final int RELOAD_IGNORE_CACHE = 1;
/**
@@ -162,7 +165,12 @@ public class XWalkView extends android.widget.FrameLayout {
* @param context a Context object used to access application assets.
* @param attrs an AttributeSet passed to our parent.
*/
- public XWalkView(Context context, AttributeSet attrs) {
+ @XWalkAPI(preWrapperLines = {"super(%1, %2);"},
+ postWrapperLines = {
+ "addView((FrameLayout)bridge, new FrameLayout.LayoutParams(",
+ " FrameLayout.LayoutParams.MATCH_PARENT,",
+ " FrameLayout.LayoutParams.MATCH_PARENT));"})
+ public XWalkViewInternal(Context context, AttributeSet attrs) {
super(context, attrs);
checkThreadSafety();
@@ -174,9 +182,14 @@ public XWalkView(Context context, AttributeSet attrs) {
* Constructor for Crosswalk runtime. In shared mode, context isi
* different from activity. In embedded mode, they're same.
* @param context a Context object used to access application assets
- * @param activity the activity for this XWalkView.
- */
- public XWalkView(Context context, Activity activity) {
+ * @param activity the activity for this XWalkViewInternal.
+ */
+ @XWalkAPI(preWrapperLines = {"super(%1, null);"},
+ postWrapperLines = {
+ "addView((FrameLayout)bridge, new FrameLayout.LayoutParams(",
+ " FrameLayout.LayoutParams.MATCH_PARENT,",
+ " FrameLayout.LayoutParams.MATCH_PARENT));"})
+ public XWalkViewInternal(Context context, Activity activity) {
super(context, null);
checkThreadSafety();
@@ -300,8 +313,8 @@ private void initXWalkContent(Context context, AttributeSet attrs) {
// Set with internal implementation. Could be overwritten by embedders'
// setting.
- setUIClient(new XWalkUIClient(this));
- setResourceClient(new XWalkResourceClient(this));
+ setUIClient(new XWalkUIClientInternal(this));
+ setResourceClient(new XWalkResourceClientInternal(this));
setDownloadListener(new XWalkDownloadListenerImpl(context));
setNavigationHandler(new XWalkNavigationHandlerImpl(context));
@@ -319,7 +332,7 @@ private void initXWalkContent(Context context, AttributeSet attrs) {
* will do nothing.
* If content is not null, load the web page/app from the content.
* If content is not null and the url is not set, return "about:blank" ifi
- * calling {@link XWalkView#getUrl()}.
+ * calling {@link XWalkViewInternal#getUrl()}.
* If content is null, try to load the content from the url.
*
* It supports URL schemes like 'http:', 'https:' and 'file:'.
@@ -327,6 +340,7 @@ private void initXWalkContent(Context context, AttributeSet attrs) {
* @param url the url for web page/app.
* @param content the content for the web page/app. Could be empty.
*/
+ @XWalkAPI
public void load(String url, String content) {
if (mContent == null) return;
checkThreadSafety();
@@ -344,6 +358,7 @@ public void load(String url, String content) {
* @param url the url for manifest.json.
* @param content the content for manifest.json.
*/
+ @XWalkAPI
public void loadAppFromManifest(String url, String content) {
if (mContent == null) return;
checkThreadSafety();
@@ -354,6 +369,7 @@ public void loadAppFromManifest(String url, String content) {
* Reload a web app with a given mode.
* @param mode the reload mode.
*/
+ @XWalkAPI
public void reload(int mode) {
if (mContent == null) return;
checkThreadSafety();
@@ -363,6 +379,7 @@ public void reload(int mode) {
/**
* Stop current loading progress.
*/
+ @XWalkAPI
public void stopLoading() {
if (mContent == null) return;
checkThreadSafety();
@@ -374,6 +391,7 @@ public void stopLoading() {
* by caller.
* @return the url for current web page/app.
*/
+ @XWalkAPI
public String getUrl() {
if (mContent == null) return null;
checkThreadSafety();
@@ -385,6 +403,7 @@ public String getUrl() {
* by caller.
* @return the title for current web page/app.
*/
+ @XWalkAPI
public String getTitle() {
if (mContent == null) return null;
checkThreadSafety();
@@ -395,6 +414,7 @@ public String getTitle() {
* Get the original url specified by caller.
* @return the original url.
*/
+ @XWalkAPI
public String getOriginalUrl() {
if (mContent == null) return null;
checkThreadSafety();
@@ -402,23 +422,25 @@ public String getOriginalUrl() {
}
/**
- * Get the navigation history for current XWalkView. It's synchronized with
- * this XWalkView if any backward/forward and navigation operations.
+ * Get the navigation history for current XWalkViewInternal. It's synchronized with
+ * this XWalkViewInternal if any backward/forward and navigation operations.
* @return the navigation history.
*/
- public XWalkNavigationHistory getNavigationHistory() {
+ @XWalkAPI
+ public XWalkNavigationHistoryInternal getNavigationHistory() {
if (mContent == null) return null;
checkThreadSafety();
return mContent.getNavigationHistory();
}
/**
- * Injects the supplied Java object into this XWalkView.
+ * Injects the supplied Java object into this XWalkViewInternal.
* Each method defined in the class of the object should be
* marked with {@link JavascriptInterface} if it's called by JavaScript.
* @param object the supplied Java object, called by JavaScript.
* @param name the name injected in JavaScript.
*/
+ @XWalkAPI
public void addJavascriptInterface(Object object, String name) {
if (mContent == null) return;
checkThreadSafety();
@@ -430,6 +452,7 @@ public void addJavascriptInterface(Object object, String name) {
* @param script the JavaScript string.
* @param callback the callback to handle the evaluated result.
*/
+ @XWalkAPI
public void evaluateJavascript(String script, ValueCallback callback) {
if (mContent == null) return;
checkThreadSafety();
@@ -441,6 +464,7 @@ public void evaluateJavascript(String script, ValueCallback callback) {
* will clear the cache for all XWalkViews used.
* @param includeDiskFiles indicate whether to clear disk files for cache.
*/
+ @XWalkAPI
public void clearCache(boolean includeDiskFiles) {
if (mContent == null) return;
checkThreadSafety();
@@ -451,6 +475,7 @@ public void clearCache(boolean includeDiskFiles) {
* Indicate that a HTML element is occupying the whole screen.
* @return true if any HTML element is occupying the whole screen.
*/
+ @XWalkAPI
public boolean hasEnteredFullscreen() {
if (mContent == null) return false;
checkThreadSafety();
@@ -461,6 +486,7 @@ public boolean hasEnteredFullscreen() {
* Leave fullscreen mode if it's. Do nothing if it's not
* in fullscreen.
*/
+ @XWalkAPI
public void leaveFullscreen() {
if (mContent == null) return;
checkThreadSafety();
@@ -468,14 +494,15 @@ public void leaveFullscreen() {
}
/**
- * Pause all layout, parsing and JavaScript timers for all XWalkView instances.
+ * Pause all layout, parsing and JavaScript timers for all XWalkViewInternal instances.
* Typically it should be called when the activity for this view is paused,
* and accordingly {@link #resumeTimers} should be called when the activity
* is resumed again.
*
- * Note that it will globally impact all XWalkView instances, not limited to
- * just this XWalkView.
+ * Note that it will globally impact all XWalkViewInternal instances, not limited to
+ * just this XWalkViewInternal.
*/
+ @XWalkAPI
public void pauseTimers() {
if (mContent == null) return;
checkThreadSafety();
@@ -483,12 +510,13 @@ public void pauseTimers() {
}
/**
- * Resume all layout, parsing and JavaScript timers for all XWalkView instances.
+ * Resume all layout, parsing and JavaScript timers for all XWalkViewInternal instances.
* Typically it should be called when the activity for this view is resumed.
*
- * Note that it will globally impact all XWalkView instances, not limited to
- * just this XWalkView.
+ * Note that it will globally impact all XWalkViewInternal instances, not limited to
+ * just this XWalkViewInternal.
*/
+ @XWalkAPI
public void resumeTimers() {
if (mContent == null) return;
checkThreadSafety();
@@ -501,6 +529,7 @@ public void resumeTimers() {
* JavaScript timers.
* Typically it should be called when the activity for this view is paused.
*/
+ @XWalkAPI
public void onHide() {
if (mContent == null || mIsHidden) return;
mExtensionManager.onPause();
@@ -513,6 +542,7 @@ public void onHide() {
* this during resuming this activity if they call onHide.
* Typically it should be called when the activity for this view is resumed.
*/
+ @XWalkAPI
public void onShow() {
if (mContent == null || !mIsHidden ) return;
mExtensionManager.onResume();
@@ -521,14 +551,15 @@ public void onShow() {
}
/**
- * Release internal resources occupied by this XWalkView.
+ * Release internal resources occupied by this XWalkViewInternal.
*/
+ @XWalkAPI
public void onDestroy() {
destroy();
}
/**
- * Pass through activity result to XWalkView. Many internal facilities need this
+ * Pass through activity result to XWalkViewInternal. Many internal facilities need this
* to handle activity result like JavaScript dialog, Crosswalk extensions, etc.
* See
* android.app.Activity.onActivityResult().
@@ -536,6 +567,7 @@ public void onDestroy() {
* @param resultCode passed from android.app.Activity.onActivityResult().
* @param data passed from android.app.Activity.onActivityResult().
*/
+ @XWalkAPI
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mContent == null) return;
mExtensionManager.onActivityResult(requestCode, resultCode, data);
@@ -543,22 +575,24 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
/**
- * Pass through intents to XWalkView. Many internal facilities need this
+ * Pass through intents to XWalkViewInternal. Many internal facilities need this
* to receive the intents like web notification. See
*
* android.app.Activity.onNewIntent().
* @param intent passed from android.app.Activity.onNewIntent().
*/
+ @XWalkAPI
public boolean onNewIntent(Intent intent) {
if (mContent == null) return false;
return mContent.onNewIntent(intent);
}
/**
- * Save current internal state of this XWalkView. This can help restore this state
+ * Save current internal state of this XWalkViewInternal. This can help restore this state
* afterwards restoring.
* @param outState the saved state for restoring.
*/
+ @XWalkAPI
public boolean saveState(Bundle outState) {
if (mContent == null) return false;
mContent.saveState(outState);
@@ -570,6 +604,7 @@ public boolean saveState(Bundle outState) {
* @param inState the state saved from saveState().
* @return true if it can restore the state.
*/
+ @XWalkAPI
public boolean restoreState(Bundle inState) {
if (mContent == null) return false;
if (mContent.restoreState(inState) != null) return true;
@@ -581,6 +616,7 @@ public boolean restoreState(Bundle inState) {
* @return the string of API level.
*/
// TODO(yongsheng): make it static?
+ @XWalkAPI
public String getAPIVersion() {
return "2.0";
}
@@ -590,6 +626,7 @@ public String getAPIVersion() {
* @return the string of Crosswalk.
*/
// TODO(yongsheng): make it static?
+ @XWalkAPI
public String getXWalkVersion() {
if (mContent == null) return null;
return mContent.getXWalkVersion();
@@ -598,9 +635,10 @@ public String getXWalkVersion() {
/**
* Embedders use this to customize their handlers to events/callbacks related
* to UI.
- * @param client the XWalkUIClient defined by callers.
+ * @param client the XWalkUIClientInternal defined by callers.
*/
- public void setUIClient(XWalkUIClient client) {
+ @XWalkAPI
+ public void setUIClient(XWalkUIClientInternal client) {
if (mContent == null) return;
checkThreadSafety();
mContent.setUIClient(client);
@@ -609,9 +647,10 @@ public void setUIClient(XWalkUIClient client) {
/**
* Embedders use this to customize their handlers to events/callbacks related
* to resource loading.
- * @param client the XWalkResourceClient defined by callers.
+ * @param client the XWalkResourceClientInternal defined by callers.
*/
- public void setResourceClient(XWalkResourceClient client) {
+ @XWalkAPI
+ public void setResourceClient(XWalkResourceClientInternal client) {
if (mContent == null) return;
checkThreadSafety();
mContent.setResourceClient(client);
@@ -624,6 +663,7 @@ public void setResourceClient(XWalkResourceClient client) {
* @param keyCode passed from android.view.View.onKeyUp().
* @param event passed from android.view.View.onKeyUp().
*/
+ @XWalkAPI
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
@@ -667,10 +707,11 @@ public void setNetworkAvailable(boolean networkUp) {
* Enables remote debugging and returns the URL at which the dev tools server is listening
* for commands. The allowedUid argument can be used to specify the uid of the process that is
* permitted to connect.
- * TODO(yongsheng): how to enable this in XWalkPreferences?
+ * TODO(yongsheng): how to enable this in XWalkPreferencesInternal?
*
* @hide
*/
+ @XWalkAPI
public String enableRemoteDebugging(int allowedUid) {
if (mContent == null) return null;
checkThreadSafety();
@@ -738,9 +779,9 @@ void disableRemoteDebugging() {
private static void checkThreadSafety() {
if (Looper.myLooper() != Looper.getMainLooper()) {
Throwable throwable = new Throwable(
- "Warning: A XWalkView method was called on thread '" +
+ "Warning: A XWalkViewInternal method was called on thread '" +
Thread.currentThread().getName() + "'. " +
- "All XWalkView methods must be called on the UI thread. ");
+ "All XWalkViewInternal methods must be called on the UI thread. ");
throw new RuntimeException(throwable);
}
}
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkWebChromeClient.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebChromeClient.java
similarity index 90%
rename from runtime/android/core/src/org/xwalk/core/XWalkWebChromeClient.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebChromeClient.java
index 6fabedee4d..85ba8d9de2 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkWebChromeClient.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebChromeClient.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.app.Activity;
import android.content.Context;
@@ -33,19 +33,19 @@
/**
* It's an internal legacy class which is to handle kinds of ui related
* callback functions. It only handles those which are not exposed to
- * external users compared to XWalkUIClient.
+ * external users compared to XWalkUIClientInternal.
*
* @hide
*/
public class XWalkWebChromeClient {
private Context mContext;
private View mCustomXWalkView;
- private XWalkView mXWalkView;
+ private XWalkViewInternal mXWalkView;
private XWalkWebChromeClient.CustomViewCallback mCustomViewCallback;
private XWalkContentsClient mContentsClient = null;
private long XWALK_MAX_QUOTA = 1024 * 1024 * 100;
- public XWalkWebChromeClient(XWalkView view) {
+ public XWalkWebChromeClient(XWalkViewInternal view) {
mContext = view.getContext();
mXWalkView = view;
}
@@ -56,25 +56,25 @@ void setContentsClient(XWalkContentsClient client) {
/**
* Notify the host application of a change in the document title.
- * @param view The XWalkView that initiated the callback.
+ * @param view The XWalkViewInternal that initiated the callback.
* @param title A String containing the new title of the document.
*/
- public void onReceivedTitle(XWalkView view, String title) {}
+ public void onReceivedTitle(XWalkViewInternal view, String title) {}
/**
* Notify the host application of a new favicon for the current page.
- * @param view The XWalkView that initiated the callback.
+ * @param view The XWalkViewInternal that initiated the callback.
* @param icon A Bitmap containing the favicon for the current page.
*/
- public void onReceivedIcon(XWalkView view, Bitmap icon) {}
+ public void onReceivedIcon(XWalkViewInternal view, Bitmap icon) {}
/**
* Notify the host application of the url for an apple-touch-icon.
- * @param view The XWalkView that initiated the callback.
+ * @param view The XWalkViewInternal that initiated the callback.
* @param url The icon url.
* @param precomposed True if the url is for a precomposed touch icon.
*/
- public void onReceivedTouchIconUrl(XWalkView view, String url,
+ public void onReceivedTouchIconUrl(XWalkViewInternal view, String url,
boolean precomposed) {}
/**
@@ -156,30 +156,30 @@ public void onHideCustomView() {
/**
* Request the host application to create a new window. If the host
* application chooses to honor this request, it should return true from
- * this method, create a new XWalkView to host the window, insert it into the
+ * this method, create a new XWalkViewInternal to host the window, insert it into the
* View system and send the supplied resultMsg message to its target with
- * the new XWalkView as an argument. If the host application chooses not to
+ * the new XWalkViewInternal as an argument. If the host application chooses not to
* honor the request, it should return false from this method. The default
* implementation of this method does nothing and hence returns false.
- * @param view The XWalkView from which the request for a new window
+ * @param view The XWalkViewInternal from which the request for a new window
* originated.
* @param isDialog True if the new window should be a dialog, rather than
* a full-size window.
* @param isUserGesture True if the request was initiated by a user gesture,
* such as the user clicking a link.
- * @param resultMsg The message to send when once a new XWalkView has been
+ * @param resultMsg The message to send when once a new XWalkViewInternal has been
* created. resultMsg.obj is a
- * {@link XWalkView.XWalkViewTransport} object. This should be
- * used to transport the new XWalkView, by calling
- * {@link XWalkView.XWalkViewTransport#setXWalkView(XWalkView)
- * XWalkView.XWalkViewTransport.setXWalkView(XWalkView)}.
+ * {@link XWalkViewInternal.XWalkViewTransport} object. This should be
+ * used to transport the new XWalkViewInternal, by calling
+ * {@link XWalkViewInternal.XWalkViewTransport#setXWalkView(XWalkViewInternal)
+ * XWalkViewInternal.XWalkViewTransport.setXWalkView(XWalkViewInternal)}.
* @return This method should return true if the host application will
* create a new window, in which case resultMsg should be sent to
* its target. Otherwise, this method should return false. Returning
* false from this method but also sending resultMsg will result in
* undefined behavior.
*/
- public boolean onCreateWindow(XWalkView view, boolean isDialog,
+ public boolean onCreateWindow(XWalkViewInternal view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
return false;
}
@@ -201,7 +201,7 @@ public boolean onCreateWindow(XWalkView view, boolean isDialog,
* database, in bytes
* @param totalQuota The total quota for all origins, in bytes
* @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
- * must be used to inform the XWalkView of the new quota.
+ * must be used to inform the XWalkViewInternal of the new quota.
*/
// Note that the callback must always be executed at some point to ensure
// that the sleeping WebCore thread is woken up.
@@ -232,7 +232,7 @@ public void onExceededDatabaseQuota(String url, String databaseIdentifier,
* in bytes.
* @param quota The quota, in bytes
* @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
- * must be used to inform the XWalkView of the new quota.
+ * must be used to inform the XWalkViewInternal of the new quota.
*/
// Note that the callback must always be executed at some point to ensure
// that the sleeping WebCore thread is woken up.
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegate.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegate.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegate.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegate.java
index ea6812d054..f91bd0abab 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegate.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegate.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
diff --git a/runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegateAdapter.java b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegateAdapter.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegateAdapter.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegateAdapter.java
index 3d7a12aa16..bc0ff7d233 100644
--- a/runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegateAdapter.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegateAdapter.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core;
+package org.xwalk.core.internal;
import android.util.Log;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkCoreExtensionBridge.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkCoreExtensionBridge.java
similarity index 91%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkCoreExtensionBridge.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkCoreExtensionBridge.java
index 6b956544c0..e0b136b8ff 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkCoreExtensionBridge.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkCoreExtensionBridge.java
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.content.Context;
import android.content.Intent;
import org.chromium.base.CalledByNative;
-import org.xwalk.core.extensions.XWalkExtensionAndroid;
-import org.xwalk.core.extension.XWalkExtension;
+import org.xwalk.core.internal.extensions.XWalkExtensionAndroid;
+import org.xwalk.core.internal.extension.XWalkExtension;
/**
* The extension bridge for the implementation based on xwalk core.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtension.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtension.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtension.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtension.java
index d49ea66419..26ce61e324 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtension.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtension.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.content.Context;
import android.content.Intent;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridge.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridge.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridge.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridge.java
index 73f52e3d3a..2f5526ef02 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridge.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridge.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.content.Intent;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridgeFactory.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridgeFactory.java
similarity index 92%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridgeFactory.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridgeFactory.java
index e4dae3c729..2d15653303 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionBridgeFactory.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionBridgeFactory.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
/**
* A factory used to create the extension bridge.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionClientImpl.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionClientImpl.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionClientImpl.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionClientImpl.java
index 1927e5dda6..6cea295db8 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionClientImpl.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionClientImpl.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.content.Context;
import android.content.Intent;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContext.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContext.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContext.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContext.java
index 78492acdc4..72d87624f9 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContext.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContext.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.app.Activity;
import android.content.Context;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContextWrapper.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContextWrapper.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContextWrapper.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContextWrapper.java
index e34288f2fb..eb08b548bd 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionContextWrapper.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionContextWrapper.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.app.Activity;
import android.content.Context;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionManager.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionManager.java
index 1845580613..985ac03c60 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/XWalkExtensionManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/XWalkExtensionManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension;
+package org.xwalk.core.internal.extension;
import android.app.Activity;
import android.content.Context;
@@ -23,12 +23,12 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.contacts.Contacts;
-import org.xwalk.core.extension.api.device_capabilities.DeviceCapabilities;
-import org.xwalk.core.extension.api.launchscreen.LaunchScreenExtension;
-import org.xwalk.core.extension.api.messaging.Messaging;
-import org.xwalk.core.extension.api.presentation.PresentationExtension;
-import org.xwalk.core.extension.api.screenorientation.ScreenOrientationExtension;
+import org.xwalk.core.internal.extension.api.contacts.Contacts;
+import org.xwalk.core.internal.extension.api.device_capabilities.DeviceCapabilities;
+import org.xwalk.core.internal.extension.api.launchscreen.LaunchScreenExtension;
+import org.xwalk.core.internal.extension.api.messaging.Messaging;
+import org.xwalk.core.internal.extension.api.presentation.PresentationExtension;
+import org.xwalk.core.internal.extension.api.screenorientation.ScreenOrientationExtension;
/**
* This internal class acts a manager to manage extensions.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerJBMR1.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerJBMR1.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerJBMR1.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerJBMR1.java
index 806468d74e..b14dbd43c3 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerJBMR1.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerJBMR1.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api;
+package org.xwalk.core.internal.extension.api;
import android.content.Context;
import android.hardware.display.DisplayManager;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerNull.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerNull.java
similarity index 93%
rename from runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerNull.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerNull.java
index 1d93a7fb4f..81aacfc6b2 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/DisplayManagerNull.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/DisplayManagerNull.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api;
+package org.xwalk.core.internal.extension.api;
import android.view.Display;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/OWNERS b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/OWNERS
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/extension/api/OWNERS
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/OWNERS
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/XWalkDisplayManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/XWalkDisplayManager.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/api/XWalkDisplayManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/XWalkDisplayManager.java
index 6f3eec965f..44bd29c77d 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/XWalkDisplayManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/XWalkDisplayManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api;
+package org.xwalk.core.internal.extension.api;
import android.os.Build;
import android.content.Context;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactConstants.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactConstants.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactConstants.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactConstants.java
index dbb1a1820a..ec3de1699a 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactConstants.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactConstants.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactEventListener.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactEventListener.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactEventListener.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactEventListener.java
index 78751ab429..453923ce0b 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactEventListener.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactEventListener.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.content.ContentResolver;
import android.database.ContentObserver;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactFinder.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactFinder.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactFinder.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactFinder.java
index 7301141459..f078d8527a 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactFinder.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactFinder.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.content.ContentResolver;
import android.database.Cursor;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactJson.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactJson.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactJson.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactJson.java
index e9b466d750..d6b1054ee3 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactJson.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactJson.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.util.Log;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactSaver.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactSaver.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactSaver.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactSaver.java
index 074686e29b..ea4d730fb8 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactSaver.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactSaver.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.content.ContentProviderOperation;
import android.content.ContentProviderOperation.Builder;
@@ -28,7 +28,7 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.contacts.ContactConstants.ContactMap;
+import org.xwalk.core.internal.extension.api.contacts.ContactConstants.ContactMap;
/**
* This class saves contacts according to a given JSONString.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactUtils.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactUtils.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactUtils.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactUtils.java
index 9ad8b27442..099f53898a 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/ContactUtils.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/ContactUtils.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/Contacts.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/Contacts.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/Contacts.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/Contacts.java
index d7dcb74a15..d299969ab4 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/Contacts.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/Contacts.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.contacts;
+package org.xwalk.core.internal.extension.api.contacts;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
@@ -21,8 +21,8 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
public class Contacts extends XWalkExtension {
public static final String NAME = "xwalk.experimental.contacts";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/contacts/contacts_api.js b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/contacts_api.js
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/extension/api/contacts/contacts_api.js
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/contacts_api.js
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilities.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilities.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilities.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilities.java
index 653e53b0d3..7c2193efdc 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilities.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilities.java
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import android.util.Log;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCPU.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCPU.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCPU.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCPU.java
index ed1cc6d071..1dcdd438a3 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCPU.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCPU.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import android.util.Log;
@@ -11,7 +11,7 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
class DeviceCapabilitiesCPU {
private static final String SYSTEM_INFO_STAT_FILE = "/proc/stat";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java
similarity index 81%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java
index d35dd2d941..ecea792f43 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesCodecs.java
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
class DeviceCapabilitiesCodecs {
private static XWalkMediaCodec sMediaCodec;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java
index c107080db8..3c36b71425 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesDisplay.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import android.content.Context;
import android.graphics.Point;
@@ -14,8 +14,8 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.XWalkDisplayManager;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.api.XWalkDisplayManager;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
class DeviceCapabilitiesDisplay {
private static final String TAG = "DeviceCapabilitiesDisplay";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesMemory.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesMemory.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesMemory.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesMemory.java
index 3b5c14efca..3a039b4090 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesMemory.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesMemory.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
@@ -15,7 +15,7 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
class DeviceCapabilitiesMemory {
private static final String MEM_INFO_FILE = "/proc/meminfo";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesStorage.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesStorage.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesStorage.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesStorage.java
index fc69d88de3..d830becb4d 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/DeviceCapabilitiesStorage.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/DeviceCapabilitiesStorage.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -20,7 +20,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
class DeviceCapabilitiesStorage {
private static final String TAG = "DeviceCapabilitiesStorage";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodec.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodec.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodec.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodec.java
index b98bd445c6..7fc7934f01 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodec.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodec.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import java.util.HashSet;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodecNull.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodecNull.java
similarity index 85%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodecNull.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodecNull.java
index 087eb317d3..5e4cf8c095 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/MediaCodecNull.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/MediaCodecNull.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import org.json.JSONObject;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/XWalkMediaCodec.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/XWalkMediaCodec.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/XWalkMediaCodec.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/XWalkMediaCodec.java
index 739c609594..88fb924547 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/XWalkMediaCodec.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/XWalkMediaCodec.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.device_capabilities;
+package org.xwalk.core.internal.extension.api.device_capabilities;
import java.util.Set;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/device_capabilities_api.js b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/device_capabilities_api.js
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/device_capabilities_api.js
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/device_capabilities_api.js
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/launchscreen/LaunchScreenExtension.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/launchscreen/LaunchScreenExtension.java
similarity index 86%
rename from runtime/android/core/src/org/xwalk/core/extension/api/launchscreen/LaunchScreenExtension.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/launchscreen/LaunchScreenExtension.java
index 3fcf19fcac..421cc01a02 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/launchscreen/LaunchScreenExtension.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/launchscreen/LaunchScreenExtension.java
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.launchscreen;
+package org.xwalk.core.internal.extension.api.launchscreen;
import android.content.Intent;
import android.util.Log;
-import org.xwalk.core.XWalkLaunchScreenManager;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.XWalkLaunchScreenManager;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
/**
* A XWalk extension for LaunchScreen API implementation on Android.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/Messaging.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/Messaging.java
similarity index 93%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/Messaging.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/Messaging.java
index b6e17236e6..b9abad0993 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/Messaging.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/Messaging.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
import android.app.Activity;
import android.content.ContentValues;
@@ -20,10 +20,10 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.messaging.MessagingManager;
-import org.xwalk.core.extension.api.messaging.MessagingSmsManager;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.api.messaging.MessagingManager;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsManager;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
interface Command {
void runCommand(int instanceID, JSONObject jsonMsg);
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingHelpers.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingHelpers.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingHelpers.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingHelpers.java
index f84737c097..471565d0bb 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingHelpers.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingHelpers.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
import android.database.Cursor;
import java.text.SimpleDateFormat;
@@ -12,8 +12,8 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.messaging.MessagingSmsConstMaps;
-import org.xwalk.core.extension.api.messaging.MessagingSmsConsts;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsConstMaps;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsConsts;
public class MessagingHelpers {
private static String buildSqlClause(boolean hasAnd, String condition, String column) {
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingManager.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingManager.java
index 2a01e1ade4..c96c2674cf 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
import android.app.Activity;
import android.app.PendingIntent;
@@ -27,10 +27,10 @@
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.messaging.Messaging;
-import org.xwalk.core.extension.api.messaging.MessagingHelpers;
-import org.xwalk.core.extension.api.messaging.MessagingSmsConstMaps;
-import org.xwalk.core.extension.api.messaging.MessagingSmsConsts;
+import org.xwalk.core.internal.extension.api.messaging.Messaging;
+import org.xwalk.core.internal.extension.api.messaging.MessagingHelpers;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsConstMaps;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsConsts;
public class MessagingManager {
private final static String TAG = "MessagingManager";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConstMaps.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConstMaps.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConstMaps.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConstMaps.java
index 69fc6858fc..5adc869684 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConstMaps.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConstMaps.java
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
import java.util.HashMap;
-import org.xwalk.core.extension.api.messaging.MessagingSmsConsts;
+import org.xwalk.core.internal.extension.api.messaging.MessagingSmsConsts;
public class MessagingSmsConstMaps {
final public static HashMap smsTableColumnDict =
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConsts.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConsts.java
similarity index 97%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConsts.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConsts.java
index ef0f1eff9d..023cb0e911 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsConsts.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsConsts.java
@@ -17,7 +17,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
// Contains SMS content provider constants. These values are copied from
// com.android.provider.telephony.*
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsManager.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsManager.java
similarity index 99%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsManager.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsManager.java
index 4d88c84fa1..bc46167023 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/MessagingSmsManager.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/MessagingSmsManager.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.messaging;
+package org.xwalk.core.internal.extension.api.messaging;
import android.app.Activity;
import android.app.PendingIntent;
@@ -25,7 +25,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.core.extension.api.messaging.Messaging;
+import org.xwalk.core.internal.extension.api.messaging.Messaging;
public class MessagingSmsManager {
private final static String TAG = "MessagingSmsManager";
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/messaging/messaging_api.js b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/messaging_api.js
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/extension/api/messaging/messaging_api.js
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/messaging_api.js
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/OWNERS b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/OWNERS
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/OWNERS
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/OWNERS
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationExtension.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationExtension.java
similarity index 98%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationExtension.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationExtension.java
index 9e21600d2b..2bef43bedd 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationExtension.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationExtension.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.presentation;
+package org.xwalk.core.internal.extension.api.presentation;
import android.content.Context;
import android.os.Build;
@@ -21,9 +21,9 @@
import org.chromium.base.ThreadUtils;
-import org.xwalk.core.extension.api.XWalkDisplayManager;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.api.XWalkDisplayManager;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
/**
* A XWalk extension for Presentation API implementation on Android.
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationView.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationView.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationView.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationView.java
index acf9b94f5d..4faee104dc 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationView.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationView.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.presentation;
+package org.xwalk.core.internal.extension.api.presentation;
import android.os.Build;
import android.content.Context;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewJBMR1.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewJBMR1.java
similarity index 96%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewJBMR1.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewJBMR1.java
index 31ad20b8b8..7c81e5abe2 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewJBMR1.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewJBMR1.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.presentation;
+package org.xwalk.core.internal.extension.api.presentation;
import android.app.Presentation;
import android.os.Build;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewNull.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewNull.java
similarity index 92%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewNull.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewNull.java
index 9eeae7070f..1b3a6fd7f8 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/PresentationViewNull.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/PresentationViewNull.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.presentation;
+package org.xwalk.core.internal.extension.api.presentation;
import android.view.Display;
import android.view.View;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/XWalkPresentationContent.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/XWalkPresentationContent.java
similarity index 82%
rename from runtime/android/core/src/org/xwalk/core/extension/api/presentation/XWalkPresentationContent.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/XWalkPresentationContent.java
index 4ca8e55a29..dae6ad33f3 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/presentation/XWalkPresentationContent.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/presentation/XWalkPresentationContent.java
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.presentation;
+package org.xwalk.core.internal.extension.api.presentation;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkUIClient;
-import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkUIClientInternal;
+import org.xwalk.core.internal.XWalkViewInternal;
/**
* Represents the content to be presented on the secondary display.
@@ -20,7 +20,7 @@ public class XWalkPresentationContent {
public final int INVALID_PRESENTATION_ID = -1;
private int mPresentationId = INVALID_PRESENTATION_ID;
- private XWalkView mContentView;
+ private XWalkViewInternal mContentView;
private Context mContext;
private Activity mActivity;
private PresentationDelegate mDelegate;
@@ -34,19 +34,19 @@ public XWalkPresentationContent(Context context, Activity activity, Presentation
public void load(final String url) {
if (mContentView == null) {
- mContentView = new XWalkView(mContext, mActivity);
+ mContentView = new XWalkViewInternal(mContext, mActivity);
final XWalkClient xWalkClient = new XWalkClient(mContentView) {
@Override
- public void onPageFinished(XWalkView view, String url) {
+ public void onPageFinished(XWalkViewInternal view, String url) {
mPresentationId = mContentView.getContentID();
onContentLoaded();
}
};
mContentView.setXWalkClient(xWalkClient);
- final XWalkUIClient xWalkUIClient = new XWalkUIClient(mContentView) {
+ final XWalkUIClientInternal xWalkUIClient = new XWalkUIClientInternal(mContentView) {
@Override
- public void onJavascriptCloseWindow(XWalkView view) {
+ public void onJavascriptCloseWindow(XWalkViewInternal view) {
// The content was closed already. Web need to invalidate the
// presentation id now.
mPresentationId = INVALID_PRESENTATION_ID;
diff --git a/runtime/android/core/src/org/xwalk/core/extension/api/screenorientation/ScreenOrientationExtension.java b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/screenorientation/ScreenOrientationExtension.java
similarity index 95%
rename from runtime/android/core/src/org/xwalk/core/extension/api/screenorientation/ScreenOrientationExtension.java
rename to runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/screenorientation/ScreenOrientationExtension.java
index 34d242b21d..6f6e0c0448 100644
--- a/runtime/android/core/src/org/xwalk/core/extension/api/screenorientation/ScreenOrientationExtension.java
+++ b/runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/screenorientation/ScreenOrientationExtension.java
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.core.extension.api.screenorientation;
+package org.xwalk.core.internal.extension.api.screenorientation;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.util.Log;
import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
+import org.xwalk.core.internal.extension.XWalkExtension;
+import org.xwalk.core.internal.extension.XWalkExtensionContext;
/**
* XWalk extension for screen orientation api implementation on Android.
diff --git a/runtime/android/core/src/org/xwalk/core/package.html b/runtime/android/core_internal/src/org/xwalk/core/internal/package.html
similarity index 100%
rename from runtime/android/core/src/org/xwalk/core/package.html
rename to runtime/android/core_internal/src/org/xwalk/core/internal/package.html
diff --git a/runtime/android/core/strings/android_xwalk_strings.grd b/runtime/android/core_internal/strings/android_xwalk_strings.grd
similarity index 100%
rename from runtime/android/core/strings/android_xwalk_strings.grd
rename to runtime/android/core_internal/strings/android_xwalk_strings.grd
diff --git a/runtime/android/core_shell/src/org/xwalk/core/xwview/shell/XWalkViewShellActivity.java b/runtime/android/core_shell/src/org/xwalk/core/xwview/shell/XWalkViewShellActivity.java
index 06fa264097..5fb2a73ded 100644
--- a/runtime/android/core_shell/src/org/xwalk/core/xwview/shell/XWalkViewShellActivity.java
+++ b/runtime/android/core_shell/src/org/xwalk/core/xwview/shell/XWalkViewShellActivity.java
@@ -40,7 +40,6 @@
import org.xwalk.core.XWalkPreferences;
import org.xwalk.core.XWalkResourceClient;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
public class XWalkViewShellActivity extends FragmentActivity
implements ActionBar.TabListener, XWalkViewSectionFragment.OnXWalkViewCreatedListener{
@@ -269,7 +268,7 @@ public void onClick(View v) {
if (mActiveView != null &&
mActiveView.getNavigationHistory().canGoBack()) {
mActiveView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.BACKWARD, 1);
+ XWalkNavigationHistory.BACKWARD, 1);
}
}
});
@@ -281,7 +280,7 @@ public void onClick(View v) {
if (mActiveView != null &&
mActiveView.getNavigationHistory().canGoForward()) {
mActiveView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.FORWARD, 1);
+ XWalkNavigationHistory.FORWARD, 1);
}
}
});
@@ -320,12 +319,15 @@ public void onProgressChanged(XWalkView view, int newProgress) {
}
});
+ // TODO: core shell shouldn't use internal APIs.
+ /*
xwalkView.setXWalkWebChromeClient(new XWalkWebChromeClient(xwalkView) {
@Override
- public void onReceivedTitle(XWalkView view, String title) {
- mSectionsPagerAdapter.setPageTitle(view, title);
+ public void onReceivedTitle(XWalkViewInternal view, String title) {
+ mSectionsPagerAdapter.setPageTitle((XWalkView)view, title);
}
});
+ */
}
private void setKeyboardVisibilityForUrl(boolean visible) {
diff --git a/runtime/android/runtime/src/org/xwalk/runtime/XWalkRuntimeTestHelper.java b/runtime/android/runtime/src/org/xwalk/runtime/XWalkRuntimeTestHelper.java
index 8ede0af8b2..74ce4c3691 100644
--- a/runtime/android/runtime/src/org/xwalk/runtime/XWalkRuntimeTestHelper.java
+++ b/runtime/android/runtime/src/org/xwalk/runtime/XWalkRuntimeTestHelper.java
@@ -11,10 +11,11 @@
import java.lang.reflect.Method;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkResourceClient;
-import org.xwalk.core.XWalkWebChromeClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkViewInternal;
+import org.xwalk.core.internal.XWalkWebChromeClient;
class XWalkRuntimeTestHelper {
@@ -47,7 +48,7 @@ class TestXWalkClient extends XWalkClient {
}
@Override
- public void onPageStarted(XWalkView view, String url) {
+ public void onPageStarted(XWalkViewInternal view, String url) {
super.onPageStarted(view, url);
if (mCallbackForTest != null) {
try {
@@ -61,7 +62,7 @@ public void onPageStarted(XWalkView view, String url) {
}
@Override
- public void onPageFinished(XWalkView view, String url) {
+ public void onPageFinished(XWalkViewInternal view, String url) {
super.onPageFinished(view, url);
if (mCallbackForTest != null) {
try {
@@ -81,7 +82,7 @@ class TestXWalkWebChromeClient extends XWalkWebChromeClient {
}
@Override
- public void onReceivedTitle(XWalkView view, String title) {
+ public void onReceivedTitle(XWalkViewInternal view, String title) {
super.onReceivedTitle(view, title);
if (mCallbackForTest != null) {
try {
diff --git a/runtime/android/sample/src/org/xwalk/core/sample/ResourceAndUIClientsActivity.java b/runtime/android/sample/src/org/xwalk/core/sample/ResourceAndUIClientsActivity.java
index 52f9a41095..52eb1c90de 100644
--- a/runtime/android/sample/src/org/xwalk/core/sample/ResourceAndUIClientsActivity.java
+++ b/runtime/android/sample/src/org/xwalk/core/sample/ResourceAndUIClientsActivity.java
@@ -63,7 +63,7 @@ public void onJavascriptCloseWindow(XWalkView view) {
Log.d(TAG, "Window closed.");
}
- public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type,
+ public boolean onJavascriptModalDialog(XWalkView view, int type,
String url,
String message, String defaultValue, XWalkJavascriptResult result) {
Log.d(TAG, "Show JS dialog.");
diff --git a/runtime/android/sample/src/org/xwalk/core/sample/XWalkNavigationActivity.java b/runtime/android/sample/src/org/xwalk/core/sample/XWalkNavigationActivity.java
index ec3b50c4e6..5565e07ffb 100644
--- a/runtime/android/sample/src/org/xwalk/core/sample/XWalkNavigationActivity.java
+++ b/runtime/android/sample/src/org/xwalk/core/sample/XWalkNavigationActivity.java
@@ -41,7 +41,7 @@ public void onClick(View v) {
if (mXWalkView != null &&
mXWalkView.getNavigationHistory().canGoBack()) {
mXWalkView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.BACKWARD, 1);
+ XWalkNavigationHistory.BACKWARD, 1);
}
XWalkNavigationItem navigationItem = mXWalkView.getNavigationHistory().getCurrentItem();
showNavigationItemInfo(navigationItem);
@@ -55,7 +55,7 @@ public void onClick(View v) {
if (mXWalkView != null &&
mXWalkView.getNavigationHistory().canGoForward()) {
mXWalkView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.FORWARD, 1);
+ XWalkNavigationHistory.FORWARD, 1);
}
XWalkNavigationItem navigationItem = mXWalkView.getNavigationHistory().getCurrentItem();
showNavigationItemInfo(navigationItem);
diff --git a/runtime/browser/android/xwalk_settings.cc b/runtime/browser/android/xwalk_settings.cc
index 143239cdbb..b274b70156 100644
--- a/runtime/browser/android/xwalk_settings.cc
+++ b/runtime/browser/android/xwalk_settings.cc
@@ -42,7 +42,7 @@ struct XWalkSettings::FieldIds {
// FIXME: we should be using a new GetFieldIDFromClassName() with caching.
ScopedJavaLocalRef clazz(
- GetClass(env, "org/xwalk/core/XWalkSettings"));
+ GetClass(env, "org/xwalk/core/internal/XWalkSettings"));
allow_scripts_to_close_windows =
GetFieldID(env, clazz, "mAllowScriptsToCloseWindows", "Z");
load_images_automatically =
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ClearHistoryTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ClearHistoryTest.java
index 271bca7506..d88784f1a2 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ClearHistoryTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ClearHistoryTest.java
@@ -10,8 +10,8 @@
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
/**
* Test suite for clearHistory().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/CookieManagerTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/CookieManagerTest.java
index 33028031f2..b38a260bc3 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/CookieManagerTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/CookieManagerTest.java
@@ -23,9 +23,9 @@
import java.util.List;
import java.util.Set;
-import org.xwalk.core.XWalkCookieManager;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkCookieManager;
+import org.xwalk.core.internal.XWalkClient;
/**
* Tests for the CookieManager.
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcast.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcast.java
index e0c194ba6b..67cca254d4 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcast.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcast.java
@@ -4,7 +4,7 @@
package org.xwalk.core.xwview.test;
-import org.xwalk.core.extensions.XWalkExtensionAndroid;
+import org.xwalk.core.internal.extensions.XWalkExtensionAndroid;
public class ExtensionBroadcast extends XWalkExtensionAndroid {
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcastTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcastTest.java
index 2d3df74d03..770717618a 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcastTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionBroadcastTest.java
@@ -10,9 +10,9 @@
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkWebChromeClient;
import org.xwalk.core.xwview.test.ExtensionBroadcast;
/**
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEcho.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEcho.java
index 012b883fee..8096c11ff2 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEcho.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEcho.java
@@ -4,7 +4,7 @@
package org.xwalk.core.xwview.test;
-import org.xwalk.core.extensions.XWalkExtensionAndroid;
+import org.xwalk.core.internal.extensions.XWalkExtensionAndroid;
public class ExtensionEcho extends XWalkExtensionAndroid {
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEchoTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEchoTest.java
index d31ce7e571..181a95549f 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEchoTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ExtensionEchoTest.java
@@ -10,9 +10,9 @@
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkWebChromeClient;
import org.xwalk.core.xwview.test.ExtensionEcho;
/**
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/GeolocationPermissionTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/GeolocationPermissionTest.java
index 9055994cfc..708b93f1fb 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/GeolocationPermissionTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/GeolocationPermissionTest.java
@@ -11,10 +11,10 @@
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkGeolocationPermissions;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkGeolocationPermissions;
+import org.xwalk.core.internal.XWalkWebChromeClient;
/**
* Test suite for onGeolocationPermissionsShowPrompt() and
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/HandleActionUriTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/HandleActionUriTest.java
index 338fef8907..c1c5e252db 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/HandleActionUriTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/HandleActionUriTest.java
@@ -13,8 +13,8 @@
import org.chromium.base.test.util.Feature;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkNavigationHandlerImpl;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkNavigationHandlerImpl;
/**
* Test suite for handling ActionUri.
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnPageFinishedTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnPageFinishedTest.java
index 019d867d96..77097ed17e 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnPageFinishedTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnPageFinishedTest.java
@@ -12,8 +12,8 @@
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
import java.util.concurrent.TimeUnit;
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnUpdateTitleTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnUpdateTitleTest.java
index 8c19e80b54..bd00acc9f4 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnUpdateTitleTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/OnUpdateTitleTest.java
@@ -9,9 +9,9 @@
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkWebChromeClient;
/**
* Test suite for onUpdateTitle().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ReloadTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ReloadTest.java
index f07f0765ca..0554921768 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/ReloadTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/ReloadTest.java
@@ -11,8 +11,8 @@
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
/**
* Test suite for reload().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/RendererResponsivenessTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/RendererResponsivenessTest.java
index 1ebc5c14df..fb4eae6ee1 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/RendererResponsivenessTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/RendererResponsivenessTest.java
@@ -19,8 +19,9 @@
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkViewInternal;
/**
* Renderer responsiveness tests:
@@ -46,7 +47,7 @@ public void testRendererUnresponsive() throws Throwable {
setXWalkClient(new XWalkViewTestBase.TestXWalkClient());
getXWalkView().setXWalkClient(new XWalkClient(getXWalkView()) {
@Override
- public void onRendererUnresponsive(XWalkView view) {
+ public void onRendererUnresponsive(XWalkViewInternal view) {
unresponsiveHelper.notifyCalled(view);
}
});
@@ -82,7 +83,7 @@ public void testRendererResponsiveAgain() throws Throwable {
* Called once the renderer become responsive again.
*/
@Override
- public void onRendererResponsive(XWalkView view) {
+ public void onRendererResponsive(XWalkViewInternal view) {
responsiveHelper.notifyCalled(view);
}
});
@@ -107,13 +108,13 @@ public void onRendererResponsive(XWalkView view) {
}
private final class OnRendererResponsivenessHelper extends CallbackHelper {
- private XWalkView mView;
+ private XWalkViewInternal mView;
- public void notifyCalled(XWalkView view) {
+ public void notifyCalled(XWalkViewInternal view) {
mView = view;
notifyCalled();
}
- public XWalkView getXWalkView() {
+ public XWalkViewInternal getXWalkView() {
assert getCallCount() > 0;
return mView;
}
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SaveRestoreStateTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SaveRestoreStateTest.java
index 3212860e2e..d7cc0c2763 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SaveRestoreStateTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SaveRestoreStateTest.java
@@ -17,9 +17,9 @@
import org.chromium.content.browser.NavigationHistory;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkNavigationHistory;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
import org.xwalk.core.xwview.test.util.CommonResources;
import java.util.concurrent.Callable;
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetAppCacheEnabledTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetAppCacheEnabledTest.java
index fa25a468ee..8bb8212640 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetAppCacheEnabledTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetAppCacheEnabledTest.java
@@ -20,10 +20,10 @@
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkSettings;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkSettings;
+import org.xwalk.core.internal.XWalkWebChromeClient;
import org.xwalk.core.xwview.test.util.CommonResources;
/**
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDatabaseEnabledTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDatabaseEnabledTest.java
index 838b01de53..d7b29720d1 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDatabaseEnabledTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDatabaseEnabledTest.java
@@ -13,7 +13,7 @@
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkClient;
+import org.xwalk.core.internal.XWalkClient;
/**
* Test suite for setDatabaseEnabled().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDomStorageEnabledTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDomStorageEnabledTest.java
index 964f04000b..30fd2fdb06 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDomStorageEnabledTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetDomStorageEnabledTest.java
@@ -13,10 +13,10 @@
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkSettings;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkSettings;
+import org.xwalk.core.internal.XWalkWebChromeClient;
/**
* Test suite for setDomStorageEnabled().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetNetworkAvailableTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetNetworkAvailableTest.java
index eb72a91ef4..f42d426d22 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetNetworkAvailableTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/SetNetworkAvailableTest.java
@@ -11,8 +11,8 @@
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
/**
* Test case for XWalkView.setNetworkAvailable method
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/UserAgentTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/UserAgentTest.java
index ae860651ca..c228ca9ba3 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/UserAgentTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/UserAgentTest.java
@@ -16,9 +16,9 @@
import org.apache.http.HttpRequest;
import org.chromium.base.test.util.Feature;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkSettings;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkSettings;
/**
* Test suite for setUserAgentString() and getUserAgentString().
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/WebNotificationTest.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/WebNotificationTest.java
index 6544fd0d79..545b82575b 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/WebNotificationTest.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/WebNotificationTest.java
@@ -16,11 +16,11 @@
import android.util.Log;
import org.chromium.base.test.util.Feature;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkPreferences;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
-import org.xwalk.core.XWalkNotificationServiceImpl;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkNotificationServiceImpl;
/**
* Test suite for web notification API.
diff --git a/test/android/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewTestBase.java b/test/android/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewTestBase.java
index c42b9e438e..98fbf8dbd2 100644
--- a/test/android/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewTestBase.java
+++ b/test/android/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewTestBase.java
@@ -25,12 +25,13 @@
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.xwalk.core.XWalkClient;
import org.xwalk.core.XWalkNavigationHistory;
import org.xwalk.core.XWalkResourceClient;
-import org.xwalk.core.XWalkSettings;
import org.xwalk.core.XWalkView;
-import org.xwalk.core.XWalkWebChromeClient;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.internal.XWalkSettings;
+import org.xwalk.core.internal.XWalkViewInternal;
+import org.xwalk.core.internal.XWalkWebChromeClient;
public class XWalkViewTestBase
extends ActivityInstrumentationTestCase2 {
@@ -47,12 +48,12 @@ public TestXWalkClientBase(TestHelperBridge client) {
}
@Override
- public void onPageStarted(XWalkView view, String url) {
+ public void onPageStarted(XWalkViewInternal view, String url) {
mInnerContentsClient.onPageStarted(url);
}
@Override
- public void onPageFinished(XWalkView view, String url) {
+ public void onPageFinished(XWalkViewInternal view, String url) {
mInnerContentsClient.onPageFinished(url);
}
}
@@ -71,7 +72,7 @@ public TestXWalkWebChromeClientBase(TestHelperBridge client) {
}
@Override
- public void onReceivedTitle(XWalkView view, String title) {
+ public void onReceivedTitle(XWalkViewInternal view, String title) {
mInnerContentsClient.onTitleChanged(title);
}
}
@@ -418,7 +419,7 @@ public void run() {
@Override
public void run() {
mXWalkView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.BACKWARD, 1);
+ XWalkNavigationHistory.BACKWARD, 1);
}
});
}
@@ -433,7 +434,7 @@ public void run() {
@Override
public void run() {
mXWalkView.getNavigationHistory().navigate(
- XWalkNavigationHistory.Direction.FORWARD, 1);
+ XWalkNavigationHistory.FORWARD, 1);
}
});
}
diff --git a/tools/reflection_generator/generator.py b/tools/reflection_generator/generator.py
new file mode 100644
index 0000000000..193da09e20
--- /dev/null
+++ b/tools/reflection_generator/generator.py
@@ -0,0 +1,87 @@
+import optparse
+import os
+import sys
+import shutil
+import subprocess
+
+
+def Touch(path):
+ if not os.path.isdir(os.path.dirname(path)):
+ os.makedirs(os.path.dirname(path))
+ with open(path, 'a'):
+ os.utime(path, None)
+
+
+def GetCommandOutput(command, cwd=None):
+ proc = subprocess.Popen(command, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, bufsize=1,
+ cwd=cwd)
+ output = proc.communicate()[0]
+ result = proc.returncode
+ if result:
+ raise Exception('%s: %s' % (subprocess.list2cmdline(command), output))
+ return output
+
+
+def DoGenerate(options):
+ mainClass = 'org.xwalk.reflection.generator.Generator'
+ jars = []
+ for jar in options.classpath.split(' '):
+ try:
+ jarPath = eval(jar)
+ except:
+ jarPath = jar
+ jars.append(jarPath)
+ classpath = ':'.join(jars)
+ if os.path.isdir(options.output):
+ shutil.rmtree(options.output)
+ os.makedirs(options.output)
+ cmd = ['java', '-classpath', classpath, mainClass,
+ str(options.reflection).lower(), options.source, options.output]
+ GetCommandOutput(cmd)
+
+
+def DoCopyHelperJava(options):
+ if options.helper_class is None:
+ return
+ f = open(options.helper_class, 'r')
+ output = os.path.join(options.output, 'wrapper', 'src', 'org', 'xwalk', 'core',
+ os.path.basename(options.helper_class))
+ if not os.path.isdir(os.path.dirname(output)):
+ os.makedirs(os.path.dirname(output))
+ fo = open(output, 'w')
+ for line in f.read().split('\n'):
+ if line.startswith('package '):
+ fo.write('package org.xwalk.core;\n')
+ else:
+ fo.write(line + '\n')
+ fo.close()
+ f.close()
+
+
+def main():
+ parser = optparse.OptionParser()
+ info = ('list of jars needed when running generator')
+ parser.add_option('--classpath', help=info)
+ info = ('path or internal java files')
+ parser.add_option('--source', help=info)
+ info = ('intermediate folder to place generated java files')
+ parser.add_option('--output', help=info)
+ info = ('the file to touch on success.')
+ parser.add_option('--stamp', help=info)
+ info = ('set to true to create real reflection, otherwise '
+ 'only bridge and wrapper will be created')
+ parser.add_option('--reflection', default=False, action='store_true', help=info)
+ info = ('the path of the ReflectionHelper java source, '
+ 'will copy it to output folder')
+ parser.add_option('--helper-class', help=info)
+ options, _ = parser.parse_args()
+
+ DoGenerate(options)
+ DoCopyHelperJava(options)
+ if options.stamp:
+ Touch(options.stamp)
+
+if __name__ == '__main__':
+ sys.exit(main())
+
diff --git a/tools/reflection_generator/reflection_generator.py b/tools/reflection_generator/reflection_generator.py
new file mode 100755
index 0000000000..41a34de8bd
--- /dev/null
+++ b/tools/reflection_generator/reflection_generator.py
@@ -0,0 +1,1289 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import optparse
+import os
+import re
+import sys
+
+from collections import OrderedDict
+from string import Template
+
+# Classes list that have to generate bridge and wrap code.
+CLASSES_TO_BE_PROCESS = [
+ 'XWalkViewInternal',
+ 'XWalkUIClientInternal',
+ 'XWalkResourceClientInternal',
+ 'XWalkPreferencesInternal',
+ 'XWalkNavigationItemInternal',
+ 'XWalkNavigationHistoryInternal',
+ 'XWalkJavascriptResultHandlerInternal',
+ 'XWalkJavascriptResultInternal',
+]
+
+
+def ManagleInternalNameToBridgeName(internal_name):
+ if internal_name not in CLASSES_TO_BE_PROCESS:
+ return internal_name
+ else:
+ return internal_name.replace('Internal', 'Bridge')
+
+
+def MangleInternalNameToWrapperName(internal_name):
+ if internal_name not in CLASSES_TO_BE_PROCESS:
+ return internal_name
+ else:
+ return internal_name.replace('Internal', '')
+
+def ManagleInternalNameToFullBridgeName(internal_name):
+ if internal_name not in CLASSES_TO_BE_PROCESS:
+ return internal_name
+ else:
+ package_string = 'org.xwalk.core.internal.%s'
+ return package_string % (internal_name.replace('Internal', 'Bridge'))
+
+
+def ManagleInternalNameToFullWrapperName(internal_name):
+ if internal_name not in CLASSES_TO_BE_PROCESS:
+ return internal_name
+ else:
+ return "org.xwalk.core.%s" % (internal_name.replace('Internal', ''))
+
+
+class Method:
+ """Internal representaion of a method."""
+ ANNOTATION_PRE_WRAPLINE = 'preWrapperLines'
+ ANNOTATION_POST_WRAPLINE = 'postWrapLines'
+
+ def __init__(self, is_constructor, is_static, method_name, method_return,
+ params, annotation):
+ self._is_constructor = is_constructor
+ self._is_static = is_static
+ self._method_name = method_name
+ self._method_return = method_return
+ self._params = OrderedDict() # Use OrderedDict to avoid parameter misorder.
+ self._method_annotations = {}
+ self.ParseMethodParams(params)
+ self.ParseMethodAnnotation(annotation)
+
+ @property
+ def is_constructor(self):
+ return self._is_constructor
+
+ @property
+ def is_static(self):
+ return self._is_static
+
+ @property
+ def method_name(self):
+ return self._method_name
+
+ @property
+ def method_return(self):
+ return self._method_return
+
+ @property
+ def params(self):
+ return self._params
+
+ @property
+ def method_annotations(self):
+ return self._method_annotations
+
+ def ParseMethodParams(self, params):
+ # TODO(shouqun): Currently, generic parameters are not supported.
+ # The support of generic types should be added if such cases happen.
+ if not params or params == '':
+ return
+ for param in params.split(','):
+ param = param.strip()
+ param_list = param.split()
+ param_type = param_list[0]
+ param_name = param_list[1]
+ self._params[param_name] = param_type
+
+ def ParseMethodAnnotation(self, annotation):
+ pre_wrapline_re = re.compile('preWrapperLines\s*=\s*\{'
+ '(?P[a-zA-Z0-9%,\s\(\);._"=]*)\}')
+ for match in re.finditer(pre_wrapline_re, annotation):
+ pre_wrapline = match.group('pre_wrapline')
+ self._method_annotations[self.ANNOTATION_PRE_WRAPLINE] = pre_wrapline
+
+ post_wrapline_re = re.compile('postWrapperLines\s*=\s*\{('
+ '?P[a-zA-Z0-9%,\s\(\);._"=]*)\}')
+ for match in re.finditer(post_wrapline_re, annotation):
+ post_wrapline = match.group('post_wrapline')
+ self._method_annotations[self.ANNOTATION_POST_WRAPLINE] = post_wrapline
+
+
+class Field:
+ """Python class represents static field of a java class"""
+ def __init__(self, field_type, name, value):
+ self._field_type = field_type
+ self._field_name = name
+ self._field_value = value
+
+ @property
+ def field_type(self):
+ return self._field_type
+
+ @property
+ def field_name(self):
+ return self._field_name
+
+ @property
+ def field_value(self):
+ return self._field_value
+
+
+class CodeGenerator(object):
+ """Basic class of code generator"""
+ def __init__(self, java_data):
+ self._java_data = java_data
+ self._generated_code = ''
+ self._generated_class_name = ''
+
+ def RunTask(self):
+ pass
+
+ def GetGeneratedCode(self):
+ return self._generated_code
+
+ def GetGeneratedClassFileName(self):
+ return self._generated_class_name + '.java'
+
+ def GenerateImportRules(self):
+ imports = ''
+ for imported in self._java_data.imports:
+ import_string = 'import ' + imported + ";\n"
+ imports += import_string
+ # Add the reflection helper import.
+ imports += '\n'
+ imports += 'import java.lang.reflect.Constructor;\n'
+ imports += 'import java.lang.reflect.Method;\n'
+ return imports
+
+ def FormatStaticInitializerConstructorName(self, method):
+ constructor = method.method_name
+ for param_name in method.params:
+ constructor += method.params[param_name]
+ constructor += 'Constructor'
+ return constructor
+
+
+class InterfaceGenerator(CodeGenerator):
+ """Generator class that generates interfade code in wrapper layer"""
+ def __init__(self, java_data):
+ super(InterfaceGenerator, self).__init__(java_data)
+
+ def RunTask(self):
+ self._generated_code = self.GenerateInterface()
+ self._generated_class_name = MangleInternalNameToWrapperName(
+ self._java_data.class_name)
+
+ def GenerateInterface(self):
+ interface_template = Template("""
+${PACKAGE_SECTION}
+
+${IMPORT_SECTION}
+public interface ${INTERFACE_NAME} {
+${METHOD_SECTION}
+}
+""")
+ package_section = 'package %s;' % \
+ (self._java_data.package_name.replace('.internal', ''))
+ import_section = self.GenerateImportRules()
+ method_section = self.GenerateMethods()
+ interface_name = MangleInternalNameToWrapperName(self._java_data.class_name)
+ value = {'PACKAGE_SECTION': package_section,
+ 'IMPORT_SECTION': import_section,
+ 'INTERFACE_NAME': interface_name,
+ 'METHOD_SECTION': method_section}
+ interface_code = interface_template.substitute(value)
+ return interface_code
+
+ def FormatMethodParams(self, params):
+ params_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ param_type = MangleInternalNameToWrapperName(param_type)
+ params_string += '%s %s,' % (param_type, param_name)
+ if params_string.endswith(','):
+ params_string = params_string[0:-1]
+ return params_string
+
+ def FormatMethodString(self, method):
+ method_template = Template("""\
+ public ${RETURN} ${NAME}(${PARAMS});
+""")
+ method_return = method.method_return
+ if method.method_return in CLASSES_TO_BE_PROCESS:
+ method_return = MangleInternalNameToWrapperName(method_return)
+ value = {'RETURN': method_return,
+ 'NAME': method.method_name,
+ 'PARAMS': self.FormatMethodParams(method.params)}
+ return method_template.substitute(value)
+
+ def GenerateMethods(self):
+ methods_string = ''
+ for method in self._java_data.methods:
+ methods_string += self.FormatMethodString(method)
+ return methods_string
+
+
+class BrigdeGenerator(CodeGenerator):
+ """ Generator class that generates bridge layer code."""
+ def __init__(self, java_data):
+ super(BrigdeGenerator, self).__init__(java_data)
+
+ def RunTask(self):
+ self._generated_code = self.GenerateBrigdeClass()
+ self._generated_class_name = ManagleInternalNameToBridgeName(
+ self._java_data.class_name)
+
+ def GenerateBrigdeClass(self):
+ bridge_class_template = Template("""\
+${PACKAGE_SECTION}
+
+${IMPORT_SECTION}
+public class ${CLASS_NAME} extends ${PARENT_CLASS} {
+ private final static String WRAPPER_CLASS = "org.xwalk.core.Object";
+ private Object wrapper;
+
+ public Object getWrapper() {
+ return wrapper;
+ }
+${CREATE_INTERNALLY_CONSTRUCTOR}
+${STATIC_METHOD_SECTION}
+${METHODS_SECTION}
+
+${REFLECTION_INIT_SECTION}
+${STATIC_INITIALIZER}
+}
+""")
+ package_name = ''
+ if self._java_data.package_name != '':
+ package_name = 'package ' + self._java_data.package_name + ";"
+ imports_string = self.GenerateImportRules()
+ internal_class_name = self._java_data.class_name
+ bridge_class_name = ManagleInternalNameToBridgeName(internal_class_name)
+ create_internally_constructor = self.GenerateCreateInternallyConstructor()
+ static_methods = self.GenerateStaticMethods()
+ bridge_methods = self.GenerateBridgeMethods()
+ reflection_init = self.GenerateReflectionInitString()
+ static_initializer = self.GenerateStaticInitializerString()
+ value = {'PACKAGE_SECTION': package_name,
+ 'IMPORT_SECTION': imports_string,
+ 'CLASS_NAME': bridge_class_name,
+ 'PARENT_CLASS': internal_class_name,
+ 'STATIC_METHOD_SECTION': static_methods,
+ 'METHODS_SECTION': bridge_methods,
+ 'REFLECTION_INIT_SECTION': reflection_init,
+ 'CREATE_INTERNALLY_CONSTRUCTOR': create_internally_constructor,
+ 'STATIC_INITIALIZER': static_initializer}
+ class_content = bridge_class_template.substitute(value)
+ return class_content
+
+ def GenerateCreateInternallyConstructor(self):
+ if not self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_INTERNALLY):
+ return ''
+ constructor_template = Template("""\
+ private ${INTERNAL_CLASS_NAME} internal = null;
+ ${BRIDGE_CLASS_NAME}(${INTERNAL_CLASS_NAME} internal) {
+ this.internal = internal;
+ this.wrapper = ReflectionHelper.createInstance(\
+"${STATIC_CONSTRUCTOR_NAME}", this);
+ try {
+ reflectionInit();
+ } catch (Exception e) {
+ ReflectionHelper.handleException(e);
+ }
+ }
+""")
+ internal_class_name = self._java_data.class_name
+ bridge_class_name = ManagleInternalNameToBridgeName(internal_class_name)
+ constructor_method = Method(True, False, bridge_class_name, '', '', '')
+ static_constructor_name = \
+ self.FormatStaticInitializerConstructorName(constructor_method)
+ value = {'INTERNAL_CLASS_NAME': internal_class_name,
+ 'BRIDGE_CLASS_NAME': bridge_class_name,
+ 'STATIC_CONSTRUCTOR_NAME': static_constructor_name}
+ return constructor_template.substitute(value)
+
+
+ def FormatStaticMethodString(self, class_name, method):
+ method_template = Template("""\
+ public static ${RETURN} ${NAME}($PARAMS) {
+ ${RETURN_STATE}${CLASS_NAME}.${NAME}(${CALL_PARAMS});
+ }
+""")
+ return_string = method.method_return
+ name = method.method_name
+ params = self.FormatMethodParamsString(method.params)
+ return_state = ''
+ if return_string != 'void':
+ return_state = 'return '
+ call_params = self.FormatMethodCallParamsString(method.params)[1]
+ value = {'RETURN': return_string,
+ 'NAME': name,
+ 'PARAMS': params,
+ 'RETURN_STATE': return_state,
+ 'CLASS_NAME': class_name,
+ 'CALL_PARAMS': call_params}
+ return method_template.substitute(value)
+
+ def GenerateStaticMethods(self):
+ static_methods = ''
+ for method in self._java_data.methods:
+ static_methods += self.FormatStaticMethodString(
+ self._java_data.class_name, method)
+ return static_methods
+
+ def GenerateBridgeMethods(self):
+ methods_string = ''
+ for method in self._java_data.methods:
+ if method.is_constructor:
+ methods_string += self.GenerateBridgeConstructorString(method)
+ elif not method.is_static:
+ methods_string += self.GenerateBridgeMethodString(method)
+ method_field_template = Template("""\
+ private Method ${METHOD}Method;
+""")
+ for method in self._java_data.methods:
+ if not method.is_constructor and not method.is_static:
+ value = {'METHOD': method.method_name}
+ methods_string += method_field_template.substitute(value)
+ return methods_string
+
+ def FormatMethodParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ # Mangle class name if the param type is in internal class list.
+ param_type = ManagleInternalNameToBridgeName(param_type)
+ param_string += '%s %s' % (param_type, param_name)
+ param_string += ','
+ # Trim the last comma for the method parameter list.
+ if param_string.endswith(','):
+ param_string = param_string[0:-1]
+ return param_string
+
+ def FormatMethodCallParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ # Mangle parameter string if it is in internal class list.
+ param_type = ManagleInternalNameToBridgeName(param_type)
+ param_name = '((%s) a).getWrapper()' % (param_type)
+ param_string += ', '
+ param_string += param_name
+ super_param_string = param_string
+ # Trim the first comma.
+ if super_param_string.startswith(','):
+ super_param_string = super_param_string[1:]
+ return [param_string, super_param_string]
+
+ def FormatConstructorParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ param_string += '%s %s' % (param_type, param_name)
+ param_string += ','
+ return param_string
+
+ def FormatConstructorCallParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_string += param_name
+ param_string += ','
+ if param_string.endswith(','):
+ param_string = param_string[0:-1]
+ return param_string
+
+ def GenerateBridgeConstructorString(self, method):
+ constructor_template = Template("""\
+ public ${NAME}(${PARAMS} Object wrapper) {
+ super(${CALL_PARAMS});
+ this.wrapper = wrapper;
+ try {
+ reflectionInit();
+ } catch (Exception e) {
+ ReflectionHelper.handleException(e);
+ }
+ }
+""")
+ params = self.FormatConstructorParamsString(method.params)
+ call_params = self.FormatConstructorCallParamsString(method.params)
+ value = {'NAME': method.method_name,
+ 'PARAMS': params,
+ 'CALL_PARAMS': call_params}
+ return constructor_template.substitute(value)
+
+ def FormatMethodReturnStatement(self, method):
+ if method.method_return == 'void':
+ return ''
+ else:
+ return 'return (%s)' % (method.method_return)
+
+ def FormatSuperMethodReturnStatemt(self, method):
+ if method.method_return == 'void':
+ return ''
+ else:
+ return 'return '
+
+ def FormatPreCreateInternallyReturn(self):
+ return 'if (internal == null) {'
+
+ def FormatPostCreateInternallyReturn(self, method, call_params):
+ return_template = Template("""\
+} else {
+ internal.${METHOD_NAME}(${SUPER_CALL_PARAMS});
+ }
+""")
+ method_name = method.method_name
+ value = {'METHOD_NAME': method_name,
+ 'SUPER_CALL_PARAMS': call_params}
+ return return_template.substitute(value)
+
+ def GenerateBridgeMethodString(self, method):
+ method_template = Template("""\
+ public ${RETURN} ${NAME}(${PARAMS}) {
+ ${RETURN_STATEMENT}ReflectionHelper.invokeMethod(${NAME}Method, \
+wrapper${CALL_PARAMS});
+ }
+
+ public ${RETURN} ${NAME}Super(${PARAMS}) {
+ ${PRE_CREATE_INTERNALLY_RETURN}
+ ${SUPER_RETURN_STATEMENT}super.${NAME}(${SUPER_CALL_PARAMS});
+ ${POST_CREATE_INTERNALLY_RETURN}
+ }
+
+""")
+ param_string = self.FormatMethodParamsString(method.params)
+ call_param_strings = self.FormatMethodCallParamsString(method.params)
+ return_statement = self.FormatMethodReturnStatement(method)
+ super_return_statement = self.FormatSuperMethodReturnStatemt(method)
+ pre_create_internally_return = self.FormatPreCreateInternallyReturn()
+ post_create_internally_return = \
+ self.FormatPostCreateInternallyReturn(method, call_param_strings[1])
+ values = {'RETURN': method.method_return,
+ 'NAME': method.method_name,
+ 'PARAMS': param_string,
+ 'RETURN_STATEMENT': return_statement,
+ 'SUPER_RETURN_STATEMENT': super_return_statement,
+ 'CALL_PARAMS': call_param_strings[0],
+ 'SUPER_CALL_PARAMS': call_param_strings[1],
+ 'PRE_CREATE_INTERNALLY_RETURN': pre_create_internally_return,
+ 'POST_CREATE_INTERNALLY_RETURN': post_create_internally_return}
+ return method_template.substitute(values)
+
+ def FormatReflectionParamString(self, params):
+ params_string = ''
+ for param_name in params:
+ params_string += ', '
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ mangle = ManagleInternalNameToFullWrapperName(param_type)
+ param_type = 'clazz.getClassLoader().loadClass(\"%s\")' % (mangle)
+ params_string += param_type
+ else:
+ params_string += "%s.class" % (params[param_name])
+ return params_string
+
+ def GenerateReflectionInitString(self):
+ ref_methods_string = ''
+ ref_method_template = Template("""\
+ ${METHOD}Method = clazz.getMethod(\"${METHOD}\"${PARAMS});
+""")
+ for method in self._java_data.methods:
+ if method.is_constructor or method.is_static:
+ continue
+ params_string = self.FormatReflectionParamString(method.params)
+ value = { 'METHOD': method.method_name,
+ 'PARAMS': params_string}
+ ref_methods_string += ref_method_template.substitute(value)
+
+ ref_init_template = Template("""\
+ private void reflectionInit() throws NoSuchMethodException,
+ ClassNotFoundException {
+ Class> clazz = wrapper.getClass();
+${REF_METHODS}
+ }
+""")
+ value = {'REF_METHODS': ref_methods_string}
+ ref_init_string = ref_init_template.substitute(value)
+ return ref_init_string
+
+ def GenerateStaticInitializerString(self):
+ if not self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_INTERNALLY):
+ return ''
+ static_initializer_template = Template("""\
+ static {
+ ReflectionHelper.registerConstructor("${STATIC_CONSTRUCTOR_NAME}", \
+"${FULL_CLASS_NAME}", Object.class);
+ }
+""")
+ bridge_class_name = \
+ ManagleInternalNameToBridgeName(self._java_data.class_name)
+ constructor_method = Method(True, False, bridge_class_name, '', '', '')
+ static_constructor_name = \
+ self.FormatStaticInitializerConstructorName(constructor_method)
+ full_class_name = \
+ ManagleInternalNameToFullWrapperName(self._java_data.class_name)
+ value = {'STATIC_CONSTRUCTOR_NAME': static_constructor_name,
+ 'FULL_CLASS_NAME': full_class_name}
+ return static_initializer_template.substitute(value)
+
+
+class WrapperGenerator(CodeGenerator):
+ """ Generator class thar generates wrapper layer code."""
+ def __init__(self, java_data):
+ super(WrapperGenerator, self).__init__(java_data)
+
+ def RunTask(self):
+ self._generated_code = self.GenerateWrapperClass()
+ self._generated_class_name = MangleInternalNameToWrapperName(
+ self._java_data.class_name)
+
+ def GenerateWrapperClass(self):
+ wrapper_template = Template("""\
+${PACKAGE_SECTION}
+
+${IMPORT_SECTION}
+
+public class ${CLASS_NAME} ${CLASS_EXTENDS} ${CLASS_IMPLEMENTS}{
+
+${FIELD_SECTION}
+
+ private final static String BRIDGE_CLASS = "${BRIDGE_CLASS_FULL_NAME}";
+ private Object bridge;
+
+ public Object getBridge() {
+ return bridge;
+ }
+${CREATE_INTERNALLY_CONSTRUCORS}
+${CONSTRUCTORS_SECTION}
+${STATIC_METHOD_SECTION}
+${METHODS_SECTION}
+
+${REFLECTION_SECTION}
+
+${STATIC_INITIALIZER}
+}
+""")
+ package_string = self.GeneratePackageString()
+ imports = self.GenerateImportRules()
+ class_name = self.GenerateWrapperClassName()
+ class_extends = self.GenerateClassExtends()
+ class_implements = self.GenerateClassImplements()
+ fields = self.GenerateClassFields()
+ bridge_full_class_name = self._java_data.package_name + \
+ '.' + self._java_data.class_name
+ create_internally_constructor = self.GenerateCreateInternallyConstructor()
+ constructors = self.GenerateConstructors()
+ methods = self.GenerateMethods()
+ static_methods = self.GenerateStaticMethods()
+ reflections = self.GenerateReflectionInitString()
+ static_initializer = self.GenerateStaticInitializerString()
+ if self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_NO_INSTANCE):
+ create_internally_constructor = ''
+ constructors = ''
+ static_initializer = ''
+ reflections = ''
+ value = {'PACKAGE_SECTION': package_string,
+ 'IMPORT_SECTION': imports,
+ 'CLASS_NAME': class_name,
+ 'CLASS_EXTENDS': class_extends,
+ 'CLASS_IMPLEMENTS': class_implements,
+ 'FIELD_SECTION': fields,
+ 'BRIDGE_CLASS_FULL_NAME': bridge_full_class_name,
+ 'CREATE_INTERNALLY_CONSTRUCORS': create_internally_constructor,
+ 'CONSTRUCTORS_SECTION': constructors,
+ 'STATIC_METHOD_SECTION': static_methods,
+ 'METHODS_SECTION': methods,
+ 'REFLECTION_SECTION': reflections,
+ 'STATIC_INITIALIZER': static_initializer}
+ return wrapper_template.substitute(value)
+
+ def GeneratePackageString(self):
+ # Remove the 'internal' folder from internal package.
+ package_name = self._java_data.package_name.replace('.internal', '')
+ return 'package %s;' % (package_name)
+
+ def GenerateWrapperClassName(self):
+ internal_class_name = self._java_data.class_name
+ return internal_class_name.replace('Internal', '')
+
+ def GenerateClassExtends(self):
+ annotations = self._java_data.class_annotations
+ if annotations.has_key(InternalJavaFileData.ANNOTATION_EXTEND_CLASS):
+ to_extend = annotations[InternalJavaFileData.ANNOTATION_EXTEND_CLASS]
+ return ' extends %s ' % (to_extend.replace('.class', ''))
+ return ''
+
+ def GenerateClassImplements(self):
+ annotations = self._java_data.class_annotations
+ if annotations.has_key(InternalJavaFileData.ANNOTATION_IMPL):
+ to_implement = annotations[InternalJavaFileData.ANNOTATION_IMPL]
+ impl_interface = to_implement.replace('.class', '')
+ if impl_interface in CLASSES_TO_BE_PROCESS:
+ impl_interface = MangleInternalNameToWrapperName(impl_interface)
+ return ' implements %s ' % (impl_interface)
+ return ''
+
+ def GenerateClassFields(self):
+ fields_string = ''
+ field_template = Template("""\
+ public final static ${TYPE} ${NAME} = ${VALUE};
+""")
+ for field in self._java_data.fields:
+ value = {'TYPE': field.field_type,
+ 'NAME': field.field_name,
+ 'VALUE': field.field_value}
+ fields_string += field_template.substitute(value)
+ return fields_string
+
+ def FormatConstructorParamsString(self, method):
+ params_string = ''
+ for param_name in method.params:
+ param_type = method.params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ param_type = MangleInternalNameToWrapperName(param_type)
+ params_string += '%s %s' % (param_type, param_name)
+ params_string += ','
+ if params_string.endswith(','):
+ params_string = params_string[0:-1]
+ # For internally created class, additional bridge parameter is needed.
+ if self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_INTERNALLY):
+ if len(params_string) > 0:
+ params_string += ','
+ params_string += 'Object bridge'
+ return params_string
+
+ def FormatInstanceParams(self, method):
+ params_string = ''
+ for param_name in method.params:
+ param_type = method.params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ params_string += ','
+ params_string += '(%s).getBridge()' % (param_name)
+ else:
+ params_string += ',' + param_name
+ return params_string
+
+ def FormatCreateInstanceString(self, method):
+ if self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_EXTERNALLY):
+ create_instance_template = Template("""\
+bridge = ReflectionHelper.createInstance("${STATIC_CONSTRUCTOR_NAME}" \
+${INSTANCE_PARAMS},this)
+""")
+ static_constructor_name = \
+ self.FormatStaticInitializerConstructorName(method)
+ instance_params = self.FormatInstanceParams(method)
+ value = {'STATIC_CONSTRUCTOR_NAME': static_constructor_name,
+ 'INSTANCE_PARAMS': instance_params}
+ return create_instance_template.substitute(value)
+ return ''
+
+ def UnStringifyWrapLines(self, wraplines):
+ # Un-stringify the wrap lines, convert it from string to statement.
+ result_lines = ''
+ lines = wraplines.split('\n')
+ for line in lines:
+ line = line.strip()
+ if line.endswith(','):
+ line = line[0:-1]
+ if not line.startswith('"') and not line.endswith('"'):
+ # TODO: Should be an Error here.
+ continue
+ line = line[1:-1]
+ result_lines += line + '\n'
+ return result_lines
+
+ def ExpandStatementArguments(self, lines, method):
+ # Expand arguments, we assume there are at most 10 arguments.
+ # For example if the '%1' and '%2' in 'super(%1, %2);' should be
+ # substitute by the actual parameter.
+ for arg in range(1, 9):
+ arg_string = "%%%d" % (arg)
+ if arg_string in lines and arg <= len(method.params.keys()):
+ lines = lines.replace(arg_string, method.params.keys()[arg-1])
+ return lines
+
+ def FormatPreWrapLinesString(self, method):
+ annotations = method.method_annotations
+ if not annotations.has_key(Method.ANNOTATION_PRE_WRAPLINE):
+ return ''
+ pre_wrapline = annotations[Method.ANNOTATION_PRE_WRAPLINE]
+ lines = self.UnStringifyWrapLines(pre_wrapline)
+ # Expand the code statement by replacing arguments by parameter.
+ lines = self.ExpandStatementArguments(lines, method)
+ return lines
+
+ def FormatPostWrapLinesString(self, method):
+ annotations = method.method_annotations
+ if not annotations.has_key(Method.ANNOTATION_POST_WRAPLINE):
+ return ''
+ post_wrapline = annotations[Method.ANNOTATION_POST_WRAPLINE]
+ lines = self.UnStringifyWrapLines(post_wrapline)
+ # Expand the code statement.
+ lines = self.ExpandStatementArguments(lines, method)
+ return lines
+
+ def GenerateConstructors(self):
+ constructor_template = Template("""\
+ public ${CLASS_NAME}($CONSTRUCTOR_PARAMS) {
+ ${PRE_WRAP_LINES}
+
+ ${CREATE_INSTANCE_STATEMENT}
+ try {
+ reflectionInit();
+ } catch(Exception e) {
+ ReflectionHelper.handleException(e);
+ }
+
+ ${POST_WRAP_LINES}
+ }
+""")
+ constructors_string = ''
+ for method in self._java_data.methods:
+ if not method.is_constructor:
+ continue
+ constructor = ''
+ class_name = self.GenerateWrapperClassName()
+ constructor_params = self.FormatConstructorParamsString(method)
+ create_instance = self.FormatCreateInstanceString(method)
+ pre_wrap_line = self.FormatPreWrapLinesString(method)
+ post_wrap_line = self.FormatPostWrapLinesString(method)
+ value = {'CLASS_NAME': class_name,
+ 'CONSTRUCTOR_PARAMS': constructor_params,
+ 'CREATE_INSTANCE_STATEMENT': create_instance,
+ 'PRE_WRAP_LINES': pre_wrap_line,
+ 'POST_WRAP_LINES': post_wrap_line }
+ constructor = constructor_template.substitute(value)
+ constructors_string += constructor
+ return constructors_string
+
+ def GenerateCreateInternallyConstructor(self):
+ if not self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_INTERNALLY):
+ return ''
+ constructor_template = Template("""\
+ public ${CLASS_NAME}(Object bridge) {
+ this.bridge = bridge;
+ try {
+ reflectionInit();
+ } catch (Exception e) {
+ ReflectionHelper.handleException(e);
+ }
+ } """)
+ class_name = MangleInternalNameToWrapperName(self._java_data.class_name)
+ return constructor_template.substitute({'CLASS_NAME': class_name})
+
+ def FormatMethodParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ # Mangle class name if the param type is in internal class list.
+ param_type = MangleInternalNameToWrapperName(param_type)
+ param_string += '%s %s' % (param_type, param_name)
+ param_string += ','
+ # Trim the last comma for the method parameter list.
+ if param_string.endswith(','):
+ param_string = param_string[0:-1]
+ return param_string
+
+ def FormatMethodCallParamsString(self, params):
+ param_string = ''
+ for param_name in params:
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ # Mangle parameter string if it is in internal class list.
+ param_name = '(%s).getBridge()' % (param_name)
+ param_string += ', '
+ param_string += param_name
+ return param_string
+
+ def FormatRefectionMethodName(self, method):
+ # FIXME: Update the reflection method name with param types.
+ return '%sMethod' % (method.method_name)
+
+ def FormatReturnStatement(self, method):
+ reflection_method = self.FormatRefectionMethodName(method)
+ call_params = self.FormatMethodCallParamsString(method.params)
+ return_string = ''
+ if method.method_return in CLASSES_TO_BE_PROCESS:
+ return_template = Template("""\
+${RETURN_STRING}ReflectionHelper.getBridgeOrWrapper(\
+ReflectionHelper.invokeMethod(${REFLECTION}, bridge ${CALL_PARAMS}))""")
+ return_string = MangleInternalNameToWrapperName(method.method_return)
+ else:
+ return_template = Template("""\
+${RETURN_STRING}ReflectionHelper.invokeMethod(${REFLECTION},\
+ bridge ${CALL_PARAMS})""")
+ if method.method_return == 'void':
+ return_string = ''
+ else:
+ return_string = 'return (%s)' % (method.method_return)
+ value = {'RETURN_STRING': return_string,
+ 'REFLECTION': reflection_method,
+ 'CALL_PARAMS': call_params}
+ return return_template.substitute(value)
+
+ def FormatMethodString(self, method):
+ method_string = ''
+ method_template = Template("""\
+ public ${RETURN} ${METHOD_NAME}(${METHOD_PARAMS}) {
+ ${RETURN_STATEMENT};
+ }
+
+""")
+ method_return = method.method_return
+ if method_return in CLASSES_TO_BE_PROCESS:
+ method_return = MangleInternalNameToWrapperName(method_return)
+ method_name = method.method_name
+ method_params = self.FormatMethodParamsString(method.params)
+ return_statement = self.FormatReturnStatement(method)
+ value = {'RETURN': method_return,
+ 'METHOD_NAME': method_name,
+ 'METHOD_PARAMS': method_params,
+ 'RETURN_STATEMENT': return_statement}
+ method_string = method_template.substitute(value)
+ return method_string
+
+ def GenerateMethods(self):
+ methods_string = ''
+ # Generate method definitions.
+ for method in self._java_data.methods:
+ if method.is_constructor or method.is_static:
+ continue
+ method_content = self.FormatMethodString(method)
+ methods_string += method_content
+ # Generate Method field lists.
+ method_field_template = Template("""\
+ private Method ${METHOD}Method;
+""")
+ for method in self._java_data.methods:
+ if not method.is_constructor and not method.is_static:
+ value = {'METHOD': method.method_name}
+ methods_string += method_field_template.substitute(value)
+ return methods_string
+
+ def FormatStaticMethodCallParamsType(self, params):
+ params_string = ''
+ for param_name in params:
+ params_string += ','
+ params_string += '%s.class' % (params[param_name])
+ return params_string
+
+ def FormatStaticMethodCallParams(self, params):
+ param_string = ''
+ for param_name in params:
+ param_string += ','
+ param_string += param_name
+ return param_string
+
+ def FormatStaticMethodTemplate(self, class_name, method):
+ method_template = Template("""\
+ public static ${RETURN} ${NAME}(${PARAMS}) {
+ Class> clazz = ReflectionHelper.loadClass(\"${FULL_CLASS_NAME}\");
+ Method method = ReflectionHelper.loadMethod(clazz, \"${NAME}\"\
+${CALL_PARAMS_TYPE});
+ ${RETURN_STATE}ReflectionHelper.invokeMethod(method${CALL_PARAMS});
+ }
+""")
+ return_string = method.method_return
+ name = method.method_name
+ full_class_name = ManagleInternalNameToFullBridgeName(class_name)
+ call_params_type = self.FormatStaticMethodCallParamsType(method.params)
+ call_params = self.FormatStaticMethodCallParams(method.params)
+ params = self.FormatMethodParamsString(method.params)
+ return_state = ''
+ if method.method_return != 'void':
+ return_state = 'return (%s)' % (method.method_return)
+ value = {'RETURN': return_string,
+ 'NAME': name,
+ 'FULL_CLASS_NAME': full_class_name,
+ 'CALL_PARAMS_TYPE': call_params_type,
+ 'CALL_PARAMS': call_params,
+ 'PARAMS': params,
+ 'RETURN_STATE': return_state}
+ return method_template.substitute(value)
+
+ def GenerateStaticMethods(self):
+ methods_string = ''
+ for method in self._java_data.methods:
+ if method.is_static:
+ methods_string += self.FormatStaticMethodTemplate(
+ self._java_data.class_name, method)
+ return methods_string
+
+ def FormatReflectionParamString(self, params):
+ params_string = ''
+ for param_name in params:
+ params_string += ', '
+ param_type = params[param_name]
+ if param_type in CLASSES_TO_BE_PROCESS:
+ mangle = ManagleInternalNameToFullBridgeName(param_type)
+ param_type = 'clazz.getClassLoader().loadClass(\"%s\")' % (mangle)
+ params_string += param_type
+ else:
+ params_string += "%s.class" % (params[param_name])
+ return params_string
+
+ def GenerateReflectionInitString(self):
+ ref_methods_string = ''
+ ref_method_template = Template("""\
+ ${METHOD}Method = clazz.getMethod(\"${METHOD}Super\"${PARAMS});
+""")
+ for method in self._java_data.methods:
+ if method.is_constructor or method.is_static:
+ continue
+ params_string = self.FormatReflectionParamString(method.params)
+ value = { 'METHOD': method.method_name,
+ 'PARAMS': params_string}
+ ref_methods_string += ref_method_template.substitute(value)
+
+ ref_init_template = Template("""\
+ private void reflectionInit() throws NoSuchMethodException,
+ ClassNotFoundException {
+ Class> clazz = wrapper.getClass();
+${REF_METHODS}
+ }
+""")
+ value = {'REF_METHODS': ref_methods_string}
+ ref_init_string = ref_init_template.substitute(value)
+ return ref_init_string
+
+ def FormatStaticInitializerParamsList(self, method):
+ params_string = ''
+ for param_name in method.params:
+ params_string += method.params[param_name] + '.class'
+ params_string += ','
+ return params_string
+
+ def FormatStaticInitializer(self, method):
+ static_initializer_template = Template("""\
+ ReflectionHelper.registerConstructor(\"${CONSTRUCTOR_NAME}\", \
+\"${FULL_CLASS_NAME}\", ${PARAM_LIST} Object.class};
+""")
+ constructor_name = self.FormatStaticInitializerConstructorName(method)
+ full_class_name = ManagleInternalNameToFullBridgeName(
+ self._java_data.class_name)
+ params_list = self.FormatStaticInitializerParamsList(method)
+ value = {"CONSTRUCTOR_NAME": constructor_name,
+ "FULL_CLASS_NAME": full_class_name,
+ "PARAM_LIST": params_list}
+ return static_initializer_template.substitute(value)
+
+ def GenerateStaticInitializerString(self):
+ if not self._java_data.class_annotations.has_key(
+ InternalJavaFileData.ANNOTATION_CREATE_EXTERNALLY):
+ return ''
+ static_initializer_template = Template("""\
+ static {
+${STATIC_INITIALIZER_LIST}
+ }
+""")
+ static_initializer_list = ''
+ for method in self._java_data.methods:
+ if method.is_constructor:
+ static_initializer_list += self.FormatStaticInitializer(method)
+ value = {'STATIC_INITIALIZER_LIST': static_initializer_list}
+ return static_initializer_template.substitute(value)
+
+
+class InternalJavaFileData(object):
+ """Data class stores the generator information of internal class."""
+ ANNOTATION_CREATE_INTERNALLY = 'createInternally'
+ ANNOTATION_CREATE_EXTERNALLY = 'createExternally'
+ ANNOTATION_EXTEND_CLASS = 'extendClass'
+ ANNOTATION_NO_INSTANCE = 'noInstance'
+ ANNOTATION_INSTANCE = 'instance'
+ ANNOTATION_IMPL = 'impl'
+
+ def __init__(self):
+ self._class_name = ''
+ self._class_type = '' # class or interface
+ self._class_annotations = {}
+ self._methods = []
+ self._fields = []
+ self._imports = []
+ self._package_name = ''
+
+ @property
+ def class_name(self):
+ return self._class_name
+
+ @property
+ def class_type(self):
+ return self._class_type
+
+ @property
+ def class_annotations(self):
+ return self._class_annotations
+
+ @property
+ def methods(self):
+ return self._methods
+
+ @property
+ def fields(self):
+ return self._fields
+
+ @property
+ def imports(self):
+ return self._imports
+
+ @property
+ def package_name(self):
+ return self._package_name
+
+ def SetClassContent(self, content):
+ self.ExtractPackageName(content)
+ self.ExtractImports(content)
+ self.ExtractClassProperties(content)
+ self.ExtractMethods(content)
+ self.ExtractFields(content)
+
+ def ExtractPackageName(self, java_content):
+ package_re = re.compile('\s*package\s+(?P[a-zA-Z0-9._]+)\s*;')
+ for match in re.finditer(package_re, java_content):
+ self._package_name = match.group('package')
+
+ def ShouldIgnoreImport(self, imported):
+ # Determine whether the import rule should be ignored for generated code.
+ # TODO: Currently we only use a blacklist to filter the import rule.
+ if imported.startswith('org.xwalk.core.internal'):
+ return True
+ if imported.startswith('org.chromium'):
+ return True
+
+ def ExtractImports(self, java_content):
+ imports_re = re.compile('\s*import\s+(?P[a-zA-Z0-9._*]+)\s*;')
+ for match in re.finditer(imports_re, java_content):
+ imported = match.group('imported')
+ if not self.ShouldIgnoreImport(imported):
+ self._imports.append(imported)
+
+ def ExtractClassProperties(self, java_content):
+ class_re = re.compile('@XWalkAPI\(?'
+ '(?P[a-zA-Z0-9.,=\s]*)\)?'
+ '\s*public\s+(?P(class|interface))\s+'
+ '(?P[a-zA-Z0-9]*)')
+ for match in re.finditer(class_re, java_content):
+ annotation_content = match.group('annotation_content')
+ self._class_name = match.group('class_name')
+ self._class_type = match.group('type')
+ self.ParseClassAnnotations(annotation_content)
+
+ def ParseClassAnnotations(self, annotation):
+ """Class annotation contains the following optional attributes:
+ 'extendClass' - The class have to extend
+ 'createExternally' - boolean
+ 'craeteInternally' - boolean
+ 'noInstance' - boolean
+ 'isConst' - boolean
+ 'impl' - Class to impl
+ 'instance - instance'"""
+ extend_class_re = re.compile('extendClass\s*=\s*'
+ '(?P[a-zA-Z0-9.]+)')
+ for match in re.finditer(extend_class_re, annotation):
+ extend_class = match.group('extend_class')
+ self._class_annotations['extendClass'] = extend_class
+
+ create_internally_re = re.compile('createInternally\s*=\s*'
+ '(?P(true|false))')
+ for match in re.finditer(create_internally_re, annotation):
+ create_internally = match.group('create_internally')
+ if create_internally == 'true':
+ self._class_annotations['createInternally'] = True
+ elif create_internally == 'false':
+ self._class_annotations['createInternally'] = False
+
+ create_externally_re = re.compile('createExternally\s*=\s*'
+ '(?P(true|false))')
+ for match in re.finditer(create_externally_re, annotation):
+ create_externally = match.group('create_externally')
+ if create_externally == 'true':
+ self._class_annotations['createExternally'] = True
+ elif create_externally == 'false':
+ self._class_annotations['createExternally'] = False
+
+ no_instance_re = re.compile('noInstance\s*=\s*'
+ '(?P(true|false))')
+ for match in re.finditer(no_instance_re, annotation):
+ no_instance = match.group('no_instance')
+ if no_instance == 'true':
+ self._class_annotations['noInstance'] = True
+ elif no_instance == 'false':
+ self._class_annotations['noInstance'] = False
+
+ is_const_re = re.compile('isConst\s*=\s*'
+ '(?P(true|false))')
+ for match in re.finditer(is_const_re, annotation):
+ is_const = match.group('is_const')
+ if is_const == 'true':
+ self._class_annotations['isConst'] = True
+ elif is_const == 'false':
+ self._class_annotations['isConst'] = False
+
+ impl_re = re.compile('impl\s*=\s*'
+ '(?P[a-zA-Z0-9.]+)')
+ for match in re.finditer(impl_re, annotation):
+ impl = match.group('impl')
+ self._class_annotations['impl'] = impl
+
+ instance_re = re.compile('instance\s*=\s*'
+ '(?P[a-zA-Z0-9.]+)')
+ for match in re.finditer(instance_re, annotation):
+ instance = match.group('instance')
+ self._class_annotations['instance'] = instance
+
+ def ExtractMethods(self, java_content):
+ constructor_re = re.compile('@XWalkAPI\(?'
+ '(?P[a-zA-Z0-9%,\s\(\)\{\};._"=]*)\)?'
+ '\s*public\s(?P[a-zA-Z0-9]+)\('
+ '(?P[a-zA-Z0-9\s,]*)\)')
+ for match in re.finditer(constructor_re, java_content):
+ method_annotation = match.group('method_annotation')
+ method_name = match.group('method_name')
+ method_params = match.group('method_params')
+ method = Method(True, False, method_name, None,
+ method_params, method_annotation)
+ self._methods.append(method)
+
+ method_re = re.compile('@XWalkAPI\(?'
+ '(?P[a-zA-Z0-9%,\s\(\)\{\};._"=]*)\)?'
+ '\s*public\s+(?P[a-zA-Z0-9]+)\s+'
+ '(?P[a-zA-Z0-9]+)\('
+ '(?P[a-zA-Z0-9\s,\<\>]*)\)')
+ for match in re.finditer(method_re, java_content):
+ method_annotation = match.group('method_annotation')
+ method_name = match.group('method_name')
+ method_params = match.group('method_params')
+ method_return = match.group('method_return')
+ method = Method(False, False, method_name, method_return, method_params,
+ method_annotation)
+ self._methods.append(method)
+
+ method_re = re.compile('@XWalkAPI\(?'
+ '(?P[a-zA-Z0-9%,\s\(\)\{\};._"=]*)\)?'
+ '\s*public\s+static\s+(synchronized\s+)*'
+ '(?P[a-zA-Z0-9]+)\s+'
+ '(?P[a-zA-Z0-9]+)\('
+ '(?P[a-zA-Z0-9\s,\<\>]*)\)')
+ for match in re.finditer(method_re, java_content):
+ method_annotation = match.group('method_annotation')
+ method_name = match.group('method_name')
+ method_params = match.group('method_params')
+ method_return = match.group('method_return')
+ method = Method(False, True, method_name, method_return, method_params,
+ method_annotation)
+ self._methods.append(method)
+
+
+
+ def ExtractFields(self, java_content):
+ field_re = re.compile('@XWalkAPI\s*public\s+static\s+final\s+'
+ '(?P[a-zA-Z0-9_]+)\s+'
+ '(?P[a-zA-Z0-9_]+)\s*=\s*'
+ '(?P[a-zA-Z0-9-_"]+)\s*;')
+ for match in re.finditer(field_re, java_content):
+ field_type = match.group('field_type')
+ field_name = match.group('field_name')
+ field_value = match.group('field_value')
+ field_object = Field(field_type, field_name, field_value)
+ self._fields.append(field_object)
+
+
+def PerformSerialize(output_path, generator):
+ # Serialize the code.
+ file_name = os.path.join(output_path, generator.GetGeneratedClassFileName())
+ file_handle = open(file_name, 'w')
+ file_handle.write(generator.GetGeneratedCode())
+ file_handle.close()
+ print '%s has been generated!' % (file_name)
+
+
+def GenerateBindingForJavaFile(file_name, bridge_output, wrap_output):
+ try:
+ file_handle = open(file_name, 'r')
+ file_content = file_handle.read()
+ file_handle.close()
+ except Exception:
+ print 'Error reading input Java file, please check.'
+ return
+
+ java_data = InternalJavaFileData()
+ java_data.SetClassContent(file_content)
+
+ if java_data.class_type == 'interface':
+ interface_generator = InterfaceGenerator(java_data)
+ interface_generator.RunTask()
+ PerformSerialize(wrap_output, interface_generator)
+ else:
+ # Generate Bridge code.
+ bridge_generator = BrigdeGenerator(java_data)
+ bridge_generator.RunTask()
+ # Serialize.
+ PerformSerialize(bridge_output, bridge_generator)
+ # Generate Wrapper code.
+ wrapper_generator = WrapperGenerator(java_data)
+ wrapper_generator.RunTask()
+ PerformSerialize(wrap_output, wrapper_generator)
+
+
+def GenerateBindingForJavaDirectory(input_dir, bridge_output, wrap_output):
+ for input_file in os.listdir(input_dir):
+ input_class_name = input_file.replace('.java', '')
+ if input_class_name in CLASSES_TO_BE_PROCESS:
+ input_file = os.path.join(input_dir, input_file)
+ print 'Generate bridge and wrapper code for %s' % (input_file)
+ GenerateBindingForJavaFile(input_file, bridge_output, wrap_output)
+
+
+def main(argv):
+ usage = """Usage: %prog [OPTIONS]
+This script can generate bridge and wrap source files for given file or
+directory. Either \'input_java\' is provided as single source file or
+\'input_dir\' is provided as directory containing source files.
+ """
+ option_parser = optparse.OptionParser(usage=usage)
+ option_parser.add_option('--input_java',
+ help='Input source file.')
+ option_parser.add_option('--input_dir',
+ help= ('Input source file directory which contains'
+ 'input files'))
+ option_parser.add_option('--bridge_output',
+ help=('Output directory where the bridge code'
+ 'is placed.'))
+ option_parser.add_option('--wrap_output',
+ help=('Output directory where the wrap code'
+ 'is placed.'))
+ options, _ = option_parser.parse_args(argv)
+ if not options.input_java and not options.input_dir:
+ print('Error: Must specify input.')
+ return 1
+ if options.input_java:
+ GenerateBindingForJavaFile(options.input_java,
+ options.bridge_output, options.wrap_output)
+ elif options.input_dir:
+ GenerateBindingForJavaDirectory(options.input_dir,
+ options.bridge_output, options.wrap_output)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/tools/reflection_generator/src/org/xwalk/reflection/generator/Generator.java b/tools/reflection_generator/src/org/xwalk/reflection/generator/Generator.java
new file mode 100644
index 0000000000..201c197584
--- /dev/null
+++ b/tools/reflection_generator/src/org/xwalk/reflection/generator/Generator.java
@@ -0,0 +1,986 @@
+package org.xwalk.reflection.generator;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.List;
+
+import org.xwalk.core.internal.XWalkAPI;
+import org.xwalk.core.internal.XWalkJavascriptResultHandlerInternal;
+import org.xwalk.core.internal.XWalkNavigationHistoryInternal;
+import org.xwalk.core.internal.XWalkPreferencesInternal;
+import org.xwalk.core.internal.XWalkUIClientInternal;
+import org.xwalk.core.internal.XWalkJavascriptResultInternal;
+import org.xwalk.core.internal.XWalkNavigationItemInternal;
+import org.xwalk.core.internal.XWalkResourceClientInternal;
+import org.xwalk.core.internal.XWalkViewInternal;
+
+public class Generator {
+ private final static String INTERNAL_CLASS_SUFFIX = "Internal";
+ private final static String BRIDGE_CLASS_SUFFIX = "Bridge";
+ private final static String WRAPPER_PACKAGE = "org.xwalk.core";
+ private final static String[] PARAM_NAMES = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"};
+ private final static Class>[] CLASSES_TO_REFLECTIONIZE = {
+ XWalkJavascriptResultHandlerInternal.class,
+ XWalkNavigationHistoryInternal.class,
+ XWalkPreferencesInternal.class,
+ XWalkUIClientInternal.class,
+ XWalkJavascriptResultInternal.class,
+ XWalkNavigationItemInternal.class,
+ XWalkResourceClientInternal.class,
+ XWalkViewInternal.class
+ };
+ private final static Class>[] REFLECTION_CLASSES = {
+ Method.class,
+ Constructor.class
+ };
+
+ enum TargetType {
+ REFLECTION_LAYER_INTERNAL,
+ REFLECTION_LAYER_BRIDGE,
+ REFLECTION_LAYER_WRAPPER
+ };
+ private static Set> usedClassSet = new HashSet>();
+ private static Set usedMethodSet = new HashSet();
+ private static Set> usedConstructorSet = new HashSet>();
+ private static boolean createReflection;
+
+ /**
+ * @param args
+ */
+ @SuppressWarnings("unchecked")
+ public static void main(String[] argv) {
+ if (argv.length < 3) {
+ throw new RuntimeException("Invalid parameters");
+ }
+ String wrapperPackage = WRAPPER_PACKAGE;
+ // TODO: remove || true
+ createReflection = Boolean.parseBoolean(argv[0]) || true;
+ String internalPackagePath = argv[1];
+ String intermediatePath = argv[2];
+
+ File output = new File(intermediatePath);
+ File input = new File(internalPackagePath);
+ if (!output.isDirectory()) {
+ throw new RuntimeException("Intermediate folder not exist");
+ }
+ for (int i = 0; i < CLASSES_TO_REFLECTIONIZE.length; i++) {
+ Class> clazz = CLASSES_TO_REFLECTIONIZE[i];
+ String internalPackage = clazz.getPackage().getName();
+ String className = clazz.getSimpleName();
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (annotation == null) {
+ throw new RuntimeException("Class to be reflectionized must has XWalkAPI annotation :" + className);
+ }
+ File internalPackageDir = new File(input, internalPackage.replace('.', '/'));
+ if (!internalPackageDir.isDirectory()) {
+ throw new RuntimeException("internal package folder not exist");
+ }
+ File wrapperPackageDir = new File(output, "wrapper" + "/src/" + wrapperPackage.replace('.', '/'));
+ File bridgePackageDir = new File(output, "bridge" + "/src/" + internalPackage.replace('.', '/'));
+ if (!wrapperPackageDir.isDirectory()) wrapperPackageDir.mkdirs();
+ if (!bridgePackageDir.isDirectory()) bridgePackageDir.mkdirs();
+ if (!className.endsWith(INTERNAL_CLASS_SUFFIX)) {
+ throw new RuntimeException("Class to be reflectionized must be named end with Internal :" + className);
+ }
+ String baseClassName = className.substring(0, className.length() - INTERNAL_CLASS_SUFFIX.length());
+ File wrapperFile = new File(wrapperPackageDir, baseClassName + ".java");
+ File internalFile = new File(internalPackageDir, className + ".java");
+ BufferedWriter wrapperWriter = null;
+ BufferedWriter bridgeWriter = null;
+ BufferedReader internalReader = null;
+ try {
+ usedClassSet.clear();
+ usedMethodSet.clear();
+ usedConstructorSet.clear();
+ InputStreamReader isr = new InputStreamReader(new FileInputStream(internalFile));
+ internalReader = new BufferedReader(isr);
+ List imports = getImportsInInternal(internalReader);
+ wrapperWriter = new BufferedWriter(new FileWriter(wrapperFile));
+ if (clazz.isInterface()) {
+ parseInterface(clazz, wrapperPackage, imports, wrapperWriter);
+ } else {
+ File bridgeFile = new File(bridgePackageDir, baseClassName + "Bridge.java");
+ bridgeWriter = new BufferedWriter(new FileWriter(bridgeFile));
+ parseClass(clazz, wrapperPackage, imports, wrapperWriter, bridgeWriter);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ if (internalReader != null) internalReader.close();
+ if (wrapperWriter != null) wrapperWriter.close();
+ if (bridgeWriter != null) bridgeWriter.close();
+ } catch (IOException e) {}
+ }
+ }
+ System.exit(0);
+ }
+
+ private static List getImportsInInternal(BufferedReader internalReader) throws IOException {
+ String line = internalReader.readLine();
+ List ret = new ArrayList();
+ while(line != null) {
+ if (line.startsWith("import ")) {
+ ret.add(line.trim());
+ }
+ line = internalReader.readLine();
+ }
+ return ret;
+ }
+
+ public static void parseClass(Class> clazz, String wrapperPackage,
+ List imports, Writer wrapperWriter, Writer bridgeWriter) throws IOException {
+ String className = clazz.getSimpleName();
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (annotation == null || !className.endsWith(INTERNAL_CLASS_SUFFIX)) {
+ throw new RuntimeException("Class to be reflectionized must end with Internal");
+ }
+ StringBuilder bridge = new StringBuilder();
+ StringBuilder wrapper = new StringBuilder();
+ generateHeader(clazz, bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ generateHeader(clazz, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ Constructor>[] constructors = clazz.getDeclaredConstructors();
+ boolean hasConstructor = false;
+ // If the class declares noInstance or createInternally, it doesn't need constructor besides
+ // the ones with bridge or wrapper.
+ if (!annotation.noInstance() && !annotation.createInternally()) {
+ for (Constructor> constructor : constructors) {
+ if (constructor.getAnnotation(XWalkAPI.class) != null) {
+ usedConstructorSet.add(constructor);
+ appendConstrucor(clazz, constructor, bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ appendConstrucor(clazz, constructor, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ hasConstructor = true;
+ }
+ }
+ if (!hasConstructor) {
+ appendConstrucor(clazz, null, bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ appendConstrucor(clazz, null, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ }
+ }
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getAnnotation(XWalkAPI.class) != null) {
+ appendConst(field, wrapper);
+ }
+ }
+ Method[] methods = clazz.getDeclaredMethods();
+ for (Method method : methods) {
+ if (method.getAnnotation(XWalkAPI.class) != null) {
+ usedMethodSet.add(method);
+ appendMethod(method, annotation, false, bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ appendMethod(method, annotation, false, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ }
+ }
+ generateFooter(clazz, bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ generateFooter(clazz, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ InsertPackageImport(clazz.getPackage().getName(), wrapperPackage, imports,
+ bridge, TargetType.REFLECTION_LAYER_BRIDGE);
+ InsertPackageImport(wrapperPackage, clazz.getPackage().getName(), imports,
+ wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+
+ wrapperWriter.write(wrapper.toString());
+ bridgeWriter.write(bridge.toString());
+ }
+
+ public static void parseInterface(Class> clazz, String wrapperPackage,
+ List imports, Writer wrapperWriter) throws IOException {
+ String className = clazz.getSimpleName();
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (annotation == null || !className.endsWith(INTERNAL_CLASS_SUFFIX)) {
+ throw new RuntimeException("Class to be reflectionized must end with Internal");
+ }
+ StringBuilder wrapper = new StringBuilder();
+ generateHeader(clazz, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ Method[] methods = clazz.getDeclaredMethods();
+ for (Method method : methods) {
+ if (method.getAnnotation(XWalkAPI.class) != null) {
+ appendMethod(method, annotation, true, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ }
+ }
+ generateFooter(clazz, wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ InsertPackageImport(wrapperPackage, clazz.getPackage().getName(), imports,
+ wrapper, TargetType.REFLECTION_LAYER_WRAPPER);
+ wrapperWriter.write(wrapper.toString());
+ }
+
+ private static void InsertPackageImport(String packageName, String reflectionPackage,
+ List imports, StringBuilder builder, TargetType type) {
+ for (String importString : imports) {
+ String[] segs = importString.split(" ");
+ if (segs.length == 2) {
+ try {
+ Class> clazz = Class.forName(segs[1].replace(";", ""));
+ if (usedClassSet.contains(clazz)) {
+ builder.insert(0, importString + "\n");
+ }
+ } catch (ClassNotFoundException e) {
+ }
+ }
+ }
+ if (!createReflection) {
+ String suffix = "";
+ if (type == TargetType.REFLECTION_LAYER_WRAPPER) {
+ suffix = BRIDGE_CLASS_SUFFIX;
+ }
+ for (int i = 0 ; i < CLASSES_TO_REFLECTIONIZE.length; i++) {
+ Class> clazz = CLASSES_TO_REFLECTIONIZE[i];
+ if (!clazz.isInterface()) {
+ String className =
+ clazz.getSimpleName().replace(INTERNAL_CLASS_SUFFIX, suffix);
+ builder.insert(0, "import " + reflectionPackage + "." + className + ";\n");
+ }
+ }
+ }
+ for (Class> clazz : REFLECTION_CLASSES) {
+ builder.insert(0, "import " + clazz.getPackage().getName() + "." + clazz.getSimpleName() + ";\n");
+ }
+ builder.insert(0, "package " + packageName + ";\n");
+ }
+
+ private static void appendConstrucor(Class> clazz, Constructor> constructor,
+ StringBuilder builder, TargetType target) {
+ String internal = clazz.getSimpleName();
+ String bridge = internal.replace(INTERNAL_CLASS_SUFFIX, BRIDGE_CLASS_SUFFIX);
+ String wrapper = internal.replace(INTERNAL_CLASS_SUFFIX, "");
+ if (createReflection) {
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ wrapper = "Object";
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ bridge = "Object";
+ }
+ }
+ String declare = "";
+ String use = "";
+ String comma = "";
+ String preWrapper = "";
+ String postWrapper = "";
+ XWalkAPI methodAnnotation = constructor.getAnnotation(XWalkAPI.class);
+ for (String line : methodAnnotation.preWrapperLines()) {
+ preWrapper += " " + line + "\n";
+ }
+ for (String line : methodAnnotation.postWrapperLines()) {
+ postWrapper += " " + line + "\n";
+ }
+ for (int i = 1; i <= PARAM_NAMES.length; i++) {
+ preWrapper = preWrapper.replace("%" + i, PARAM_NAMES[i-1]);
+ postWrapper = postWrapper.replace("%" + i, PARAM_NAMES[i-1]);
+ }
+ if (constructor != null) {
+ String[] paramsStrings =
+ getMethodParamsStrings(constructor.getGenericParameterTypes(), target, false, PARAM_NAMES);
+ declare = paramsStrings[0];
+ use = paramsStrings[1];
+ if (!use.isEmpty()) comma = ", ";
+ }
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ /*
+ public clazzBridge(int a, clazz wrapper) {
+ super(a);
+ this.wrapper = wrapper;
+ }
+ */
+ builder.append(String.format(
+ " public %2$s(%3$s%5$s%1$s wrapper) {\n" +
+ " super(%4$s);\n" +
+ " this.wrapper = wrapper;\n" +
+ " try { reflectionInit(); } catch (Exception e) { ReflectionHelper.handleException(e); }\n" +
+ " }\n",
+ wrapper, bridge, declare, use, comma));
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ /* No reflection
+ XWalkClient(int a) {
+ bridge = new XWalkClientBridge(a, this);
+ }
+ */
+ /* With reflection
+ XWalkClient(int a) {
+ bridge = ReflectionHelper.createInstance("XWalkClientBridgeInt", a, this);
+ }
+ */
+ String bridgeCreation = "";
+ if (createReflection) {
+ bridgeCreation = String.format(
+ "bridge = ReflectionHelper.createInstance(\"%1$s\", %2$s%3$sthis);",
+ generateConstructorName(constructor), use, comma);
+ } else {
+ bridgeCreation = String.format("bridge = new %1$s(%2$s%3$sthis);", bridge, use, comma);
+ }
+ builder.append(String.format(
+ " public %1$s(%3$s) {\n" +
+ "%4$s" +
+ " %2$s;\n" +
+ " try { reflectionInit(); } catch (Exception e) { ReflectionHelper.handleException(e); }\n" +
+ "%5$s" +
+ " }\n",
+ wrapper, bridgeCreation, declare,
+ preWrapper, postWrapper));
+ }
+ }
+
+ private static void generateHeader(
+ Class> clazz, StringBuilder builder, TargetType target) {
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ boolean isInterface = clazz.isInterface();
+ String internal = clazz.getSimpleName();
+ String bridge = internal.replace(INTERNAL_CLASS_SUFFIX, BRIDGE_CLASS_SUFFIX);
+ String wrapper = internal.replace(INTERNAL_CLASS_SUFFIX, "");
+ if (createReflection) {
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ wrapper = "Object";
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ bridge = "Object";
+ }
+ }
+ boolean isStatic = annotation.noInstance();
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ if (isStatic) {
+ /*
+ public class clazzBridge extends clazzInternal {
+ */
+ builder.append(String.format(
+ "public class %1$s extends %2$s {\n" +
+ " private final static String WRAPPER_CLASS = \"%3$s\";\n",
+ bridge, internal, WRAPPER_PACKAGE + "." + wrapper));
+ } else {
+ /*
+ public class clazzBridge extends clazzInternal {
+ private clazz wrapper;
+ clazz getWrapper() {
+ return wrapper;
+ }
+ */
+ builder.append(String.format(
+ "public class %2$s extends %3$s {\n" +
+ " private final static String WRAPPER_CLASS = \"%4$s\";\n" +
+ " private %1$s wrapper;\n" +
+ " public %1$s getWrapper() {\n" +
+ " return wrapper;\n" +
+ " }\n",
+ wrapper, bridge, internal, WRAPPER_PACKAGE + "." + wrapper));
+ if (annotation.createInternally()) {
+ /* No reflection
+ private clazzInternal internal = null;
+ clazzBridge(clazzInternal internal) {
+ this.internal = internal;
+ this.wrapper = new clazz(this);
+ }
+ */
+ /* With reflection
+ private clazzInternal internal = null;
+ clazzBridge(clazzInternal internal) {
+ this.internal = internal;
+ this.wrapper = (clazz)ReflectionHelper.createInstance(bridge, this);
+ }
+ */
+ String wrapperCreation = "";
+ if (createReflection) {
+ wrapperCreation = String.format(
+ "this.wrapper = ReflectionHelper.createInstance(\"%1$s\", this);",
+ generateConstructorName(clazz));
+ } else {
+ wrapperCreation = String.format("this.wrapper = new %1$s(this);", wrapper);
+ }
+ builder.append(String.format(
+ " private %3$s internal = null;\n" +
+ " %2$s(%3$s internal) {\n" +
+ " this.internal = internal;\n" +
+ " %1$s\n" +
+ " try { reflectionInit(); } catch (Exception e) { ReflectionHelper.handleException(e); }\n" +
+ " }\n",
+ wrapperCreation, bridge, internal));
+ }
+ }
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ if (isInterface) {
+ /*
+ public interface XWalkInterface {
+ */
+ builder.append(String.format("public interface %1$s {\n", wrapper));
+ } else if (isStatic) {
+ /*
+ public class XWalkPreference {
+ */
+ builder.append(String.format("public class %1$s {\n", wrapper));
+ } else {
+ /*
+ public class XWalkClient {
+ private XWalkClientBridge bridge;
+ public XWalkClient(XWalkClientBridge bridge) {
+ this.bridge = bridge;
+ }
+ public XWalkClientBridge getBridge() {
+ return bridge;
+ }
+ */
+ String extAndImpl = "";
+ Class> ext = annotation.extendClass();
+ if (ext != Object.class) {
+ usedClassSet.add(ext);
+ extAndImpl = "extends " + getTypeString(null, ext, true) + " ";
+ }
+ Class> impl = annotation.impl();
+ if (impl != Object.class) {
+ extAndImpl += "implements " +
+ getTypeString(null, impl, true).replace(INTERNAL_CLASS_SUFFIX, "") + " ";
+ }
+ builder.append(String.format(
+ "public class %1$s %3$s{\n" +
+ " private final static String BRIDGE_CLASS = \"%4$s\";\n" +
+ " private %2$s bridge;\n" +
+ " public %2$s getBridge() {\n" +
+ " return bridge;\n" +
+ " }\n",
+ wrapper, bridge, extAndImpl, clazz.getPackage().getName() + "." + clazz.getSimpleName()));
+ if (!annotation.createExternally()) {
+ builder.append(String.format(
+ " public %1$s(%2$s bridge) {\n" +
+ " this.bridge = bridge;\n" +
+ " try { reflectionInit(); } catch (Exception e) { ReflectionHelper.handleException(e); }\n" +
+ " }\n",
+ wrapper, bridge, extAndImpl));
+ }
+ }
+ }
+ }
+
+ private static void appendMethod(
+ Method method, XWalkAPI annotation, boolean isInterface, StringBuilder builder, TargetType target) {
+ String name = method.getName();
+ String methodName = generateMethodName(method);
+ Type retType = method.getGenericReturnType();
+ Class> retClazz = method.getReturnType();
+ String modifierString = "public";
+ String retTypeString = getTypeString(retType, retClazz, true);
+ retTypeString = transferType(retTypeString, retClazz, target);
+ String returnTerm = retTypeString.equals("void") ? "" : "return ";
+ String preWrapper = "";
+ String postWrapper = "";
+ XWalkAPI methodAnnotation = method.getAnnotation(XWalkAPI.class);
+ for (String line : methodAnnotation.preWrapperLines()) {
+ preWrapper += " " + line + "\n";
+ }
+ for (String line : methodAnnotation.postWrapperLines()) {
+ postWrapper += " " + line + "\n";
+ }
+ for (int i = 1; i <= PARAM_NAMES.length; i++) {
+ preWrapper.replace("%" + i, PARAM_NAMES[i-1]);
+ postWrapper.replace("%" + i, PARAM_NAMES[i-1]);
+ }
+ String[] paramsStrings = getMethodParamsStrings(method.getGenericParameterTypes(), target, false, PARAM_NAMES);
+ boolean isStatic = (method.getModifiers() & Modifier.STATIC) != 0;
+ String retValue = "";
+ if (isStatic) modifierString += " static";
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ /*
+ public void work(int a) {
+ wrapper.work(a);
+ }
+
+ public void workSuper(int a) {
+ super.work(a);
+ }
+ */
+ /* In case the class has XWalkAPI annotation with createInternally, it will be
+ public void work(int a) {
+ wrapper.work(a);
+ }
+ public void workSuper(int a) {
+ if (internal == null) {
+ super.work(a);
+ } else {
+ internal.work(a);
+ }
+ }
+ */
+ /* In case the method is static, it will be
+ public static void work(int a) {
+ clazzInternal.work(a);
+ }
+ */
+ String[] paramsStringsWrapper = getMethodParamsStrings(method.getGenericParameterTypes(), target, true, PARAM_NAMES);
+ if (isStatic) {
+ String internalClass = method.getDeclaringClass().getSimpleName();
+ String v = String.format("%1$s.%2$s(%3$s)", internalClass, name, paramsStringsWrapper[1]);
+ retValue = transferValueExpress(retType, v, true, true, target);
+ } else {
+ String v = "";
+ if (createReflection) {
+ String params = paramsStringsWrapper[1];
+ if (!params.isEmpty()) params = ", " + params;
+ v = String.format("ReflectionHelper.invokeMethod(%1$s, wrapper%2$s)", methodName, params);
+ } else {
+ v = String.format("wrapper.%1$s(%2$s)", name, paramsStringsWrapper[1]);
+ }
+ retValue = transferValueExpress(retType, v, true, true, target);
+ }
+ // BridgeCall
+ builder.append(String.format(
+ " %5$s %2$s %1$s(%4$s) {\n" +
+ " %3$s%6$s;\n" +
+ " }\n",
+ name, retTypeString, returnTerm,
+ paramsStringsWrapper[0], modifierString, retValue
+ ));
+ if (!isStatic) {
+ // SuperCall
+ String v = String.format("super.%1$s(%2$s)", name, paramsStrings[1]);
+ retValue = transferValueExpress(retType, v, false, true, target);
+ if (annotation.createInternally()) {
+ String internalV = String.format("internal.%1$s(%2$s)", name, paramsStrings[1]);
+ String internalRetValue = transferValueExpress(retType, internalV, false, true, target);
+ builder.append(String.format(
+ " %5$s %2$s %1$sSuper(%4$s) {\n" +
+ " if (internal == null) {\n" +
+ " %3$s%6$s;\n" +
+ " } else {\n" +
+ " %3$s%7$s;\n" +
+ " }\n" +
+ " }\n",
+ name, retTypeString, returnTerm,
+ paramsStrings[0], modifierString,
+ retValue, internalRetValue
+ ));
+ } else {
+ builder.append(String.format(
+ " %5$s %2$s %1$sSuper(%4$s) {\n" +
+ " %3$s%6$s;\n" +
+ " }\n",
+ name, retTypeString, returnTerm,
+ paramsStrings[0], modifierString, retValue
+ ));
+ }
+ }
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ /*
+ public void work(int a) {
+ bridge.workSuper(a);
+ }
+ */
+ if (isInterface) {
+ builder.append(String.format(
+ " %4$s %2$s %1$s(%3$s);\n",
+ name, retTypeString, paramsStrings[0], modifierString
+ ));
+ } else {
+ String staticTerm = "";
+ String bridgeClass = transferType(null, method.getDeclaringClass(), target);
+ if (isStatic) {
+ if (createReflection) {
+ String paramTypes = generateParamTypesFromMethod(method, null, target);
+ staticTerm = String.format(
+ " Class> clazz = ReflectionHelper.loadClass(\"%1$s\");\n" +
+ " Method method = ReflectionHelper.loadMethod(clazz, \"%2$s\"%3$s);\n",
+ generateFullClassName(method.getDeclaringClass(), target),
+ name, paramTypes);
+ String v = String.format(
+ "ReflectionHelper.invokeMethod(method, null, %1$s)", paramsStrings[1]);
+ retValue = transferValueExpress(retType, v, false, true, target);
+ } else {
+ String v = String.format("%1$s.%2$s(%3$s)", bridgeClass, name, paramsStrings[1]);
+ retValue = transferValueExpress(retType, v, false, true, target);
+ }
+ } else {
+ String v = "";
+ if (createReflection) {
+ String params = paramsStrings[1];
+ if (!params.isEmpty()) params = ", " + params;
+ v = String.format("ReflectionHelper.invokeMethod(%1$s, bridge%2$s)", methodName, params);
+ } else {
+ v = String.format("bridge.%1$sSuper(%2$s)", name, paramsStrings[1]);
+ }
+ retValue = transferValueExpress(retType, v, false, true, target);
+ }
+ builder.append(String.format(
+ " %5$s %2$s %1$s(%4$s) {\n" +
+ "%7$s" +
+ "%9$s" +
+ " %3$s%6$s;\n" +
+ "%8$s" +
+ " }\n",
+ name, retTypeString, returnTerm, paramsStrings[0], modifierString, retValue,
+ preWrapper, postWrapper, staticTerm
+ ));
+ }
+ }
+ }
+
+ private static void appendConst(Field field, StringBuilder builder) {
+ String modifier = "public final static";
+ // The assumption is that const always are "public final static" and always are simple types.
+ try {
+ String type = field.getType().getSimpleName();
+ String value = field.get(null).toString();
+ if (field.getType() == String.class) value = "\"" + value + "\"";
+ builder.append(String.format(
+ " %1$s %2$s %3$s = %4$s;\n",
+ modifier, type, field.getName(), value));
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String[] getMethodParamsStrings(
+ Type[] gpTypes, TargetType target, boolean forWrapperCallOfBridge, String[] paramNames) {
+ String declare = "";
+ String use = "";
+ int i = 0;
+ for (Type gpType : gpTypes) {
+ String v = paramNames[i];
+ i++;
+ String value = transferValueExpress(gpType, v, forWrapperCallOfBridge, false, target);
+ Class> clazz = extractClassFromType(gpType);
+ String typeString = getTypeString(gpType, null, true);
+ typeString = transferType(typeString, clazz, target);
+ declare += typeString + " " + v + ", ";
+ use += value + ", ";
+ }
+ if (!declare.isEmpty()) {
+ // To get rid of the tailing ", "
+ declare = declare.substring(0, declare.length() - 2);
+ use = use.substring(0, use.length() - 2);
+ }
+ return new String[] {declare, use};
+ }
+
+ /*
+ * Transfer an internal type string into bridge/wrapper type.
+ */
+ private static String transferType(String type, Class> clazz, TargetType target) {
+ if (type == null) type = clazz.getSimpleName();
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (annotation == null) return type;
+
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ Class> instance = annotation.instance();
+ if (instance != Object.class) {
+ return transferType(instance.getSimpleName(), instance, target);
+ }
+ return type.replace(INTERNAL_CLASS_SUFFIX, BRIDGE_CLASS_SUFFIX);
+ } else if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ return type.replace(INTERNAL_CLASS_SUFFIX, "");
+ }
+ return type;
+ }
+
+ /*
+ * Transfer an internal type value into bridge/wrapper for function params/return value.
+ */
+ private static String transferValueExpress(
+ Type valueType, String v,
+ boolean bridgeWrapperCall, boolean forReturnValue, TargetType target) {
+ String type = getTypeString(valueType, null, true);
+ String value = v;
+ // In case it's void return type.
+ if (forReturnValue && type.equals("void")) return value;
+
+ Class> clazz = extractClassFromType(valueType);
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (annotation == null) {
+ if (value.startsWith("ReflectionHelper.invokeMethod")) {
+ String forceType = type;
+ if (clazz.isPrimitive()) {
+ forceType = primitiveToObject(clazz).getSimpleName();
+ }
+ value = "(" + forceType + ")" + value;
+ }
+ return value;
+ }
+
+ /* Handle Internal class */
+
+ // If annotation declares instance class, cast value to it.
+ Class> instance = annotation.instance();
+ String instanceType = type;
+ if (instance != Object.class) {
+ instanceType = getTypeString(null, instance, true);
+ // If annotation has instance, cast value to instance type.
+ // For wrapper, cast to the wrapper class of instance type.
+ if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ value = "(" + instanceType.replace(INTERNAL_CLASS_SUFFIX, "") + ")" + value;
+ } else if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ value = "(" + instanceType + ")" + value;
+ }
+ }
+ String instanceBridgeType = instanceType.replace(INTERNAL_CLASS_SUFFIX, BRIDGE_CLASS_SUFFIX);
+ String instanceWrapperType = instanceType.replace(INTERNAL_CLASS_SUFFIX, "");
+ // Get whether this class is only created internally or externally.
+ boolean createInternally = annotation.createInternally();
+ boolean createExternally = annotation.createExternally();
+
+ if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ if (forReturnValue) {
+ // The return of bridge's function is always bridge.
+ // So here transfers bridge value to wrapper, add ".getWrapper()"
+ if (createReflection) {
+ value = String.format("(%1$s)ReflectionHelper.getBridgeOrWrapper(%2$s)",
+ instanceWrapperType, value);
+ } else {
+ value = String.format("(%s).getWrapper()", value);
+ }
+ } else {
+ // The input of wrapper's function is always wrapper.
+ // So here transfers wrapper value to bridge value, add ".getBridge()"
+ value = String.format("(%s).getBridge()", value);
+ }
+ // Bridge class has two function for each internal function: wrapperCall and superCall.
+ // They needs to be treaded differently.
+ } else if (target == TargetType.REFLECTION_LAYER_BRIDGE && bridgeWrapperCall) {
+ if (forReturnValue) {
+ // The return of wrapper's function is always wrapper.
+ // So here transfers wrapper to bridge.
+ if (createReflection) {
+ value = String.format("(%1$s)ReflectionHelper.getBridgeOrWrapper(%2$s)",
+ instanceBridgeType, value);
+ } else {
+ value = String.format("(%s).getBridge()", value);
+ }
+ } else {
+ // The input of bridge's function is always internal.
+ // So here transfers internal to wrapper.
+ String castToBridge = String.format("(%1$s) %2$s", instanceBridgeType, v);
+ if (!createExternally) {
+ // If not create externally, the internal value might not able to be cast to bridge type.
+ // If not, need to create bridge via internal value.
+ value = String.format(
+ "%1$s instanceof %2$s ? (%3$s) : new %2$s(%4$s)",
+ v, instanceBridgeType, castToBridge, value);
+ } else {
+ value = castToBridge;
+ }
+ value = String.format("(%s).getWrapper()", value);
+ }
+ } else if (target == TargetType.REFLECTION_LAYER_BRIDGE && !bridgeWrapperCall) {
+ // superCall of bridge function
+ if (forReturnValue) {
+ // The return value of superCall is always internal.
+ // So here needs to transfer internal to bridge.
+ String castToBridge = String.format("(%1$s) %2$s", instanceBridgeType, v);
+ if (!createExternally) {
+ // If not create externally, the internal value might not able to be cast to bridge type.
+ // If not, need to create bridge via internal value.
+ value = String.format(
+ "%1$s instanceof %2$s ? (%3$s) : new %2$s(%4$s)",
+ v, instanceBridgeType, castToBridge, value);
+ } else {
+ value = castToBridge;
+ }
+ } else {
+ // The input of superCall is always internal, so directly return the original value is ok.
+ value = v;
+ }
+ }
+ return value;
+ }
+
+ /*
+ * Get the string of a given type. The main reason to have this is that Class> doesn't
+ * contain GenericTypes. e.g. HashSet is only HashSet in Class>.
+ */
+ private static String getTypeString(Type type, Class> clazz, boolean isRootCall) {
+ try {
+ if (clazz == null) {
+ clazz = extractClassFromType(type);
+ }
+ if (!clazz.isAnnotationPresent(XWalkAPI.class)) usedClassSet.add(clazz);
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType) type;
+ Type[] argus = pType.getActualTypeArguments();
+ String arguList = "";
+ for (Type argu : argus) {
+ arguList += getTypeString(argu, null, false) + ", ";
+ }
+ arguList = arguList.substring(0, arguList.length() - 2);
+ return clazz.getSimpleName() + "<" + arguList + ">";
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType pType = (GenericArrayType) type;
+ Type cType = pType.getGenericComponentType();
+ return getTypeString(cType, null, false) + "[]";
+ }
+ } catch (ClassCastException e) {
+ // If this is a recursive call, just throw the exception.
+ // when the exception thrown to the top level, return the
+ // clazz's simple name as fallback.
+ if (!isRootCall) throw e;
+ }
+ return clazz.getSimpleName();
+ }
+
+ private static Class> extractClassFromType(Type t) throws ClassCastException {
+ if (t instanceof Class>) {
+ return (Class>)t;
+ }
+ return (Class>)((ParameterizedType)t).getRawType();
+ }
+
+ private static void generateFooter(Class> clazz, StringBuilder builder, TargetType target) {
+ StringBuilder initMethod = new StringBuilder();
+ XWalkAPI annotation = clazz.getAnnotation(XWalkAPI.class);
+ if (!clazz.isInterface() && !annotation.noInstance()) {
+ initMethod.append(
+ " private void reflectionInit() throws" +
+ " NoSuchMethodException, ClassNotFoundException {\n");
+ initMethod.append(String.format(" Class> clazz = %s.getClass();\n",
+ target == TargetType.REFLECTION_LAYER_BRIDGE ? "wrapper" : "bridge"));
+ for (Method method : usedMethodSet) {
+ String name = generateMethodName(method);
+ initMethod.insert(0, " private Method " + name + ";\n");
+ String paramTypes = generateParamTypesFromMethod(method, null, target);
+ String methodName = method.getName();
+ if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ methodName += "Super";
+ }
+ initMethod.append(String.format(
+ " %1$s = clazz.getMethod(\"%2$s\"%3$s);\n"
+ , name, methodName, paramTypes));
+ }
+ initMethod.append(" }\n");
+ }
+ builder.append(initMethod.toString());
+ StringBuilder staticArea = new StringBuilder();
+ staticArea.append(" static {\n");
+ boolean hasStaticContent = false;
+ if (target == TargetType.REFLECTION_LAYER_WRAPPER) {
+ for (Constructor> constructor : usedConstructorSet) {
+ String name = generateConstructorName(constructor);
+ String paramTypes = generateParamTypesFromMethod(null, constructor, target);
+ paramTypes += ", Object.class";
+ String fullClassName = generateFullClassName(clazz, target);
+ staticArea.append(String.format(
+ " ReflectionHelper.registerConstructor(\"%1$s\", \"%2$s\"%3$s);\n",
+ name, fullClassName, paramTypes));
+ hasStaticContent = true;
+ }
+ } else if (target == TargetType.REFLECTION_LAYER_BRIDGE && annotation.createInternally()) {
+ staticArea.append(String.format(
+ " ReflectionHelper.registerConstructor(\"%1$s\", \"%2$s\", Object.class);\n",
+ generateConstructorName(clazz),
+ generateFullClassName(clazz, target)));
+ hasStaticContent = true;
+ }
+ staticArea.append(" }\n");
+ if (hasStaticContent) builder.append(staticArea.toString());
+ builder.append("}\n");
+ }
+
+ private static String generateParamTypesFromMethod(
+ Method method, Constructor constructor, TargetType target) {
+ Class>[] types;
+ boolean forConstructor = false;
+ if (method != null) {
+ types = method.getParameterTypes();
+ } else if (constructor != null) {
+ types = constructor.getParameterTypes();
+ forConstructor = true;
+ } else {
+ return "";
+ }
+ String paramTypes = "";
+ for (Class> param : types) {
+ XWalkAPI paramAnnotation = param.getAnnotation(XWalkAPI.class);
+ if (paramAnnotation == null) {
+ paramTypes += ", " + param.getSimpleName() + ".class";
+ } else {
+ String fullParamClassName = generateFullClassName(param, target);
+ // For constructor, the clazz object doesn't exist yet. Register to ReflectionHelper
+ // with full class name. ReflectionHelper will get the class object when do real
+ // initialization.
+ if (forConstructor) {
+ paramTypes += ", \"" + fullParamClassName + "\"";
+ } else {
+ paramTypes +=
+ ", clazz.getClassLoader().loadClass(\"" +
+ fullParamClassName +
+ "\")";
+ }
+ }
+ }
+ return paramTypes;
+ }
+
+ private static String generateFullClassName(Class> clazz, TargetType target) {
+ if (!clazz.isAnnotationPresent(XWalkAPI.class)) {
+ return clazz.getPackage().getName() + "." + clazz.getSimpleName();
+ }
+ if (target == TargetType.REFLECTION_LAYER_BRIDGE) {
+ return WRAPPER_PACKAGE + "." + clazz.getSimpleName().replace(INTERNAL_CLASS_SUFFIX, "");
+ } else {
+ return clazz.getName().replace(INTERNAL_CLASS_SUFFIX, BRIDGE_CLASS_SUFFIX);
+ }
+ }
+
+ private static String generateMethodName(Method method) {
+ String name = method.getName();
+ for (Class> param : method.getParameterTypes()) {
+ String paramName = param.getSimpleName();
+ name += paramName.substring(0, 1).toUpperCase();
+ if (paramName.length() > 1) name += paramName.substring(1).toLowerCase();
+ }
+ name += "Method";
+ return name;
+ }
+
+ private static String generateConstructorName(Constructor> constructor) {
+ String name = constructor.getDeclaringClass().getSimpleName().toLowerCase();
+ for (Class> param : constructor.getParameterTypes()) {
+ String paramName = param.getSimpleName();
+ name += paramName.substring(0, 1).toUpperCase();
+ if (paramName.length() > 1) name += paramName.substring(1);
+ }
+ name += "Constructor";
+ return name;
+ }
+
+ private static String generateConstructorName(Class> clazz) {
+ // This is only used by bridge, bridge will create wrapper instance if it's created internally.
+ // In such case, bridge will need to have the constructor of wrapper.
+ String name = transferType(
+ null, clazz, TargetType.REFLECTION_LAYER_BRIDGE).toLowerCase();
+ name += "Constructor";
+ return name;
+ }
+
+ private static Class> primitiveToObject(Class> primitive) {
+ if (primitive == boolean.class) {
+ return Boolean.class;
+ }
+ if (primitive == byte.class) {
+ return Byte.class;
+ }
+ if (primitive == char.class) {
+ return Character.class;
+ }
+ if (primitive == short.class) {
+ return Short.class;
+ }
+ if (primitive == int.class) {
+ return Integer.class;
+ }
+ if (primitive == long.class) {
+ return Long.class;
+ }
+ if (primitive == float.class) {
+ return Float.class;
+ }
+ if (primitive == double.class) {
+ return Double.class;
+ }
+ return Void.class;
+ }
+}
diff --git a/xwalk_android.gypi b/xwalk_android.gypi
index 24136f9267..aef8c4528a 100644
--- a/xwalk_android.gypi
+++ b/xwalk_android.gypi
@@ -1,4 +1,8 @@
{
+ 'variables': {
+ 'reflection_java_dir': '<(PRODUCT_DIR)/gen/xwalk_core_reflection_layer',
+ 'empty_src_dir': '<(DEPTH)/xwalk/runtime/android/core_empty',
+ },
'targets': [
{
'target_name': 'libxwalkcore',
@@ -30,7 +34,7 @@
],
},
{
- 'target_name': 'xwalk_core_java',
+ 'target_name': 'xwalk_core_internal_java',
'type': 'none',
'dependencies': [
'../components/components.gyp:navigation_interception_java',
@@ -40,14 +44,86 @@
'xwalk_core_extensions_java',
],
'variables': {
- 'java_in_dir': 'runtime/android/core',
+ 'java_in_dir': 'runtime/android/core_internal',
'has_java_resources': 1,
- 'R_package': 'org.xwalk.core',
- 'R_package_relpath': 'org/xwalk/core',
+ 'R_package': 'org.xwalk.core.internal',
+ 'R_package_relpath': 'org/xwalk/core/internal',
'java_strings_grd': 'android_xwalk_strings.grd',
},
'includes': ['../build/java.gypi'],
},
+ {
+ 'target_name': 'xwalk_core_reflection_layer_generator_java',
+ 'type': 'none',
+ 'dependencies': [
+ 'xwalk_core_internal_java',
+ ],
+ 'variables': {
+ 'java_in_dir': 'tools/reflection_generator',
+ },
+ 'includes': ['../build/java.gypi'],
+ 'all_dependent_settings': {
+ 'variables': {
+ 'generator_jar_path': '<(jar_final_path)',
+ },
+ },
+ },
+ {
+ 'target_name': 'xwalk_core_reflection_layer_java_gen',
+ 'type': 'none',
+ 'dependencies': [
+ 'xwalk_core_reflection_layer_generator_java',
+ ],
+ 'variables': {
+ 'timestamp': '<(reflection_java_dir)/gen.timestamp',
+ 'android_jar': '<(android_sdk)/android.jar',
+ 'input_jars_paths': [ '<(android_jar)' ],
+ },
+ 'all_dependent_settings': {
+ 'variables': {
+ 'reflection_layer_gen_timestamp': '<(timestamp)',
+ },
+ },
+ 'actions': [
+ {
+ 'action_name': 'generate_reflection',
+ 'message': 'Creating reflection layer',
+ 'inputs': [
+ 'tools/reflection_generator/generator.py',
+ '>(generator_jar_path)',
+ ],
+ 'outputs': [
+ '<(timestamp)',
+ ],
+ 'action': [
+ 'python', 'tools/reflection_generator/generator.py',
+ '--classpath=>(input_jars_paths)',
+ '--source=runtime/android/core_internal/src',
+ '--output=<(reflection_java_dir)',
+ '--stamp=<(timestamp)',
+ '--helper-class=runtime/android/core_internal/src/org/xwalk/core/internal/ReflectionHelper.java',
+ ],
+ },
+ ],
+ },
+ {
+ #TODO(wang16): split it into internal and core.
+ 'target_name': 'xwalk_core_java',
+ 'type': 'none',
+ 'dependencies': [
+ 'xwalk_core_internal_java',
+ 'xwalk_core_reflection_layer_java_gen',
+ ],
+ 'variables': {
+ 'java_in_dir': '<(empty_src_dir)',
+ 'additional_input_paths': [ '>(reflection_layer_gen_timestamp)' ],
+ 'generated_src_dirs': [
+ '<(reflection_java_dir)/bridge',
+ '<(reflection_java_dir)/wrapper',
+ ],
+ },
+ 'includes': ['../build/java.gypi']
+ },
{
'target_name': 'xwalk_runtime_java',
'type': 'none',
@@ -120,6 +196,7 @@
'<(PRODUCT_DIR)/lib.java/ui_java.dex.jar',
'<(PRODUCT_DIR)/lib.java/web_contents_delegate_android_java.dex.jar',
'<(PRODUCT_DIR)/lib.java/xwalk_core_extensions_java.dex.jar',
+ '<(PRODUCT_DIR)/lib.java/xwalk_core_internal_java.dex.jar',
'<(PRODUCT_DIR)/lib.java/xwalk_core_java.dex.jar',
'<(PRODUCT_DIR)/lib.java/xwalk_runtime_java.dex.jar',
'<(SHARED_INTERMEDIATE_DIR)/xwalk_native_libraries/'
@@ -146,17 +223,17 @@
'jni_gen_package': 'xwalk',
},
'sources': [
- 'runtime/android/core/src/org/xwalk/core/AndroidProtocolHandler.java',
- 'runtime/android/core/src/org/xwalk/core/InterceptedRequestData.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkHttpAuthHandler.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkContentsClientBridge.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkContentsIoThreadClient.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkContent.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkCookieManager.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkDevToolsServer.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkSettings.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkViewDelegate.java',
- 'runtime/android/core/src/org/xwalk/core/XWalkWebContentsDelegate.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/AndroidProtocolHandler.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/InterceptedRequestData.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsIoThreadClient.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContent.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkCookieManager.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkDevToolsServer.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkHttpAuthHandler.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkSettings.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewDelegate.java',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegate.java',
],
'includes': ['../build/jni_generator.gypi'],
},
@@ -169,8 +246,8 @@
'variables': {
'java_in_dir': 'extensions/android/java',
'has_java_resources': 0,
- 'R_package': 'org.xwalk.core.extensions',
- 'R_package_relpath': 'org/xwalk/core/extensions',
+ 'R_package': 'org.xwalk.core.internal.extensions',
+ 'R_package_relpath': 'org/xwalk/core/internal/extensions',
},
'includes': ['../build/java.gypi'],
},
@@ -181,7 +258,7 @@
'jni_gen_package': 'xwalk',
},
'sources': [
- 'extensions/android/java/src/org/xwalk/core/extensions/XWalkExtensionAndroid.java',
+ 'extensions/android/java/src/org/xwalk/core/internal/extensions/XWalkExtensionAndroid.java',
],
'includes': ['../build/jni_generator.gypi'],
},
@@ -253,9 +330,9 @@
'files': [
'experimental/launch_screen/launch_screen_api.js',
'experimental/presentation/presentation_api.js',
- 'runtime/android/core/src/org/xwalk/core/extension/api/contacts/contacts_api.js',
- 'runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/device_capabilities_api.js',
- 'runtime/android/core/src/org/xwalk/core/extension/api/messaging/messaging_api.js',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/contacts/contacts_api.js',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/device_capabilities/device_capabilities_api.js',
+ 'runtime/android/core_internal/src/org/xwalk/core/internal/extension/api/messaging/messaging_api.js',
'runtime/extension/screen_orientation_api.js',
],
},
diff --git a/xwalk_core_library_android.gypi b/xwalk_core_library_android.gypi
index 1c3cda49eb..ae22b34336 100644
--- a/xwalk_core_library_android.gypi
+++ b/xwalk_core_library_android.gypi
@@ -46,6 +46,7 @@
'additional_src_dirs': [
'<(DEPTH)/ui/android/java/resource_map',
'<(DEPTH)/content/public/android/java/resource_map',
+ '<(DEPTH)/xwalk/runtime/android/core_internal/resource_map',
],
},
'includes': [ '../build/java_apk.gypi' ],
@@ -62,7 +63,7 @@
'jar_name': '<(_target_name).jar',
'jar_final_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
'jar_excluded_classes': [
- '*org/xwalk/*',
+ '*org/xwalk/core/R*',
],
},
'all_dependent_settings': {