// 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);
    }
}

// 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.
 */
class ResourceRewriter {
    /**
     * Rewrite the R 'constants' for the WebView library apk.
     */
    public static void rewriteRValues(final int packageId) {
        // This list must be kept up to date to include all R classes depended on directly or
        // indirectly by android_webview_java.
        // TODO(torne): find a better way to do this, http://crbug.com/492166.
        com.android.webview.chromium.R.onResourcesLoaded(packageId);
        org.chromium.android_webview.R.onResourcesLoaded(packageId);
        org.chromium.components.web_contents_delegate_android.R.onResourcesLoaded(packageId);
        org.chromium.content.R.onResourcesLoaded(packageId);
        org.chromium.ui.R.onResourcesLoaded(packageId);
    }
}

Add missing R class to WebView resource rewriting.
Add missing R class to WebView resource rewriting.

We weren't rewriting the resources for web_contents_delegate_android,
resulting in crashes any time a resource was loaded by that component
(e.g. popup bubbles for HTML form validation failures). Add it to the
list and also clean up outdated comments here that refer to previous
versions of this code. Add a TODO to track finding a better way to do
this which is less fragile.

BUG=490826

Review URL: https://codereview.chromium.org/1154853005

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#331356}
