Bug 1105011 - Include locale in tiles payload. r=rnewman, a=sledru
authorBrian Nicholson <thebnich@gmail.com>
Tue, 02 Dec 2014 15:33:21 -0800
changeset 242362 c166e0f1d00d5d0d7ebde485a467b5cc8f43d56a
parent 242361 caecc91030584c9ce6f760eb4791e67b8cbafe55
child 242363 a90def262c61543d422e3001bce459c80c07e4da
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sledru
bugs1105011
milestone36.0a2
Bug 1105011 - Include locale in tiles payload. r=rnewman, a=sledru
mobile/android/base/home/TopSitesPanel.java
mobile/android/base/tiles/TilesRecorder.java
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -7,18 +7,20 @@ package org.mozilla.gecko.home;
 
 import static org.mozilla.gecko.db.URLMetadataTable.TILE_COLOR_COLUMN;
 import static org.mozilla.gecko.db.URLMetadataTable.TILE_IMAGE_URL_COLUMN;
 
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
+import org.mozilla.gecko.BrowserLocaleManager;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserContract.Thumbnails;
 import org.mozilla.gecko.db.BrowserContract.TopSites;
@@ -230,17 +232,19 @@ public class TopSitesPanel extends HomeF
                         } else {
                             method = TelemetryContract.Method.GRID_ITEM;
                         }
                         Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, Integer.toString(position));
 
                         // Record tile click events on non-private tabs.
                         final Tab tab = Tabs.getInstance().getSelectedTab();
                         if (!tab.isPrivate()) {
-                            mTilesRecorder.recordAction(tab, TilesRecorder.ACTION_CLICK, position, getTilesSnapshot());
+                            final Locale locale = Locale.getDefault();
+                            final String localeTag = BrowserLocaleManager.getLanguageTag(locale);
+                            mTilesRecorder.recordAction(tab, TilesRecorder.ACTION_CLICK, position, getTilesSnapshot(), localeTag);
                         }
 
                         mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
                     }
                 } else {
                     if (mEditPinnedSiteListener != null) {
                         mEditPinnedSiteListener.onEditPinnedSite(position, "");
                     }
--- a/mobile/android/base/tiles/TilesRecorder.java
+++ b/mobile/android/base/tiles/TilesRecorder.java
@@ -17,17 +17,17 @@ import org.mozilla.gecko.Tab;
 import android.util.Log;
 
 public class TilesRecorder {
     public static final String ACTION_CLICK = "click";
 
     private static final String LOG_TAG = "GeckoTilesRecorder";
     private static final String EVENT_TILES_CLICK = "Tiles:Click";
 
-    public void recordAction(Tab tab, String action, int index, List<Tile> tiles) {
+    public void recordAction(Tab tab, String action, int index, List<Tile> tiles, String locale) {
         final Tile clickedTile = tiles.get(index);
 
         if (tab == null || clickedTile == null) {
             throw new IllegalArgumentException("Tab and tile cannot be null");
         }
 
         if (clickedTile.id == -1) {
             // User clicked a non-distribution tile, so we don't need to report it.
@@ -62,16 +62,17 @@ public class TilesRecorder {
 
             if (clickedTileIndex == -1) {
                 throw new IllegalStateException("Clicked tile index not set");
             }
 
             final JSONObject payload = new JSONObject();
             payload.put(action, clickedTileIndex);
             payload.put("tiles", tilesJSON);
+            payload.put("locale", locale);
 
             final JSONObject data = new JSONObject();
             data.put("tabId", tab.getId());
             data.put("payload", payload.toString());
 
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(EVENT_TILES_CLICK, data.toString()));
         } catch (JSONException e) {
             Log.e(LOG_TAG, "JSON error", e);