Bug 1276696 - Add dummy service for custom tabs. r?mcomella draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Wed, 25 May 2016 19:31:10 +0200
changeset 378042 0ef81b106911778d5736b15151c004a04527f499
parent 378041 2524bee928744af46f374854219f61d4d389f52d
child 378043 4ea3ff80f84e9b929b57c73c4b109e1a63101fb9
push id20919
push users.kaspari@gmail.com
push dateTue, 14 Jun 2016 12:28:54 +0000
reviewersmcomella
bugs1276696
milestone50.0a1
Bug 1276696 - Add dummy service for custom tabs. r?mcomella Currently this service does not implement any of the callbacks. However it is necessary to be detected as an app supporting custom tabs. MozReview-Commit-ID: Hz99Gp9aQCX
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/java/org/mozilla/gecko/customtabs/GeckoCustomTabsService.java
mobile/android/base/moz.build
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -377,16 +377,24 @@
                 <action android:name="android.intent.action.BOOT_COMPLETED"></action>
             </intent-filter>
         </receiver>
 
         <service
           android:name="org.mozilla.gecko.telemetry.TelemetryUploadService"
           android:exported="false"/>
 
+        <service
+            android:name="org.mozilla.gecko.customtabs.GeckoCustomTabsService"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.support.customtabs.action.CustomTabsService" />
+            </intent-filter>
+        </service>
+
 #include ../services/manifests/FxAccountAndroidManifest_services.xml.in
 
         <service
             android:name="org.mozilla.gecko.tabqueue.TabReceivedService"
             android:exported="false" />
 
 
 #ifdef MOZ_ANDROID_SEARCH_ACTIVITY
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/GeckoCustomTabsService.java
@@ -0,0 +1,51 @@
+/* -*- 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.customtabs;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.customtabs.CustomTabsService;
+import android.support.customtabs.CustomTabsSessionToken;
+import android.util.Log;
+
+import java.util.List;
+
+/**
+ * Custom tabs service external, third-party apps connect to.
+ */
+public class GeckoCustomTabsService extends CustomTabsService {
+    private static final String LOGTAG = "GeckoCustomTabsService";
+
+    @Override
+    protected boolean warmup(long flags) {
+        Log.v(LOGTAG, "warmup()");
+
+        // Pretend warmup was successful
+        return true;
+    }
+
+    @Override
+    protected boolean newSession(CustomTabsSessionToken sessionToken) {
+        Log.v(LOGTAG, "newSession()");
+
+        // Pretend session has been started
+        return true;
+    }
+
+    @Override
+    protected boolean mayLaunchUrl(CustomTabsSessionToken sessionToken, Uri uri, Bundle bundle, List<Bundle> list) {
+        Log.v(LOGTAG, "mayLaunchUrl()");
+
+        return false;
+    }
+
+    @Override
+    protected Bundle extraCommand(String commandName, Bundle bundle) {
+        Log.v(LOGTAG, "extraCommand()");
+
+        return null;
+    }
+}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -220,16 +220,17 @@ gbjar.sources += ['java/org/mozilla/geck
     'BrowserLocaleManager.java',
     'cleanup/FileCleanupController.java',
     'cleanup/FileCleanupService.java',
     'ContactService.java',
     'ContextGetter.java',
     'CrashHandler.java',
     'CustomEditText.java',
     'customtabs/CustomTabsActivity.java',
+    'customtabs/GeckoCustomTabsService.java',
     'DataReportingNotification.java',
     'db/AbstractPerProfileDatabaseProvider.java',
     'db/AbstractTransactionalProvider.java',
     'db/BaseTable.java',
     'db/BrowserDatabaseHelper.java',
     'db/BrowserDB.java',
     'db/BrowserProvider.java',
     'db/DBUtils.java',