Pass attached HTTP headers to WebView from voice search.
Fix for http://b/issue?id=2496144
Change-Id: I245e7e47a31158a9082a33c1ebcfb7dcf924ee08
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index e502e5b..7bb6ca6 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -18,7 +18,10 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
import java.util.Vector;
import android.app.AlertDialog;
@@ -221,6 +224,9 @@
}
mVoiceSearchData = new VoiceSearchData(results, urls, htmls,
baseUrls);
+ mVoiceSearchData.mHeaders = intent.getParcelableArrayListExtra(
+ RecognizerResultsIntent
+ .EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS);
mVoiceSearchData.mSourceIsGoogle = intent.getBooleanExtra(
VoiceSearchData.SOURCE_IS_GOOGLE, false);
} else {
@@ -278,7 +284,21 @@
mVoiceSearchData.mLastVoiceSearchUrl = mActivity.smartUrlFilter(
mVoiceSearchData.mLastVoiceSearchTitle);
}
- mMainView.loadUrl(mVoiceSearchData.mLastVoiceSearchUrl);
+ Map<String, String> headers = null;
+ if (mVoiceSearchData.mHeaders != null) {
+ int bundleIndex = mVoiceSearchData.mHeaders.size() == 1 ? 0
+ : index;
+ Bundle bundle = mVoiceSearchData.mHeaders.get(bundleIndex);
+ if (bundle != null && !bundle.isEmpty()) {
+ Iterator<String> iter = bundle.keySet().iterator();
+ headers = new HashMap<String, String>();
+ while (iter.hasNext()) {
+ String key = iter.next();
+ headers.put(key, bundle.getString(key));
+ }
+ }
+ }
+ mMainView.loadUrl(mVoiceSearchData.mLastVoiceSearchUrl, headers);
}
/* package */ static class VoiceSearchData {
public VoiceSearchData(ArrayList<String> results,
@@ -327,6 +347,11 @@
*/
public boolean mSourceIsGoogle;
/**
+ * List of headers to be passed into the WebView containing location
+ * information
+ */
+ public ArrayList<Bundle> mHeaders;
+ /**
* The Intent used to invoke voice search. Placed on the
* WebHistoryItem so that when coming back to a previous voice search
* page we can again activate voice search.