Bug 847834 - Avoid NPEs in BrowserApp.onActivityResult(). r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 23 Apr 2013 14:21:34 -0700
changeset 140633 9cd4b8d02649cad70588fbe027b8bc0d56a20ad6
parent 140632 b5b63beb5249033207acb0e54ee3e1397205139d
child 140634 812da2a6d2f87a3d100537006fddf3460d510cdd
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs847834
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 847834 - Avoid NPEs in BrowserApp.onActivityResult(). r=wesj
mobile/android/base/BrowserApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -799,27 +799,30 @@ abstract public class BrowserApp extends
         updateSideBarState();
         mTabsPanel.refresh();
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
-        // Don't update the url in the toolbar if the activity was cancelled, or if it was launched to pick
-        //  a site. The order of these checks matters because data will be null if the activity was cancelled.
-        if (resultCode != Activity.RESULT_OK ||
-            data.getStringExtra(AwesomeBar.TARGET_KEY).equals(AwesomeBar.Target.PICK_SITE.toString())) {
-            // We still need to call fromAwesomeBarSearch to perform the toolbar animation.
-            mBrowserToolbar.fromAwesomeBarSearch(null);
-            return;
+        String url = null;
+
+        // Don't update the url in the toolbar if the activity was cancelled.
+        if (resultCode == Activity.RESULT_OK && data != null) {
+            // Don't update the url if the activity was launched to pick a site.
+            String targetKey = data.getStringExtra(AwesomeBar.TARGET_KEY);
+            if (!AwesomeBar.Target.PICK_SITE.toString().equals(targetKey)) {
+                // Update the toolbar with the url that was just entered.
+                url = data.getStringExtra(AwesomeBar.URL_KEY);
+            }
         }
 
-        // Otherwise, update the toolbar with the url that was just entered.
-        mBrowserToolbar.fromAwesomeBarSearch(data.getStringExtra(AwesomeBar.URL_KEY));
+        // We always need to call fromAwesomeBarSearch to perform the toolbar animation.
+        mBrowserToolbar.fromAwesomeBarSearch(url);
     }
 
     public View getActionBarLayout() {
         int actionBarRes;
 
         if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet())
            actionBarRes = R.layout.browser_toolbar_menu;
         else