Fix styled attribute resolution in WebView.

We need to correctly style the resource ID for the current app rather
than just extracting the resource from the Theme.

Bug: 10110507
Change-Id: I1d6a90580c95f23fdb36a53557f675bb820b314f
(cherry picked from commit 8a6963ba9b282825e8932e018ab6e2e53ddd9260)
diff --git a/chromium/java/com/android/webview/chromium/ResourceProvider.java b/chromium/java/com/android/webview/chromium/ResourceProvider.java
index b48aa24..5ad5f78 100644
--- a/chromium/java/com/android/webview/chromium/ResourceProvider.java
+++ b/chromium/java/com/android/webview/chromium/ResourceProvider.java
@@ -19,7 +19,7 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.os.Build;
-import android.util.TypedValue;
+import android.content.res.TypedArray;
 
 import org.chromium.android_webview.AwResource;
 
@@ -35,8 +35,6 @@
 
         AwResource.setResources(context.getResources());
 
-        Resources.Theme theme = context.getTheme();
-
         // color
         org.chromium.ui.R.color.color_picker_border_color =
                 com.android.internal.R.color.webviewchromium_color_picker_border_color;
@@ -49,9 +47,9 @@
         // drawable
 
         org.chromium.content.R.drawable.ic_menu_share_holo_light =
-                resolveThemeAttr(theme, com.android.internal.R.attr.actionModeShareDrawable);
-        org.chromium.content.R.drawable.ic_menu_search_holo_light =
-                resolveThemeAttr(theme, com.android.internal.R.attr.actionModeWebSearchDrawable);
+                resolveStyledAttr(context, com.android.internal.R.attr.actionModeShareDrawable);
+        org.chromium.content.R.drawable.ic_menu_search_holo_light = resolveStyledAttr(context,
+                com.android.internal.R.attr.actionModeWebSearchDrawable);
         org.chromium.content.R.drawable.ondemand_overlay =
                 com.android.internal.R.drawable.webviewchromium_ondemand_overlay;
 
@@ -209,10 +207,11 @@
         sInitialized = true;
     }
 
-    private static int resolveThemeAttr(Resources.Theme theme, int attr) {
-        TypedValue valueHolder = new TypedValue();
-        theme.resolveAttribute(attr, valueHolder, true);
-        return valueHolder.resourceId;
+    private static int resolveStyledAttr(Context context, int attr) {
+        TypedArray styledAttribute = context.obtainStyledAttributes(new int[] { attr });
+        int styledResource = styledAttribute.getResourceId(0, 0);
+        styledAttribute.recycle();
+        return styledResource;
     }
 
     // Verify that all the fields of the inner classes of |R| have a valid mapping.