Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2126)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java

Issue 45693002: Add ExternalPrerenderRequestHandler and related API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed the files Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d0da7f4e09f502cc6e4de2344fc77bef70be9a4
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 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.prerender;
+
+import org.chromium.base.JNINamespace;
+import org.chromium.chrome.browser.ContentViewUtil;
+import org.chromium.chrome.browser.profiles.Profile;
+
+/**
+ * A handler class for prerender requests coming from other applications.
+ */
+@JNINamespace("prerender")
+public class ExternalPrerenderHandler {
+
+ private int mNativeExternalPrerenderHandler;
+
+ public ExternalPrerenderHandler() {
+ mNativeExternalPrerenderHandler = nativeInit();
+ }
+
+ public int addPrerender(Profile profile, String url, String referrer, int width, int height) {
+ if (mNativeExternalPrerenderHandler == 0) return 0;
+ int webContentsPtr = ContentViewUtil.createNativeWebContents(false);
+ if (nativeAddPrerender(mNativeExternalPrerenderHandler, profile, webContentsPtr,
+ url, referrer, width, height)) {
+ return webContentsPtr;
+ }
+ return 0;
+ }
+
+ public void cancelCurrentPrerender() {
+ if (mNativeExternalPrerenderHandler == 0) return;
+ nativeCancelCurrentPrerender(mNativeExternalPrerenderHandler);
+ }
+
+ public static boolean hasPrerenderedUrl(Profile profile, String url, int webContentsPtr) {
+ return nativeHasPrerenderedUrl(profile, url, webContentsPtr);
+ }
+
+ private static native int nativeInit();
+ private static native boolean nativeAddPrerender(
+ int nativeExternalPrerenderHandlerAndroid, Profile profile,
+ int webContentsPtr, String url, String referrer, int width, int height);
+ private static native boolean nativeHasPrerenderedUrl(
+ Profile profile, String url, int webContentsPtr);
+ private static native void nativeCancelCurrentPrerender(
+ int nativeExternalPrerenderHandlerAndroid);
+}

Powered by Google App Engine
This is Rietveld 408576698