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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java

Issue 2838833002: 🔍 Introduce default search engine dialog (Closed)
Patch Set: Comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
index d66b67a895749d92f06cd713b45aa8d089e18ff1..7c9f022b817ecada874c32be50ba01ccd708ee9e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
@@ -28,6 +28,7 @@ import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
+import org.chromium.chrome.browser.omnibox.LocationBarLayout;
import org.chromium.chrome.browser.search_engines.TemplateUrlService;
import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListener;
import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrlServiceObserver;
@@ -123,6 +124,9 @@ public class SearchWidgetProvider extends AppWidgetProvider {
private static final Object DELEGATE_LOCK = new Object();
private static final Object OBSERVER_LOCK = new Object();
+ /** The default search engine's root URL. */
+ private static String sDefaultSearchEngineUrl;
+
private static SearchWidgetTemplateUrlServiceObserver sObserver;
private static SearchWidgetProviderDelegate sDelegate;
@@ -291,6 +295,12 @@ public class SearchWidgetProvider extends AppWidgetProvider {
TemplateUrlService service = TemplateUrlService.getInstance();
if (!service.isLoaded()) return;
+ // Update the URL that we show for zero-suggest.
+ String searchEngineUrl = service.getSearchEngineUrlFromTemplateUrl(
+ service.getDefaultSearchEngineTemplateUrl().getKeyword());
+ sDefaultSearchEngineUrl =
+ LocationBarLayout.splitPathFromUrlDisplayText(searchEngineUrl).first;
+
updateCachedEngineName(service.getDefaultSearchEngineTemplateUrl().getShortName());
}
@@ -383,4 +393,10 @@ public class SearchWidgetProvider extends AppWidgetProvider {
assert sDelegate == null;
sDelegate = delegate;
}
+
+ /** See {@link #sDefaultSearchEngineUrl}. */
+ static String getDefaultSearchEngineUrl() {
+ // TODO(yusufo): Get rid of this.
+ return sDefaultSearchEngineUrl;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698