Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.prerender; | |
| 6 | |
| 7 import org.chromium.base.JNINamespace; | |
| 8 import org.chromium.chrome.browser.ContentViewUtil; | |
| 9 import org.chromium.chrome.browser.profiles.Profile; | |
| 10 | |
| 11 /** | |
| 12 * A handler class for prerender requests coming from other applications. | |
| 13 */ | |
| 14 @JNINamespace("prerender") | |
| 15 public class ExternalPrerenderHandler { | |
| 16 | |
| 17 private int mNativeExternalPrerenderHandler; | |
| 18 | |
| 19 public ExternalPrerenderHandler() { | |
| 20 mNativeExternalPrerenderHandler = nativeInit(); | |
| 21 } | |
| 22 | |
| 23 public int addPrerender(Profile profile, String url, String referrer, int wi dth, int height) { | |
| 24 if (mNativeExternalPrerenderHandler == 0) return 0; | |
| 25 int webContentsPtr = ContentViewUtil.createNativeWebContents(false); | |
|
cbentzel
2013/11/01 20:22:09
Does this need to destroy the webContents if nativ
Yusuf
2013/11/04 22:27:49
Done.
| |
| 26 if (nativeAddPrerender(mNativeExternalPrerenderHandler, profile, webCont entsPtr, | |
| 27 url, referrer, width, height)) { | |
| 28 return webContentsPtr; | |
| 29 } | |
| 30 return 0; | |
| 31 } | |
| 32 | |
| 33 public void cancelCurrentPrerender() { | |
| 34 if (mNativeExternalPrerenderHandler == 0) return; | |
| 35 nativeCancelCurrentPrerender(mNativeExternalPrerenderHandler); | |
| 36 } | |
| 37 | |
| 38 public static boolean hasPrerenderedUrl(Profile profile, String url, int web ContentsPtr) { | |
| 39 return nativeHasPrerenderedUrl(profile, url, webContentsPtr); | |
| 40 } | |
| 41 | |
| 42 private static native int nativeInit(); | |
| 43 private static native boolean nativeAddPrerender( | |
| 44 int nativeExternalPrerenderHandlerAndroid, Profile profile, | |
| 45 int webContentsPtr, String url, String referrer, int width, int heig ht); | |
| 46 private static native boolean nativeHasPrerenderedUrl( | |
| 47 Profile profile, String url, int webContentsPtr); | |
| 48 private static native void nativeCancelCurrentPrerender( | |
| 49 int nativeExternalPrerenderHandlerAndroid); | |
| 50 } | |
| OLD | NEW |