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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java

Issue 2898823002: Add metrics for search engine promo and search widget (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java b/chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java
index 06f2f9c6cc025702de1d6c677f7ad9b60a396783..b9b7ef7d7779b381ae5d3bc1355bf71a00af1604 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java
@@ -67,6 +67,8 @@ public class LocaleManager {
private static LocaleManager sInstance;
+ protected boolean mSearchEnginePromoShown;
Ted C 2017/05/22 21:57:02 per offline, prefer to use hasShownSearchEnginePro
Yusuf 2017/05/22 22:31:14 Done.
+
// LocaleManager is a singleton and it should not have strong reference to UI objects.
// SnackbarManager is owned by ChromeActivity and is not null as long as the activity is alive.
private WeakReference<SnackbarManager> mSnackbarManager;
@@ -98,6 +100,15 @@ public class LocaleManager {
}
/**
+ * Default constructor.
+ */
+ public LocaleManager() {
+ int state = ContextUtils.getAppSharedPreferences().getInt(
+ KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_SHOULD_CHECK);
+ mSearchEnginePromoShown = state == SEARCH_ENGINE_PROMO_CHECKED_AND_SHOWN;
+ }
+
+ /**
* Starts listening to state changes of the phone.
*/
public void startObservingPhoneChanges() {
@@ -284,17 +295,27 @@ public class LocaleManager {
}
/**
+ * @return The search engine type for the given url if applicable.
+ * See template_url_prepopulate_data.cc for all values.
+ */
+ protected static int getSearchEngineType(String url) {
+ return nativeGetEngineType(url);
+ }
+
+ /**
* To be called after the user has made a selection from a search engine promo dialog.
* @param type The type of search engine promo dialog that was shown.
+ * @param keywords The keywords for all search engines listed in the order shown to the user.
* @param keyword The keyword for the search engine chosen.
*/
protected void onUserSearchEngineChoiceFromPromoDialog(
- @SearchEnginePromoType int type, String keyword) {
+ @SearchEnginePromoType int type, List<String> keywords, String keyword) {
TemplateUrlService.getInstance().setSearchEngine(keyword);
ContextUtils.getAppSharedPreferences()
.edit()
.putInt(KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_CHECKED_AND_SHOWN)
.apply();
+ mSearchEnginePromoShown = true;
}
private SpecialLocaleHandler getSpecialLocaleHandler() {
@@ -319,4 +340,29 @@ public class LocaleManager {
assert sInstance == null;
sInstance = instance;
}
+
+ /**
+ * Record any locale based metrics related with the search widget. Recorded on initialization
+ * only.
+ * @param widgetPresent Whether there is at least one search widget on home screen.
+ */
+ public void recordLocaleBasedSearchWidgetMetrics(boolean widgetPresent) {}
+
+ /**
+ * @return Whether the search engine promo has been shown.
+ */
+ public boolean hasShownSearchEnginePromo() {
+ return mSearchEnginePromoShown;
+ }
+
+ /**
+ * Record any locale based metrics related with search. Recorded per search.
+ * @param isFromSearchWidget Whether the search was performed from the search widget.
+ * @param url Url for the search made.
+ * @param transition The transition type for the navigation.
+ */
+ public void recordLocaleBasedSearchMetrics(
+ boolean isFromSearchWidget, String url, int transition) {}
Ted C 2017/05/22 21:57:02 for the transition, can we tag it with @PageTransi
Yusuf 2017/05/22 22:31:14 We dont really have that defined right now :S. So
+
+ private static native int nativeGetEngineType(String url);
}

Powered by Google App Engine
This is Rietveld 408576698