// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.android.webview.chromium;

/**
 * Helper class used to fix up resource ids.
 * This is mostly a copy of the code in frameworks/base/core/java/android/app/LoadedApk.java.
 * TODO: Remove if a cleaner mechanism is provided (either public API or AAPT is changed to generate
 * this code).
 */
class ResourceRewriter {
    /**
     * Rewrite the R 'constants' for the WebView library apk.
     */
    public static void rewriteRValues(final int packageId) {
        // 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.
        com.android.webview.chromium.R.onResourcesLoaded(packageId);
        org.chromium.android_webview.R.onResourcesLoaded(packageId);
        org.chromium.content.R.onResourcesLoaded(packageId);
        org.chromium.ui.R.onResourcesLoaded(packageId);
    }
}

@@ -253,585 +253,392 @@
 .%0A *
- This is mostly a copy of the code in frameworks/base/core/java/android/app/LoadedApk.java.%0A * TODO: Remove if a cleaner mechanism is provided (either public API or AAPT is changed to generate%0A * this code).%0A */%0Aclass ResourceRewriter %7B%0A    /**%0A     * Rewrite the R 'constants' for the WebView library apk.%0A     */%0A    public static void rewriteRValues(final int packageId) %7B%0A        // TODO: We should use jarjar to remove the redundant R classes here, but due%0A        // to a bug in jarjar it's not possible to rename classes with '$' in their name.%0A        // See b/15684775
+/%0Aclass ResourceRewriter %7B%0A    /**%0A     * Rewrite the R 'constants' for the WebView library apk.%0A     */%0A    public static void rewriteRValues(final int packageId) %7B%0A        // This list must be kept up to date to include all R classes depended on directly or%0A        // indirectly by android_webview_java.%0A        // TODO(torne): find a better way to do this, http://crbug.com/492166
 .%0A  
@@ -765,32 +765,126 @@
 ded(packageId);%0A
+        org.chromium.components.web_contents_delegate_android.R.onResourcesLoaded(packageId);%0A
         org.chro

Add missing R class to WebView resource rewriting.