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

Side by Side Diff: chrome/browser/android/omnibox/omnibox_prerender.cc

Issue 2652763013: Cleanup: Remove the last traces of Instant Search on Android (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/android/toolbar/toolbar_model_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/omnibox/omnibox_prerender.h" 5 #include "chrome/browser/android/omnibox/omnibox_prerender.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/android/tab_android.h" 9 #include "chrome/browser/android/tab_android.h"
10 #include "chrome/browser/predictors/autocomplete_action_predictor.h" 10 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
11 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" 11 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_android.h" 13 #include "chrome/browser/profiles/profile_android.h"
14 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
15 #include "components/omnibox/browser/autocomplete_match.h" 14 #include "components/omnibox/browser/autocomplete_match.h"
16 #include "components/omnibox/browser/autocomplete_result.h" 15 #include "components/omnibox/browser/autocomplete_result.h"
17 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
18 #include "jni/OmniboxPrerender_jni.h" 17 #include "jni/OmniboxPrerender_jni.h"
19 #include "url/gurl.h" 18 #include "url/gurl.h"
20 19
21 using base::android::JavaParamRef; 20 using base::android::JavaParamRef;
22 using predictors::AutocompleteActionPredictor; 21 using predictors::AutocompleteActionPredictor;
23 using predictors::AutocompleteActionPredictorFactory; 22 using predictors::AutocompleteActionPredictorFactory;
24 23
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (!autocomplete_result) 83 if (!autocomplete_result)
85 return; 84 return;
86 if (!profile) 85 if (!profile)
87 return; 86 return;
88 87
89 const AutocompleteResult::const_iterator default_match( 88 const AutocompleteResult::const_iterator default_match(
90 autocomplete_result->default_match()); 89 autocomplete_result->default_match());
91 if (default_match == autocomplete_result->end()) 90 if (default_match == autocomplete_result->end())
92 return; 91 return;
93 92
93 AutocompleteActionPredictor* action_predictor =
94 AutocompleteActionPredictorFactory::GetForProfile(profile);
95 if (!action_predictor)
96 return;
97
98 action_predictor->
99 RegisterTransitionalMatches(url_string, *autocomplete_result);
94 AutocompleteActionPredictor::Action recommended_action = 100 AutocompleteActionPredictor::Action recommended_action =
95 AutocompleteActionPredictor::ACTION_NONE; 101 action_predictor->RecommendAction(url_string, *default_match);
96 InstantSearchPrerenderer* prerenderer =
97 InstantSearchPrerenderer::GetForProfile(profile);
98 if (prerenderer &&
99 prerenderer->IsAllowed(*default_match, web_contents)) {
100 recommended_action = AutocompleteActionPredictor::ACTION_PRERENDER;
101 } else {
102 AutocompleteActionPredictor* action_predictor =
103 AutocompleteActionPredictorFactory::GetForProfile(profile);
104 if (!action_predictor)
105 return;
106
107 if (action_predictor) {
108 action_predictor->
109 RegisterTransitionalMatches(url_string, *autocomplete_result);
110 recommended_action =
111 action_predictor->RecommendAction(url_string, *default_match);
112 }
113 }
114 102
115 GURL current_url = GURL(current_url_string); 103 GURL current_url = GURL(current_url_string);
116 switch (recommended_action) { 104 switch (recommended_action) {
117 case AutocompleteActionPredictor::ACTION_PRERENDER: 105 case AutocompleteActionPredictor::ACTION_PRERENDER:
118 // Ask for prerendering if the destination URL is different than the 106 // Ask for prerendering if the destination URL is different than the
119 // current URL. 107 // current URL.
120 if (default_match->destination_url != current_url) { 108 if (default_match->destination_url != current_url) {
121 DoPrerender( 109 DoPrerender(
122 *default_match, 110 *default_match,
123 profile, 111 profile,
(...skipping 14 matching lines...) Expand all
138 void OmniboxPrerender::DoPrerender(const AutocompleteMatch& match, 126 void OmniboxPrerender::DoPrerender(const AutocompleteMatch& match,
139 Profile* profile, 127 Profile* profile,
140 content::WebContents* web_contents) { 128 content::WebContents* web_contents) {
141 DCHECK(profile); 129 DCHECK(profile);
142 if (!profile) 130 if (!profile)
143 return; 131 return;
144 DCHECK(web_contents); 132 DCHECK(web_contents);
145 if (!web_contents) 133 if (!web_contents)
146 return; 134 return;
147 gfx::Rect container_bounds = web_contents->GetContainerBounds(); 135 gfx::Rect container_bounds = web_contents->GetContainerBounds();
148 InstantSearchPrerenderer* prerenderer =
149 InstantSearchPrerenderer::GetForProfile(profile);
150 if (prerenderer && prerenderer->IsAllowed(match, web_contents)) {
151 prerenderer->Init(
152 web_contents->GetController().GetDefaultSessionStorageNamespace(),
153 container_bounds.size());
154 return;
155 }
156 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile)-> 136 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile)->
157 StartPrerendering( 137 StartPrerendering(
158 match.destination_url, 138 match.destination_url,
159 web_contents->GetController().GetDefaultSessionStorageNamespace(), 139 web_contents->GetController().GetDefaultSessionStorageNamespace(),
160 container_bounds.size()); 140 container_bounds.size());
161 } 141 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/android/toolbar/toolbar_model_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698