// 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 org.chromium.chrome.browser.banners;

import org.chromium.base.VisibleForTesting;

/**
 * Fetches data about the given app.
 */
public abstract class AppDetailsDelegate {
    /**
     * Class to inform when the app's details have been retrieved.
     */
    public interface Observer {
        /**
         * Called when the task has finished.
         * @param data Data about the requested package.  Will be null if retrieval failed.
         */
        @VisibleForTesting
        public void onAppDetailsRetrieved(AppData data);
    }

    /**
     * Retrieves information about the given package asynchronously.  When details have been
     * retrieved, the observer is alerted.
     * @param observer    Informed when the app details have been received.
     * @param url         URL of the page requesting a banner.
     * @param packageName Name of the app's package.
     * @param iconSize    Size of the icon to retrieve.
     */
    protected abstract void getAppDetailsAsynchronously(
            Observer observer, String url, String packageName, int iconSize);

    /**
     * Destroy the delegate, cleaning up any open hooks.
     */
    public abstract void destroy();
}

// 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 org.chromium.chrome.browser.banners;

import org.chromium.base.VisibleForTesting;

/**
 * Fetches data about the given app.
 */
public abstract class AppDetailsDelegate {
    /**
     * Class to inform when the app's details have been retrieved.
     */
    public interface Observer {
        /**
         * Called when the task has finished.
         * @param data Data about the requested package.  Will be null if retrieval failed.
         */
        @VisibleForTesting
        public void onAppDetailsRetrieved(AppData data);
    }

    /**
     * Retrieves information about the given package asynchronously.  When details have been
     * retrieved, the observer is alerted.
     * @param observer    Informed when the app details have been received.
     * @param url         URL of the page requesting a banner.
     * @param packageName Name of the app's package.
     * @param iconSize    Size of the icon to retrieve.
     */
    protected void getAppDetailsAsynchronously(
            Observer observer, String url, String packageName, int iconSize) { }

    /**
     * Retrieves information about the given package asynchronously.  When details have been
     * retrieved, the observer is alerted.
     * @param observer    Informed when the app details have been received.
     * @param url         URL of the page requesting a banner.
     * @param packageName Name of the app's package.
     * @param referrer    Referrer specified by the page requesting a banner.
     * @param iconSize    Size of the icon to retrieve.
     */
    protected void getAppDetailsAsynchronously(
            Observer observer, String url, String packageName, String referrer, int iconSize) { }

    /**
     * Destroy the delegate, cleaning up any open hooks.
     */
    public abstract void destroy();
}

Add a referrer parameter to the app details fetcher.
Add a referrer parameter to the app details fetcher.

This is the first part of a three-sided patch which will allow
developers to specify a referrer in the URL of a manifest related
application. The referrer will then be added to the app details
fetch and sent to the relevant store (currently just the Play Store).

The outdated method and dummy implementations will be removed in the
third side of this patch once the relevant downstream method is updated.

BUG=503226

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

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