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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java

Issue 2555513003: [Android] Sort custom search engines based on last visited time and display only top 3 most recentl… (Closed)
Patch Set: Fix the conflicts Created 4 years 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/android/javatests/src/org/chromium/chrome/browser/search_engines/TemplateUrlServiceTest.java » ('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 package org.chromium.chrome.browser.search_engines; 5 package org.chromium.chrome.browser.search_engines;
6 6
7 import android.support.annotation.IntDef; 7 import android.support.annotation.IntDef;
8 import android.text.TextUtils; 8 import android.text.TextUtils;
9 9
10 import org.chromium.base.ObserverList; 10 import org.chromium.base.ObserverList;
11 import org.chromium.base.ThreadUtils; 11 import org.chromium.base.ThreadUtils;
12 import org.chromium.base.VisibleForTesting;
12 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
13 14
14 import java.lang.annotation.Retention; 15 import java.lang.annotation.Retention;
15 import java.lang.annotation.RetentionPolicy; 16 import java.lang.annotation.RetentionPolicy;
16 import java.util.ArrayList; 17 import java.util.ArrayList;
17 import java.util.List; 18 import java.util.List;
18 import java.util.regex.Matcher; 19 import java.util.regex.Matcher;
19 import java.util.regex.Pattern; 20 import java.util.regex.Pattern;
20 21
21 /** 22 /**
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 367
367 /** 368 /**
368 * Finds the URL for the search engine at the given index. 369 * Finds the URL for the search engine at the given index.
369 * @param index The templateUrl index to look up. 370 * @param index The templateUrl index to look up.
370 * @return A {@link String} that contains the url of the specified sear ch engine. 371 * @return A {@link String} that contains the url of the specified sear ch engine.
371 */ 372 */
372 public String getSearchEngineUrlFromTemplateUrl(String keyword) { 373 public String getSearchEngineUrlFromTemplateUrl(String keyword) {
373 return nativeGetSearchEngineUrlFromTemplateUrl(mNativeTemplateUrlService Android, keyword); 374 return nativeGetSearchEngineUrlFromTemplateUrl(mNativeTemplateUrlService Android, keyword);
374 } 375 }
375 376
377 @VisibleForTesting
378 public String addSearchEngineForTesting(String keyword, int ageInDays) {
379 return nativeAddSearchEngineForTesting(
380 mNativeTemplateUrlServiceAndroid, keyword, ageInDays);
381 }
382
383 @VisibleForTesting
384 public String updateLastVisitedForTesting(String keyword) {
385 return nativeUpdateLastVisitedForTesting(mNativeTemplateUrlServiceAndroi d, keyword);
386 }
387
376 private native long nativeInit(); 388 private native long nativeInit();
377 private native void nativeLoad(long nativeTemplateUrlServiceAndroid); 389 private native void nativeLoad(long nativeTemplateUrlServiceAndroid);
378 private native boolean nativeIsLoaded(long nativeTemplateUrlServiceAndroid); 390 private native boolean nativeIsLoaded(long nativeTemplateUrlServiceAndroid);
379 private native int nativeGetTemplateUrlCount(long nativeTemplateUrlServiceAn droid); 391 private native int nativeGetTemplateUrlCount(long nativeTemplateUrlServiceAn droid);
380 private native TemplateUrl nativeGetTemplateUrlAt(long nativeTemplateUrlServ iceAndroid, int i); 392 private native TemplateUrl nativeGetTemplateUrlAt(long nativeTemplateUrlServ iceAndroid, int i);
381 private native void nativeSetUserSelectedDefaultSearchProvider( 393 private native void nativeSetUserSelectedDefaultSearchProvider(
382 long nativeTemplateUrlServiceAndroid, String selectedKeyword); 394 long nativeTemplateUrlServiceAndroid, String selectedKeyword);
383 private native int nativeGetDefaultSearchProviderIndex(long nativeTemplateUr lServiceAndroid); 395 private native int nativeGetDefaultSearchProviderIndex(long nativeTemplateUr lServiceAndroid);
384 private native boolean nativeIsSearchProviderManaged(long nativeTemplateUrlS erviceAndroid); 396 private native boolean nativeIsSearchProviderManaged(long nativeTemplateUrlS erviceAndroid);
385 private native boolean nativeIsSearchByImageAvailable(long nativeTemplateUrl ServiceAndroid); 397 private native boolean nativeIsSearchByImageAvailable(long nativeTemplateUrl ServiceAndroid);
386 private native boolean nativeIsDefaultSearchEngineGoogle(long nativeTemplate UrlServiceAndroid); 398 private native boolean nativeIsDefaultSearchEngineGoogle(long nativeTemplate UrlServiceAndroid);
387 private native String nativeGetUrlForSearchQuery(long nativeTemplateUrlServi ceAndroid, 399 private native String nativeGetUrlForSearchQuery(long nativeTemplateUrlServi ceAndroid,
388 String query); 400 String query);
389 private native String nativeGetUrlForVoiceSearchQuery(long nativeTemplateUrl ServiceAndroid, 401 private native String nativeGetUrlForVoiceSearchQuery(long nativeTemplateUrl ServiceAndroid,
390 String query); 402 String query);
391 private native String nativeReplaceSearchTermsInUrl(long nativeTemplateUrlSe rviceAndroid, 403 private native String nativeReplaceSearchTermsInUrl(long nativeTemplateUrlSe rviceAndroid,
392 String query, String currentUrl); 404 String query, String currentUrl);
393 private native String nativeGetUrlForContextualSearchQuery(long nativeTempla teUrlServiceAndroid, 405 private native String nativeGetUrlForContextualSearchQuery(long nativeTempla teUrlServiceAndroid,
394 String query, String alternateTerm, boolean shouldPrefetch, String p rotocolVersion); 406 String query, String alternateTerm, boolean shouldPrefetch, String p rotocolVersion);
395 private native String nativeGetSearchEngineUrlFromTemplateUrl( 407 private native String nativeGetSearchEngineUrlFromTemplateUrl(
396 long nativeTemplateUrlServiceAndroid, String keyword); 408 long nativeTemplateUrlServiceAndroid, String keyword);
409 private native String nativeAddSearchEngineForTesting(
410 long nativeTemplateUrlServiceAndroid, String keyword, int offset);
411 private native String nativeUpdateLastVisitedForTesting(
412 long nativeTemplateUrlServiceAndroid, String keyword);
397 } 413 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/search_engines/TemplateUrlServiceTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698