Bug 847834 - Avoid NPEs in BrowserApp.onActivityResult(). r=wesj, a=bajaj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 23 Apr 2013 14:21:34 -0700
changeset 133529 f11233f17239380157715e0ca48bc44d242bbe08
parent 133528 32fbb9114d175252de67863d7573b5251d8cdb06
child 133530 608257be5ba4a91f0a91f11a0c6ccc7c945d39ce
push id3692
push userryanvm@gmail.com
push dateMon, 29 Apr 2013 14:23:58 +0000
treeherdermozilla-aurora@739adfac85b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, bajaj
bugs847834
milestone22.0a2
Bug 847834 - Avoid NPEs in BrowserApp.onActivityResult(). r=wesj, a=bajaj
mobile/android/base/BrowserApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -697,27 +697,30 @@ abstract public class BrowserApp extends
         if (mAboutHomeContent != null)
             mAboutHomeContent.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 (!hasPermanentMenuKey() || isTablet())
            actionBarRes = R.layout.browser_toolbar_menu;
         else