Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / omnibox / omnibox_prerender.h
blobeb8e79282af25b159d88b656ed24519fe0137719
1 // Copyright 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.
5 #ifndef CHROME_BROWSER_ANDROID_OMNIBOX_OMNIBOX_PRERENDER_H_
6 #define CHROME_BROWSER_ANDROID_OMNIBOX_OMNIBOX_PRERENDER_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
12 class AutocompleteResult;
13 class ProfielAndroid;
14 class Profile;
15 class TabAndroid;
16 struct AutocompleteMatch;
18 namespace content {
19 class WebContents;
22 // This class is responsible for taking the user's omnibox input text,
23 // AutocompleteResults and navigation actions and then feeding them to the
24 // AutocompleteActionPredictor. The predictor uses it to update its
25 // database and returns predictions on what page, if any, to pre-render
26 // or pre-connect. This class then takes the corresponding action.
27 class OmniboxPrerender {
28 public:
29 OmniboxPrerender(JNIEnv* env, jobject obj);
30 virtual ~OmniboxPrerender();
32 // Clears the transitional matches. This should be called when the user
33 // stops typing into the omnibox (e.g. when navigating away, closing the
34 // keyboard or changing tabs).
35 void Clear(JNIEnv* env, jobject obj, jobject j_profile_android);
37 // Initializes the underlying action predictor for a given profile instance.
38 // This should be called as soon as possible as the predictor must register
39 // for certain notifications to properly initialize before providing
40 // predictions and updated its learning database.
41 void InitializeForProfile(JNIEnv* env,
42 jobject obj,
43 jobject j_profile_android);
45 // Potentailly invokes a pre-render or pre-connect given the url typed into
46 // the omnibox and a corresponding autocomplete result. This should be
47 // invoked everytime the omnibox changes (e.g. As the user types characters
48 // this method should be invoked at least once per character).
49 void PrerenderMaybe(JNIEnv* env,
50 jobject obj,
51 jstring j_url,
52 jstring j_current_url,
53 jlong jsource_match,
54 jobject j_profile_android,
55 jobject j_tab);
57 private:
59 // Prerenders a given AutocompleteMatch's url.
60 void DoPrerender(const AutocompleteMatch& match,
61 Profile* profile,
62 content::WebContents* web_contents);
63 JavaObjectWeakGlobalRef weak_java_omnibox_;
65 DISALLOW_COPY_AND_ASSIGN(OmniboxPrerender);
68 bool RegisterOmniboxPrerender(JNIEnv* env);
70 #endif // CHROME_BROWSER_ANDROID_OMNIBOX_OMNIBOX_PRERENDER_H_