Bug 1067025 - Abort when no extra_text present in share dialog. r=rnewman, a=lmandel
authorChris Kitching <chriskitching@linux.com>
Sun, 14 Sep 2014 21:49:45 -0700
changeset 224977 8f2b6a4a26a4f3b8ebd007ba219362d15cb428ae
parent 224976 e6bf3fa80963d7d1c016f41410fe784ac91e5dcb
child 224978 315cb80abb1e8064a93451ed7206fde0c9221135
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, lmandel
bugs1067025
milestone34.0a2
Bug 1067025 - Abort when no extra_text present in share dialog. r=rnewman, a=lmandel
mobile/android/base/overlays/ui/ShareDialog.java
--- a/mobile/android/base/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/overlays/ui/ShareDialog.java
@@ -79,36 +79,47 @@ public class ShareDialog extends LocaleA
         // Note: The activity can be destroyed without onDestroy being called. However, this occurs
         // only when the application is killed, something which also kills the registered receiver
         // list, and the service, and everything else: so we don't care.
         LocalBroadcastManager.getInstance(this).unregisterReceiver(uiEventListener);
 
         super.onDestroy();
     }
 
+    /**
+     * Show a toast indicating we were started with no URL, and then stop.
+     */
+    private void abortDueToNoURL() {
+        Log.e(LOGTAG, "Unable to process shared intent. No URL found!");
+
+        // Display toast notifying the user of failure (most likely a developer who screwed up
+        // trying to send a share intent).
+        Toast toast = Toast.makeText(this, getResources().getText(R.string.overlay_share_no_url), Toast.LENGTH_SHORT);
+        toast.show();
+        finish();
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         getWindow().setWindowAnimations(0);
 
         Intent intent = getIntent();
 
         // The URL is usually hiding somewhere in the extra text. Extract it.
         String extraText = intent.getStringExtra(Intent.EXTRA_TEXT);
-        String pageUrl = new WebURLFinder(extraText).bestWebURL();
-
-        if (TextUtils.isEmpty(pageUrl)) {
-            Log.e(LOGTAG, "Unable to process shared intent. No URL found!");
+        if (TextUtils.isEmpty(extraText)) {
+            abortDueToNoURL();
+            return;
+        }
 
-            // Display toast notifying the user of failure (most likely a developer who screwed up
-            // trying to send a share intent).
-            Toast toast = Toast.makeText(this, getResources().getText(R.string.overlay_share_no_url), Toast.LENGTH_SHORT);
-            toast.show();
-
+        String pageUrl = new WebURLFinder(extraText).bestWebURL();
+        if (TextUtils.isEmpty(pageUrl)) {
+            abortDueToNoURL();
             return;
         }
 
         setContentView(R.layout.overlay_share_dialog);
 
         LocalBroadcastManager.getInstance(this).registerReceiver(uiEventListener,
                                                                  new IntentFilter(OverlayConstants.SHARE_METHOD_UI_EVENT));