Bug 1417650 - Correctly specify flags for Tab:OpenUri; r=me a=gchang
authorJim Chen <nchen@mozilla.com>
Mon, 20 Nov 2017 14:15:35 -0500
changeset 444848 c818d9deb4627045e57217ed3274697496edff92
parent 444847 29d36b507287ce7f7c5f1a43bc80d0e311cff0b1
child 444849 a8ed5d6e5ff37f33420e97f74cb5eab0531b0e6d
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme, gchang
bugs1417650
milestone58.0
Bug 1417650 - Correctly specify flags for Tab:OpenUri; r=me a=gchang Pass in the flag names for Tab:OpenUri so we don't have to worry about synchronizing the flags in Java with ones in C++. r=me for trivial patch. MozReview-Commit-ID: BowjLV1s7nT
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -4137,17 +4137,17 @@ public class BrowserApp extends GeckoApp
         showTabQueuePromptIfApplicable(intent);
 
         // GeckoApp will wrap this unsafe external intent in a SafeIntent.
         super.onNewIntent(externalIntent);
 
         if (AppConstants.MOZ_ANDROID_BEAM && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
             final GeckoBundle data = new GeckoBundle(2);
             data.putString("uri", intent.getDataString());
-            data.putInt("flags", LOAD_NEW_TAB);
+            data.putString("flags", "OPEN_NEWTAB");
             getAppEventDispatcher().dispatch("Tab:OpenUri", data);
         }
 
         // Only solicit feedback when the app has been launched from the icon shortcut.
         if (GuestSession.NOTIFICATION_INTENT.equals(action)) {
             GuestSession.onNotificationIntentReceived(this);
         }
 
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -156,20 +156,16 @@ public abstract class GeckoApp extends G
     // Delay before running one-time "cleanup" tasks that may be needed
     // after a version upgrade.
     private static final int CLEANUP_DEFERRAL_SECONDS = 15;
 
     // Length of time in ms during which crashes are classified as startup crashes
     // for crash loop detection purposes.
     private static final int STARTUP_PHASE_DURATION_MS = 30 * 1000;
 
-    protected static final int LOAD_DEFAULT = 0;
-    protected static final int LOAD_NEW_TAB = 1;
-    protected static final int LOAD_SWITCH_TAB = 2;
-
     private static boolean sAlreadyLoaded;
 
     protected RelativeLayout mRootLayout;
     protected RelativeLayout mMainLayout;
 
     protected RelativeLayout mGeckoLayout;
     private OrientationEventListener mCameraOrientationEventListener;
     protected MenuPanel mMenuPanel;
@@ -1795,22 +1791,22 @@ public abstract class GeckoApp extends G
                         flags |= Tabs.LOADURL_FIRST_AFTER_ACTIVITY_UNHIDDEN;
                     }
                     Tabs.getInstance().loadUrlWithIntentExtras(url, intent, flags);
                 }
             });
         } else if (ACTION_HOMESCREEN_SHORTCUT.equals(action)) {
             final GeckoBundle data = new GeckoBundle(2);
             data.putString("uri", uri);
-            data.putInt("flags", LOAD_SWITCH_TAB);
+            data.putString("flags", "OPEN_SWITCHTAB");
             getAppEventDispatcher().dispatch("Tab:OpenUri", data);
         } else if (Intent.ACTION_SEARCH.equals(action)) {
             final GeckoBundle data = new GeckoBundle(2);
             data.putString("uri", uri);
-            data.putInt("flags", LOAD_NEW_TAB);
+            data.putString("flags", "OPEN_NEWTAB");
             getAppEventDispatcher().dispatch("Tab:OpenUri", data);
         } else if (NotificationHelper.HELPER_BROADCAST_ACTION.equals(action)) {
             NotificationHelper.getInstance(getApplicationContext()).handleNotificationIntent(intent);
         } else if (ACTION_LAUNCH_SETTINGS.equals(action)) {
             // Check if launched from data reporting notification.
             Intent settingsIntent = new Intent(GeckoApp.this, GeckoPreferences.class);
             // Copy extras.
             settingsIntent.putExtras(intent.getUnsafe());
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1926,17 +1926,18 @@ var BrowserApp = {
           }
           this.loadURI(url, browser, params);
         }
         break;
       }
 
       case "Tab:OpenUri":
         window.browserDOMWindow.openURI(Services.io.newURI(data.uri),
-                                        /* opener */ null, data.flags,
+                                        /* opener */ null,
+                                        Ci.nsIBrowserDOMWindow[data.flags],
                                         Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL,
                                         /* triggeringPrincipal */ null);
         break;
 
       case "Tab:Selected":
         this._handleTabSelected(this.getTabForId(data.id));
         break;