diff options
author | Mathew Inwood <mathewi@google.com> | 2011-08-10 12:37:43 +0100 |
---|---|---|
committer | Mathew Inwood <mathewi@google.com> | 2011-08-10 13:09:31 +0100 |
commit | dffa72f926d051c089981adf52a44d2c933a0de4 (patch) | |
tree | 4fad21512dcb7345f49d86931172202c497305e5 /src/com/android | |
parent | 864a2200268f9a9fc3edfad1f4ac1bab60d4fab1 (diff) | |
download | packages_apps_Browser-dffa72f926d051c089981adf52a44d2c933a0de4.zip packages_apps_Browser-dffa72f926d051c089981adf52a44d2c933a0de4.tar.gz packages_apps_Browser-dffa72f926d051c089981adf52a44d2c933a0de4.tar.bz2 |
Support for calling oncancel on the SearchBox API while preloading.
See also: I39a5765d2382f9c88c652d156a4917fd07cea3a4
Bug: 5035246
Change-Id: I7de6b8a718e4190480537412a8235892ee7c7aee
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/browser/PreloadRequestReceiver.java | 4 | ||||
-rw-r--r-- | src/com/android/browser/PreloadedTabControl.java | 13 | ||||
-rw-r--r-- | src/com/android/browser/Preloader.java | 9 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/browser/PreloadRequestReceiver.java b/src/com/android/browser/PreloadRequestReceiver.java index 5176176..ff3c8e3 100644 --- a/src/com/android/browser/PreloadRequestReceiver.java +++ b/src/com/android/browser/PreloadRequestReceiver.java @@ -39,6 +39,7 @@ public class PreloadRequestReceiver extends BroadcastReceiver { private static final String ACTION_PRELOAD = "android.intent.action.PRELOAD"; static final String EXTRA_PRELOAD_ID = "preload_id"; static final String EXTRA_PRELOAD_DISCARD = "preload_discard"; + static final String EXTRA_SEARCHBOX_CANCEL = "searchbox_cancel"; static final String EXTRA_SEARCHBOX_SETQUERY = "searchbox_query"; @Override @@ -61,6 +62,9 @@ public class PreloadRequestReceiver extends BroadcastReceiver { if (i.getBooleanExtra(EXTRA_PRELOAD_DISCARD, false)) { if (LOGD_ENABLED) Log.d(LOGTAG, "Got " + id + " preload discard request"); Preloader.getInstance().discardPreload(id); + } else if (i.getBooleanExtra(EXTRA_SEARCHBOX_CANCEL, false)) { + if (LOGD_ENABLED) Log.d(LOGTAG, "Got " + id + " searchbox cancel request"); + Preloader.getInstance().cancelSearchBoxPreload(id); } else { if (LOGD_ENABLED) Log.d(LOGTAG, "Got " + id + " preload request for " + url); if (url != null && url.startsWith("http")) { diff --git a/src/com/android/browser/PreloadedTabControl.java b/src/com/android/browser/PreloadedTabControl.java index 824c00b..ed066f2 100644 --- a/src/com/android/browser/PreloadedTabControl.java +++ b/src/com/android/browser/PreloadedTabControl.java @@ -89,6 +89,19 @@ public class PreloadedTabControl { return true; } + public void searchBoxCancel() { + SearchBox sb = mTab.getWebView().getSearchBox(); + if (sb != null) { + mLastQuery = null; + sb.oncancel(new SearchBox.SearchBoxListener(){ + @Override + public void onCancelComplete(boolean called) { + if (LOGD_ENABLED) Log.d(LOGTAG, "Query cancelled: " + called); + } + }); + } + } + public void loadUrlIfChanged(String url, Map<String, String> headers) { String currentUrl = mTab.getUrl(); if (!TextUtils.isEmpty(currentUrl)) { diff --git a/src/com/android/browser/Preloader.java b/src/com/android/browser/Preloader.java index 3d30c96..3273a8c 100644 --- a/src/com/android/browser/Preloader.java +++ b/src/com/android/browser/Preloader.java @@ -106,6 +106,15 @@ public class Preloader { } } + public void cancelSearchBoxPreload(String id) { + PreloaderSession s = getSession(id); + if (s != null) { + s.touch(); // reset timer + PreloadedTabControl tab = s.getTabControl(); + tab.searchBoxCancel(); + } + } + public void discardPreload(String id) { PreloaderSession s = takeSession(id); if (s != null) { |