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

Side by Side Diff: chrome/browser/search_engines/template_url_service_android.cc

Issue 601003002: Add a template url accessor for contextual search that doesn't preload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add back the accessor with the current signature for compatability. Created 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/search_engines/template_url_service_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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/search_engines/template_url_service_android.h" 5 #include "chrome/browser/search_engines/template_url_service_android.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 env, destination_url.spec()); 197 env, destination_url.spec());
198 } 198 }
199 return base::android::ScopedJavaLocalRef<jstring>(env, NULL); 199 return base::android::ScopedJavaLocalRef<jstring>(env, NULL);
200 } 200 }
201 201
202 base::android::ScopedJavaLocalRef<jstring> 202 base::android::ScopedJavaLocalRef<jstring>
203 TemplateUrlServiceAndroid::GetUrlForContextualSearchQuery( 203 TemplateUrlServiceAndroid::GetUrlForContextualSearchQuery(
204 JNIEnv* env, 204 JNIEnv* env,
205 jobject obj, 205 jobject obj,
206 jstring jquery, 206 jstring jquery,
207 jstring jalternate_term) { 207 jstring jalternate_term,
208 jboolean jshould_prefetch) {
208 base::string16 query(base::android::ConvertJavaStringToUTF16(env, jquery)); 209 base::string16 query(base::android::ConvertJavaStringToUTF16(env, jquery));
209 std::string url; 210 std::string url;
210 211
211 if (!query.empty()) { 212 if (!query.empty()) {
212 GURL gurl(GetDefaultSearchURLForSearchTerms(template_url_service_, query)); 213 GURL gurl(GetDefaultSearchURLForSearchTerms(template_url_service_, query));
213 if (google_util::IsGoogleSearchUrl(gurl)) { 214 if (google_util::IsGoogleSearchUrl(gurl)) {
214 gurl = net::AppendQueryParameter(gurl, "ctxs", "2"); 215 gurl = net::AppendQueryParameter(gurl, "ctxs", "2");
215 // Indicate that the search page is being prefetched. 216 if (jshould_prefetch) {
216 gurl = net::AppendQueryParameter(gurl, "pf", "c"); 217 // Indicate that the search page is being prefetched.
218 gurl = net::AppendQueryParameter(gurl, "pf", "c");
219 }
217 220
218 if (jalternate_term) { 221 if (jalternate_term) {
219 std::string alternate_term( 222 std::string alternate_term(
220 base::android::ConvertJavaStringToUTF8(env, jalternate_term)); 223 base::android::ConvertJavaStringToUTF8(env, jalternate_term));
221 if (!alternate_term.empty()) { 224 if (!alternate_term.empty()) {
222 gurl = net::AppendQueryParameter( 225 gurl = net::AppendQueryParameter(
223 gurl, "ctxsl_alternate_term", alternate_term); 226 gurl, "ctxsl_alternate_term", alternate_term);
224 } 227 }
225 } 228 }
226 } 229 }
227 url = gurl.spec(); 230 url = gurl.spec();
228 } 231 }
229 232
230 return base::android::ConvertUTF8ToJavaString(env, url); 233 return base::android::ConvertUTF8ToJavaString(env, url);
231 } 234 }
232 235
233 static jlong Init(JNIEnv* env, jobject obj) { 236 static jlong Init(JNIEnv* env, jobject obj) {
234 TemplateUrlServiceAndroid* template_url_service_android = 237 TemplateUrlServiceAndroid* template_url_service_android =
235 new TemplateUrlServiceAndroid(env, obj); 238 new TemplateUrlServiceAndroid(env, obj);
236 return reinterpret_cast<intptr_t>(template_url_service_android); 239 return reinterpret_cast<intptr_t>(template_url_service_android);
237 } 240 }
238 241
239 // static 242 // static
240 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { 243 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) {
241 return RegisterNativesImpl(env); 244 return RegisterNativesImpl(env);
242 } 245 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698