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

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

Issue 2898823002: Add metrics for search engine promo and search widget (Closed)
Patch Set: removed assert for test (expectations changed) Created 3 years, 6 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 android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.PendingIntent; 8 import android.app.PendingIntent;
9 import android.appwidget.AppWidgetManager; 9 import android.appwidget.AppWidgetManager;
10 import android.appwidget.AppWidgetProvider; 10 import android.appwidget.AppWidgetProvider;
(...skipping 10 matching lines...) Expand all
21 import android.widget.RemoteViews; 21 import android.widget.RemoteViews;
22 22
23 import org.chromium.base.ContextUtils; 23 import org.chromium.base.ContextUtils;
24 import org.chromium.base.Log; 24 import org.chromium.base.Log;
25 import org.chromium.base.ThreadUtils; 25 import org.chromium.base.ThreadUtils;
26 import org.chromium.base.VisibleForTesting; 26 import org.chromium.base.VisibleForTesting;
27 import org.chromium.base.library_loader.LibraryLoader; 27 import org.chromium.base.library_loader.LibraryLoader;
28 import org.chromium.chrome.R; 28 import org.chromium.chrome.R;
29 import org.chromium.chrome.browser.IntentHandler; 29 import org.chromium.chrome.browser.IntentHandler;
30 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; 30 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
31 import org.chromium.chrome.browser.locale.LocaleManager;
31 import org.chromium.chrome.browser.omnibox.LocationBarLayout; 32 import org.chromium.chrome.browser.omnibox.LocationBarLayout;
32 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 33 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
33 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r; 34 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r;
34 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ServiceObserver; 35 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ServiceObserver;
35 import org.chromium.chrome.browser.util.IntentUtils; 36 import org.chromium.chrome.browser.util.IntentUtils;
36 37
37 /** 38 /**
38 * Widget that lets the user search using their default search engine. 39 * Widget that lets the user search using their default search engine.
39 * 40 *
40 * Because this is a BroadcastReceiver, it dies immediately after it runs. A ne w one is created 41 * Because this is a BroadcastReceiver, it dies immediately after it runs. A ne w one is created
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Set up an observer to monitor for changes. 144 // Set up an observer to monitor for changes.
144 synchronized (OBSERVER_LOCK) { 145 synchronized (OBSERVER_LOCK) {
145 if (sObserver != null) return; 146 if (sObserver != null) return;
146 sObserver = new SearchWidgetTemplateUrlServiceObserver(); 147 sObserver = new SearchWidgetTemplateUrlServiceObserver();
147 148
148 TemplateUrlService service = TemplateUrlService.getInstance(); 149 TemplateUrlService service = TemplateUrlService.getInstance();
149 service.registerLoadListener(sObserver); 150 service.registerLoadListener(sObserver);
150 service.addObserver(sObserver); 151 service.addObserver(sObserver);
151 if (!service.isLoaded()) service.load(); 152 if (!service.isLoaded()) service.load();
152 } 153 }
154 int[] ids = getDelegate().getAllSearchWidgetIds();
155 LocaleManager.getInstance().recordLocaleBasedSearchWidgetMetrics(
156 ids != null && ids.length > 0);
153 } 157 }
154 158
155 /** Nukes all cached information and forces all widgets to start with a blan k slate. */ 159 /** Nukes all cached information and forces all widgets to start with a blan k slate. */
156 public static void reset() { 160 public static void reset() {
157 SharedPreferences.Editor editor = getDelegate().getSharedPreferences().e dit(); 161 SharedPreferences.Editor editor = getDelegate().getSharedPreferences().e dit();
158 editor.remove(PREF_IS_VOICE_SEARCH_AVAILABLE); 162 editor.remove(PREF_IS_VOICE_SEARCH_AVAILABLE);
159 editor.remove(PREF_SEARCH_ENGINE_SHORTNAME); 163 editor.remove(PREF_SEARCH_ENGINE_SHORTNAME);
160 editor.apply(); 164 editor.apply();
161 165
162 performUpdate(null); 166 performUpdate(null);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 assert sDelegate == null; 400 assert sDelegate == null;
397 sDelegate = delegate; 401 sDelegate = delegate;
398 } 402 }
399 403
400 /** See {@link #sDefaultSearchEngineUrl}. */ 404 /** See {@link #sDefaultSearchEngineUrl}. */
401 static String getDefaultSearchEngineUrl() { 405 static String getDefaultSearchEngineUrl() {
402 // TODO(yusufo): Get rid of this. 406 // TODO(yusufo): Get rid of this.
403 return sDefaultSearchEngineUrl; 407 return sDefaultSearchEngineUrl;
404 } 408 }
405 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698