diff options
author | apiccion@chromium.org <apiccion@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 12:17:35 +0000 |
---|---|---|
committer | apiccion@chromium.org <apiccion@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 12:17:35 +0000 |
commit | a679e42fffa709c69aec93eb4e7cbcd9fd1e9f55 (patch) | |
tree | 8340e2297cb6878556fde4c89ce8f3bf055d7811 /chrome/android/java | |
parent | 6790829574756765572a05fc9c94ec555020834e (diff) | |
download | chromium_src-a679e42fffa709c69aec93eb4e7cbcd9fd1e9f55.zip chromium_src-a679e42fffa709c69aec93eb4e7cbcd9fd1e9f55.tar.gz chromium_src-a679e42fffa709c69aec93eb4e7cbcd9fd1e9f55.tar.bz2 |
Added OmniboxAndroid class to handle prerender related logic.
BUG=166665
Review URL: https://chromiumcodereview.appspot.com/21061005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/android/java')
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxPrerender.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxPrerender.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxPrerender.java new file mode 100644 index 0000000..a99e765 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxPrerender.java @@ -0,0 +1,74 @@ +// Copyright 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.omnibox; + +import org.chromium.chrome.browser.profiles.Profile; + +/** + * Java bridge to handle conditional prerendering using autocomplete results * as the user types + * into the Omnibox. + * + * OmniboxPrerender takes keystrokes, autocomplete results and navigation actions then feeds + * them to the (native) AutocompleteActionPredictor. The predictor uses this data to update its + * database and returns predictions on what page, if any, to pre-render or pre-connect. + * + */ +public class OmniboxPrerender { + private int mNativeOmniboxPrerender = 0; + + /** + * Constructor for creating a OmniboxPrerender instanace. + */ + public OmniboxPrerender() { + mNativeOmniboxPrerender = nativeInit(); + } + + /** + * Clears the transitional matches. This should be called when the user stops typing into + * the omnibox (e.g. when navigating away, closing the keyboard or changing tabs) + * + * @param profile profile instance corresponding to the active profile. + */ + public void clear(Profile profile) { + nativeClear(mNativeOmniboxPrerender, profile); + } + + /** + * Initializes the underlying action predictor for a given profile instance. This should be + * called as soon as possible as the predictor must register for certain notifications to + * properly initialize before providing predictions and updated its learning database. + * + * @param profile profile instance corresponding to active profile. + */ + public void initializeForProfile(Profile profile) { + nativeInitializeForProfile(mNativeOmniboxPrerender, profile); + } + + /** + * Potentailly invokes a pre-render or pre-connect given the url typed into the omnibox and + * a corresponding autocomplete result. This should be invoked everytime the omnibox changes + * (e.g. As the user types characters this method should be invoked at least once per character) + * + * @param url url in the omnibox. + * @param currentUrl url the current tab is displaying. + * @param nativeAutocompleteResult native pointer to an autocomplete result. + * @param profile profile instance corresponding to the active profile. + * @param nativeWebContents native pointer to a web contents instance. + */ + public void prerenderMaybe(String url, String currentUrl, int nativeAutocompleteResult, + Profile profile, int nativeWebContents) { + nativePrerenderMaybe(mNativeOmniboxPrerender, url, currentUrl, nativeAutocompleteResult, + profile, nativeWebContents); + } + + private native int nativeInit(); + private native void nativeClear(int nativeOmniboxPrerender, Profile profile); + private native void nativeInitializeForProfile( + int nativeOmniboxPrerender, + Profile profile); + private native void nativePrerenderMaybe(int nativeOmniboxPrerender, String url, + String currentUrl, int nativeAutocompleteResult, Profile profile, + int nativeWebContents); +} |