unify voice search code

Change-Id: Icf1fc84405d08da8504ac91094e67c7d8d1c901d
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index f1fcdc3..361e94c 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -17,12 +17,8 @@
 package com.android.browser;
 
 import android.app.Activity;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
-import android.speech.RecognizerIntent;
 import android.text.SpannableString;
 import android.text.Spanned;
 import android.text.TextUtils;
@@ -50,7 +46,6 @@
     private Drawable mBookmarkDrawable;
     private Drawable mVoiceDrawable;
     private boolean mInLoad;
-    private Intent mVoiceSearchIntent;
     private ImageSpan mArcsSpan;
     private View mContainer;
 
@@ -78,25 +73,9 @@
 
         mHorizontalProgress = (PageProgressView) findViewById(
                 R.id.progress_horizontal);
-        mVoiceSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
-        mVoiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
-                RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
-        // This extra tells voice search not to send the application id in its
-        // results intent - http://b/2546173
-        //
-        // TODO: Make a constant for this extra.
-        mVoiceSearchIntent.putExtra("android.speech.extras.SEND_APPLICATION_ID_EXTRA",
-                false);
-        PackageManager pm = activity.getPackageManager();
-        ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent,
-                PackageManager.MATCH_DEFAULT_ONLY);
         Resources resources = getResources();
-        if (ri == null) {
-            mVoiceSearchIntent = null;
-        } else {
-            mVoiceDrawable = resources.getDrawable(
-                    android.R.drawable.ic_btn_speak_now);
-        }
+        mVoiceDrawable = resources.getDrawable(
+                android.R.drawable.ic_btn_speak_now);
         mBookmarkDrawable = mBookmarkButton.getDrawable();
         mArcsSpan = new ImageSpan(activity, R.drawable.arcs,
                 ImageSpan.ALIGN_BASELINE);
@@ -122,7 +101,7 @@
     @Override
     void setInVoiceMode(boolean inVoiceMode) {
         if (mInVoiceMode == inVoiceMode) return;
-        mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null;
+        mInVoiceMode = inVoiceMode && mUiController.supportsVoiceSearch();
         Drawable titleDrawable;
         if (mInVoiceMode) {
             mBookmarkButton.setImageDrawable(mVoiceDrawable);