Disable URL overriding on redirects

 Bug: 5334118
 When sending an intent for a URL with specialized handlers, tag
 it with an extra that will surpress subsequent redirections

Change-Id: I997aa79192baea86c58958ab213200d57ec4c4f9
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 0cf598f..7cb00d9 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -156,6 +156,7 @@
     // If true, the tab is in page loading state (after onPageStarted,
     // before onPageFinsihed)
     private boolean mInPageLoad;
+    private boolean mDisableOverrideUrlLoading;
     // The last reported progress of the current page
     private int mPageLoadProgress;
     // The time the load started, used to find load page time
@@ -373,6 +374,7 @@
 
         @Override
         public void onPageFinished(WebView view, String url) {
+            mDisableOverrideUrlLoading = false;
             if (!isPrivateBrowsingEnabled()) {
                 LogTag.logPageFinishedLoading(
                         url, SystemClock.uptimeMillis() - mLoadStartTime);
@@ -384,7 +386,7 @@
         // return true if want to hijack the url to let another app to handle it
         @Override
         public boolean shouldOverrideUrlLoading(WebView view, String url) {
-            if (mInForeground) {
+            if (!mDisableOverrideUrlLoading && mInForeground) {
                 return mWebViewController.shouldOverrideUrlLoading(Tab.this,
                         view, url);
             } else {
@@ -1895,6 +1897,10 @@
         }
     }
 
+    public void disableUrlOverridingForLoad() {
+        mDisableOverrideUrlLoading = true;
+    }
+
     protected void capture() {
         if (mMainView == null || mCapture == null) return;
         if (mMainView.getContentWidth() <= 0 || mMainView.getContentHeight() <= 0) {