root/content/public/android/java/src/org/chromium/content/browser/InterstitialPageDelegateAndroid.java

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. JNINamespace
  2. getNative
  3. onProceed
  4. onDontProceed
  5. commandReceived
  6. onNativeDestroyed
  7. proceed
  8. dontProceed
  9. nativeInit
  10. nativeProceed
  11. nativeDontProceed

// Copyright 2012 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.content.browser;

import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;

/**
 * Allows the specification and handling of Interstitial pages in java.
 */
@JNINamespace("content")
public class InterstitialPageDelegateAndroid {

    private long mNativePtr;

    /**
     * Constructs an interstitial with the given HTML content.
     *
     * @param htmlContent The HTML content for the interstitial.
     */
    public InterstitialPageDelegateAndroid(String htmlContent) {
        mNativePtr = nativeInit(htmlContent);
    }

    /**
     * @return The pointer to the underlying native counterpart.
     */
    public long getNative() {
        return mNativePtr;
    }

    /**
     * Called when "proceed" is triggered on the interstitial.
     */
    @CalledByNative
    protected void onProceed() {
    }

    /**
     * Called when "dont' proceed" is triggered on the interstitial.
     */
    @CalledByNative
    protected void onDontProceed() {
    }

    /**
     * Called when a command has been received from the interstitial.
     *
     * @param command The command that was received.
     */
    @CalledByNative
    protected void commandReceived(String command) {
    }

    @CalledByNative
    private void onNativeDestroyed() {
        mNativePtr = 0;
    }

    /**
     * Notifies the native interstitial to proceed.
     */
    protected void proceed() {
        if (mNativePtr != 0) nativeProceed(mNativePtr);
    }

    /**
     * Notifies the native interstitial to not proceed.
     */
    protected void dontProceed() {
        if (mNativePtr != 0) nativeDontProceed(mNativePtr);
    }

    private native long nativeInit(String htmlContent);
    private native void nativeProceed(long nativeInterstitialPageDelegateAndroid);
    private native void nativeDontProceed(long nativeInterstitialPageDelegateAndroid);
}

/* [<][>][^][v][top][bottom][index][help] */