Bug 1299400 - Remove WebActivities Android Backend. r?sebastian
WebActivities API has removed by
bug 1284455, so we should remove Android backend.
MozReview-Commit-ID: IOYs1bM2u06
--- a/mobile/android/base/java/org/mozilla/gecko/IntentHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/IntentHelper.java
@@ -7,17 +7,16 @@ package org.mozilla.gecko;
import org.mozilla.gecko.overlays.ui.ShareDialog;
import org.mozilla.gecko.util.ActivityResultHandler;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.JSONUtils;
import org.mozilla.gecko.util.NativeEventListener;
import org.mozilla.gecko.util.NativeJSObject;
-import org.mozilla.gecko.util.WebActivityMapper;
import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.TargetApi;
import android.content.Context;
@@ -43,17 +42,16 @@ import java.util.Locale;
public final class IntentHelper implements GeckoEventListener,
NativeEventListener {
private static final String LOGTAG = "GeckoIntentHelper";
private static final String[] EVENTS = {
"Intent:GetHandlers",
"Intent:Open",
"Intent:OpenForResult",
- "WebActivity:Open"
};
private static final String[] NATIVE_EVENTS = {
"Intent:OpenNoHandler",
};
// via http://developer.android.com/distribute/tools/promote/linking.html
private static String MARKET_INTENT_URI_PACKAGE_PREFIX = "market://details?id=";
@@ -411,18 +409,16 @@ public final class IntentHelper implemen
public void handleMessage(String event, JSONObject message) {
try {
if (event.equals("Intent:GetHandlers")) {
getHandlers(message);
} else if (event.equals("Intent:Open")) {
open(message);
} else if (event.equals("Intent:OpenForResult")) {
openForResult(message);
- } else if (event.equals("WebActivity:Open")) {
- openWebActivity(message);
}
} catch (JSONException e) {
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
}
}
private void getHandlers(JSONObject message) throws JSONException {
final Intent intent = getOpenURIIntent(activity,
@@ -567,21 +563,16 @@ public final class IntentHelper implemen
* @param encodedUri The encoded uri. While the page does not open correctly without specifying
* a uri parameter, it happily accepts the empty String so this argument may
* be the empty String.
*/
private String getUnknownProtocolErrorPageUri(final String encodedUri) {
return UNKNOWN_PROTOCOL_URI_PREFIX + encodedUri;
}
- private void openWebActivity(JSONObject message) throws JSONException {
- final Intent intent = WebActivityMapper.getIntentForWebActivity(message.getJSONObject("activity"));
- ActivityHandlerHelper.startIntentForActivity(activity, intent, new ResultHandler(message));
- }
-
private static class ResultHandler implements ActivityResultHandler {
private final JSONObject message;
public ResultHandler(JSONObject message) {
this.message = message;
}
@Override
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -134,17 +134,16 @@ gujar.sources += [geckoview_source_dir +
'util/PrefUtils.java',
'util/ProxySelector.java',
'util/RawResource.java',
'util/StringUtils.java',
'util/ThreadUtils.java',
'util/UIAsyncTask.java',
'util/UUIDUtil.java',
'util/WeakReferenceHandler.java',
- 'util/WebActivityMapper.java',
'util/WindowUtils.java',
]]
gujar.extra_jars = [
CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
'constants.jar',
'gecko-mozglue.jar',
deleted file mode 100644
--- a/mobile/android/components/AndroidActivitiesGlue.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict"
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Messaging.jsm");
-
-function ActivitiesGlue() { }
-
-ActivitiesGlue.prototype = {
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIActivityUIGlue]),
- classID: Components.ID("{e4deb5f6-d5e3-4fce-bc53-901dd9951c48}"),
-
- // Ignore aActivities results on Android, go straight to Android intents.
- chooseActivity: function ap_chooseActivity(aOptions, aActivities, aCallback) {
- Messaging.sendRequestForResult({
- type: "WebActivity:Open",
- activity: { name: aOptions.name, data: aOptions.data }
- }).then((result) => {
- aCallback.handleEvent(Ci.nsIActivityUIGlueCallback.NATIVE_ACTIVITY, result);
- });
- }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivitiesGlue]);
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -112,17 +112,13 @@ component {a78d7e59-b558-4321-a3d6-dffe2
contract @mozilla.org/snippets;1 {a78d7e59-b558-4321-a3d6-dffe2f1e76dd}
category browser-delayed-startup-finished Snippets @mozilla.org/snippets;1
category update-timer Snippets @mozilla.org/snippets;1,getService,snippets-update-timer,browser.snippets.updateInterval,86400
# ColorPicker.js
component {430b987f-bb9f-46a3-99a5-241749220b29} ColorPicker.js
contract @mozilla.org/colorpicker;1 {430b987f-bb9f-46a3-99a5-241749220b29}
-# AndroidActivitiesGlue.js
-component {e4deb5f6-d5e3-4fce-bc53-901dd9951c48} AndroidActivitiesGlue.js
-contract @mozilla.org/dom/activities/ui-glue;1 {e4deb5f6-d5e3-4fce-bc53-901dd9951c48}
-
# PersistentNotificationHandler.js
component {75390fe7-f8a3-423a-b3b1-258d7eabed40} PersistentNotificationHandler.js
contract @mozilla.org/persistent-notification-handler;1 {75390fe7-f8a3-423a-b3b1-258d7eabed40}
category persistent-notification-click PersistentNotificationHandler @mozilla.org/persistent-notification-handler;1
category persistent-notification-close PersistentNotificationHandler @mozilla.org/persistent-notification-handler;1
--- a/mobile/android/components/moz.build
+++ b/mobile/android/components/moz.build
@@ -8,17 +8,16 @@ XPIDL_SOURCES += [
'SessionStore.idl',
]
XPIDL_MODULE = 'MobileComponents'
EXTRA_COMPONENTS += [
'AboutRedirector.js',
'AddonUpdateService.js',
- 'AndroidActivitiesGlue.js',
'BlocklistPrompt.js',
'BrowserCLH.js',
'ColorPicker.js',
'ContentDispatchChooser.js',
'ContentPermissionPrompt.js',
'DirectoryProvider.js',
'FilePicker.js',
'FxAccountsPush.js',
deleted file mode 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/WebActivityMapper.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.util;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-public final class WebActivityMapper {
- private static final String LOGTAG = "Gecko";
-
- private static final Map<String, WebActivityMapping> activityMap = new HashMap<String, WebActivityMapping>();
- static {
- activityMap.put("dial", new DialMapping());
- activityMap.put("open", new OpenMapping());
- activityMap.put("pick", new PickMapping());
- activityMap.put("send", new SendMapping());
- activityMap.put("view", new ViewMapping());
- activityMap.put("record", new RecordMapping());
- };
-
- private static abstract class WebActivityMapping {
- protected JSONObject mData;
-
- public void setData(JSONObject data) {
- mData = data;
- }
-
- // Cannot return null
- public abstract String getAction();
-
- public String getMime() throws JSONException {
- return null;
- }
-
- public String getUri() throws JSONException {
- return null;
- }
-
- public void putExtras(Intent intent) throws JSONException {}
- }
-
- /**
- * Provides useful defaults for mime type and uri.
- */
- private static abstract class BaseMapping extends WebActivityMapping {
- /**
- * If 'type' is present in data object, uses the value as the MIME type.
- */
- @Override
- public String getMime() throws JSONException {
- return mData.optString("type", null);
- }
-
- /**
- * If 'uri' or 'url' is present in data object, uses the respective value as the Uri.
- */
- @Override
- public String getUri() throws JSONException {
- // Will return uri or url if present.
- String uri = mData.optString("uri", null);
- return uri != null ? uri : mData.optString("url", null);
- }
- }
-
- public static Intent getIntentForWebActivity(JSONObject message) throws JSONException {
- final String name = message.getString("name").toLowerCase();
- final JSONObject data = message.getJSONObject("data");
-
- Log.w(LOGTAG, "Activity is: " + name);
- final WebActivityMapping mapping = activityMap.get(name);
- if (mapping == null) {
- Log.w(LOGTAG, "No mapping found!");
- return null;
- }
-
- mapping.setData(data);
-
- final Intent intent = new Intent(mapping.getAction());
-
- final String mime = mapping.getMime();
- if (!TextUtils.isEmpty(mime)) {
- intent.setType(mime);
- }
-
- final String uri = mapping.getUri();
- if (!TextUtils.isEmpty(uri)) {
- intent.setData(Uri.parse(uri));
- }
-
- mapping.putExtras(intent);
-
- return intent;
- }
-
- private static class DialMapping extends WebActivityMapping {
- @Override
- public String getAction() {
- return Intent.ACTION_DIAL;
- }
-
- @Override
- public String getUri() throws JSONException {
- return "tel:" + mData.getString("number");
- }
- }
-
- private static class OpenMapping extends BaseMapping {
- @Override
- public String getAction() {
- return Intent.ACTION_VIEW;
- }
- }
-
- private static class PickMapping extends BaseMapping {
- @Override
- public String getAction() {
- return Intent.ACTION_GET_CONTENT;
- }
-
- @Override
- public String getMime() throws JSONException {
- // bug 1007112 - pick action needs a mimetype to work
- String mime = mData.optString("type", null);
- return !TextUtils.isEmpty(mime) ? mime : "*/*";
- }
- }
-
- private static class SendMapping extends BaseMapping {
- @Override
- public String getAction() {
- return Intent.ACTION_SEND;
- }
-
- @Override
- public void putExtras(Intent intent) throws JSONException {
- optPutExtra("text", Intent.EXTRA_TEXT, intent);
- optPutExtra("html_text", Intent.EXTRA_HTML_TEXT, intent);
- optPutExtra("stream", Intent.EXTRA_STREAM, intent);
- }
-
- private void optPutExtra(String key, String extraName, Intent intent) {
- final String extraValue = mData.optString(key);
- if (!TextUtils.isEmpty(extraValue)) {
- intent.putExtra(extraName, extraValue);
- }
- }
- }
-
- private static class ViewMapping extends BaseMapping {
- @Override
- public String getAction() {
- return Intent.ACTION_VIEW;
- }
-
- @Override
- public String getMime() {
- // MozActivity adds a type 'url' here, we don't want to set the MIME to 'url'.
- String type = mData.optString("type", null);
- if ("url".equals(type) || "uri".equals(type)) {
- return null;
- } else {
- return type;
- }
- }
- }
-
- private static class RecordMapping extends WebActivityMapping {
- @Override
- public String getAction() {
- String type = mData.optString("type", null);
- if ("photos".equals(type)) {
- return "android.media.action.IMAGE_CAPTURE";
- } else if ("videos".equals(type)) {
- return "android.media.action.VIDEO_CAPTURE";
- }
- return null;
- }
-
- // Add an extra to specify where to save the picture/video.
- @Override
- public void putExtras(Intent intent) {
- final String action = getAction();
-
- final String dirType = action == "android.media.action.IMAGE_CAPTURE"
- ? Environment.DIRECTORY_PICTURES
- : Environment.DIRECTORY_MOVIES;
-
- final String ext = action == "android.media.action.IMAGE_CAPTURE"
- ? ".jpg"
- : ".mp4";
-
- File destDir = Environment.getExternalStoragePublicDirectory(dirType);
-
- try {
- File dest = File.createTempFile(
- "capture", /* prefix */
- ext, /* suffix */
- destDir /* directory */
- );
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(dest));
- } catch (Exception e) {
- Log.w(LOGTAG, "Failed to add extra for " + action + " : " + e);
- }
- }
- }
-}
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -109,27 +109,25 @@
@BINPATH@/components/content_geckomediaplugins.xpt
@BINPATH@/components/content_html.xpt
@BINPATH@/components/content_webrtc.xpt
@BINPATH@/components/content_xslt.xpt
@BINPATH@/components/cookie.xpt
@BINPATH@/components/directory.xpt
@BINPATH@/components/docshell.xpt
@BINPATH@/components/dom.xpt
-@BINPATH@/components/dom_activities.xpt
@BINPATH@/components/dom_apps.xpt
@BINPATH@/components/dom_newapps.xpt
@BINPATH@/components/dom_base.xpt
@BINPATH@/components/dom_canvas.xpt
@BINPATH@/components/dom_core.xpt
@BINPATH@/components/dom_css.xpt
@BINPATH@/components/dom_events.xpt
@BINPATH@/components/dom_geolocation.xpt
@BINPATH@/components/dom_media.xpt
-@BINPATH@/components/dom_messages.xpt
@BINPATH@/components/dom_network.xpt
@BINPATH@/components/dom_notification.xpt
@BINPATH@/components/dom_html.xpt
@BINPATH@/components/dom_offline.xpt
@BINPATH@/components/dom_json.xpt
@BINPATH@/components/dom_power.xpt
#ifdef MOZ_ANDROID_GCM
@BINPATH@/components/dom_push.xpt
@@ -367,23 +365,16 @@
@BINPATH@/components/XULStore.manifest
@BINPATH@/components/Webapps.js
@BINPATH@/components/Webapps.manifest
@BINPATH@/components/AppsService.js
@BINPATH@/components/AppsService.manifest
@BINPATH@/components/htmlMenuBuilder.js
@BINPATH@/components/htmlMenuBuilder.manifest
-@BINPATH@/components/Activities.manifest
-@BINPATH@/components/AndroidActivitiesGlue.js
-@BINPATH@/components/ActivityProxy.js
-@BINPATH@/components/ActivityRequestHandler.js
-@BINPATH@/components/ActivityWrapper.js
-@BINPATH@/components/ActivityMessageConfigurator.js
-
@BINPATH@/components/SystemMessageInternal.js
@BINPATH@/components/SystemMessageManager.js
@BINPATH@/components/SystemMessageCache.js
@BINPATH@/components/SystemMessageManager.manifest
@BINPATH@/components/InstallPackagedWebapp.manifest
@BINPATH@/components/InstallPackagedWebapp.js