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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchBoxDataProvider.java

Issue 2838833002: 🔍 Introduce default search engine dialog (Closed)
Patch Set: COmments Created 3 years, 7 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.searchwidget; 5 package org.chromium.chrome.browser.searchwidget;
6 6
7 import org.chromium.base.library_loader.LibraryLoader; 7 import org.chromium.base.library_loader.LibraryLoader;
8 import org.chromium.chrome.browser.ntp.NewTabPage; 8 import org.chromium.chrome.browser.ntp.NewTabPage;
9 import org.chromium.chrome.browser.omnibox.LocationBarLayout;
10 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
11 import org.chromium.chrome.browser.tab.Tab; 9 import org.chromium.chrome.browser.tab.Tab;
12 import org.chromium.chrome.browser.toolbar.ToolbarDataProvider; 10 import org.chromium.chrome.browser.toolbar.ToolbarDataProvider;
13 11
14 class SearchBoxDataProvider implements ToolbarDataProvider, TemplateUrlService.L oadListener { 12 class SearchBoxDataProvider implements ToolbarDataProvider {
15 private Tab mTab; 13 private Tab mTab;
16 private String mVerbatimUrl;
17 14
18 /** 15 /**
19 * Called when native library is loaded and a tab has been initialized. 16 * Called when native library is loaded and a tab has been initialized.
20 * @param tab The tab to use. 17 * @param tab The tab to use.
21 */ 18 */
22 public void onNativeLibraryReady(Tab tab) { 19 public void onNativeLibraryReady(Tab tab) {
23 assert LibraryLoader.isInitialized(); 20 assert LibraryLoader.isInitialized();
24
25 mTab = tab; 21 mTab = tab;
26
27 TemplateUrlService service = TemplateUrlService.getInstance();
28 service.registerLoadListener(this);
29 service.load();
30 } 22 }
31 23
32 @Override 24 @Override
33 public void onTemplateUrlServiceLoaded() {
34 // For zero suggest, the default search engine's URL is used as the firs t suggestion.
35 TemplateUrlService service = TemplateUrlService.getInstance();
36 service.unregisterLoadListener(this);
37 String searchEngineUrl = service.getSearchEngineUrlFromTemplateUrl(
38 service.getDefaultSearchEngineTemplateUrl().getKeyword());
39 mVerbatimUrl = LocationBarLayout.splitPathFromUrlDisplayText(searchEngin eUrl).first;
40 }
41
42 @Override
43 public boolean isUsingBrandColor() { 25 public boolean isUsingBrandColor() {
44 return false; 26 return false;
45 } 27 }
46 28
47 @Override 29 @Override
48 public boolean isIncognito() { 30 public boolean isIncognito() {
49 if (mTab == null) return false; 31 if (mTab == null) return false;
50 return mTab.isIncognito(); 32 return mTab.isIncognito();
51 } 33 }
52 34
(...skipping 12 matching lines...) Expand all
65 return 0; 47 return 0;
66 } 48 }
67 49
68 @Override 50 @Override
69 public NewTabPage getNewTabPageForCurrentTab() { 51 public NewTabPage getNewTabPageForCurrentTab() {
70 return null; 52 return null;
71 } 53 }
72 54
73 @Override 55 @Override
74 public String getCurrentUrl() { 56 public String getCurrentUrl() {
75 return mVerbatimUrl; 57 return SearchWidgetProvider.getDefaultSearchEngineUrl();
76 } 58 }
77 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698