Fix intent handling

 Bug: 5405096
 If state != null, don't process the intent in getIntent, it will be
 stale

Change-Id: Icc854a1d8f11fdbd60c1f7f854053f2294864b0f
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 602df06..edec96f 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -336,8 +336,11 @@
             // TabControl.restoreState() will create a new tab even if
             // restoring the state fails.
             setActiveTab(mTabControl.getCurrentTab());
-            // Handle the intent
-            mIntentHandler.onNewIntent(intent);
+            // Handle the intent if needed. If icicle != null, we are restoring
+            // and the intent will be stale - ignore it.
+            if (icicle == null) {
+                mIntentHandler.onNewIntent(intent);
+            }
         }
         // Read JavaScript flags if it exists.
         String jsFlags = getSettings().getJsEngineFlags();
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java
index cc6b57c..c76197d 100644
--- a/src/com/android/browser/IntentHandler.java
+++ b/src/com/android/browser/IntentHandler.java
@@ -65,7 +65,6 @@
     }
 
     void onNewIntent(Intent intent) {
-        mActivity.setIntent(null);
         Tab current = mTabControl.getCurrentTab();
         // When a tab is closed on exit, the current tab index is set to -1.
         // Reset before proceed as Browser requires the current tab to be set.