Don't use reflection to rewrite the WebView resources.

Bug: 16870075
Change-Id: Ie65a3a277ecb3c55622d5bab5916833768b1f21b
diff --git a/chromium/java/com/android/webview/chromium/ResourceRewriter.java b/chromium/java/com/android/webview/chromium/ResourceRewriter.java
index 637a64f..99fa46f 100644
--- a/chromium/java/com/android/webview/chromium/ResourceRewriter.java
+++ b/chromium/java/com/android/webview/chromium/ResourceRewriter.java
@@ -45,57 +45,11 @@
             // TODO: We should use jarjar to remove the redundant R classes here, but due
             // to a bug in jarjar it's not possible to rename classes with '$' in their name.
             // See b/15684775.
-            rewriteRValues(com.android.webview.chromium.R.class, id);
-            rewriteRValues(org.chromium.content.R.class, id);
-            rewriteRValues(org.chromium.ui.R.class, id);
+            com.android.webview.chromium.R.onResourcesLoaded(id);
+            org.chromium.ui.R.onResourcesLoaded(id);
+            org.chromium.content.R.onResourcesLoaded(id);
 
             break;
         }
-
     }
-
-    private static void rewriteIntField(Field field, int packageId) throws IllegalAccessException {
-        int requiredModifiers = Modifier.STATIC | Modifier.PUBLIC;
-        int bannedModifiers = Modifier.FINAL;
-
-        int mod = field.getModifiers();
-        if ((mod & requiredModifiers) != requiredModifiers ||
-                (mod & bannedModifiers) != 0) {
-            throw new IllegalArgumentException("Field " + field.getName() +
-                    " is not rewritable");
-        }
-
-        Class<?> fieldType = field.getType();
-        if (fieldType != int.class && fieldType != Integer.class) {
-            throw new IllegalArgumentException("Field " + field.getName() +
-                    " is not an integer");
-        }
-
-        try {
-            int resId = field.getInt(null);
-            int newId = (resId & 0x00ffffff) | (packageId << 24);
-            field.setInt(null, newId);
-        } catch (IllegalAccessException e) {
-            // This should not occur (we check above if we can write to it)
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    private static void rewriteRValues(final Class<?> rClazz, int id) {
-        try {
-            for (Class<?> clazz : rClazz.getDeclaredClasses()) {
-                try {
-                    for (Field field : clazz.getDeclaredFields()) {
-                            rewriteIntField(field, id);
-                    }
-                } catch (Exception e) {
-                    throw new IllegalArgumentException("Failed to rewrite R values for " +
-                            clazz.getName(), e);
-                }
-            }
-        } catch (Exception e) {
-            throw new IllegalArgumentException("Failed to rewrite R values", e);
-        }
-    }
-
 }