Bug 977196 - Part 4: Loading URL from browser search. r=liuche a=sylvestre
authorSola Ogunsakin <oogunsakin@mozilla.com>
Wed, 23 Apr 2014 16:08:05 -0700
changeset 192666 b171d8bdb81cb0a08a1a22a8388baca5d5fac282
parent 192665 81739c61fc928b91631aabae8836b4db00fa1c6a
child 192667 5030420c7d7cc1f34cfef4f7bbbba558c8723ded
push id5874
push usermfinkle@mozilla.com
push dateFri, 09 May 2014 14:33:39 +0000
treeherdermozilla-aurora@3e4da21582df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche, sylvestre
bugs977196
milestone31.0a2
Bug 977196 - Part 4: Loading URL from browser search. r=liuche a=sylvestre
mobile/android/base/BrowserApp.java
mobile/android/base/TelemetryContract.java
mobile/android/base/home/BrowserSearch.java
mobile/android/base/home/SearchEngineRow.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -2611,16 +2611,17 @@ abstract public class BrowserApp extends
             openUrlAndStopEditing(url);
         }
     }
 
     // BrowserSearch.OnSearchListener
     @Override
     public void onSearch(SearchEngine engine, String text) {
         recordSearch(engine, "barsuggest");
+        Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.SUGGESTION, "search");
         openUrlAndStopEditing(text, engine.name);
     }
 
     // BrowserSearch.OnEditSuggestionListener
     @Override
     public void onEditSuggestion(String suggestion) {
         mBrowserToolbar.onEditSuggestion(suggestion);
     }
--- a/mobile/android/base/TelemetryContract.java
+++ b/mobile/android/base/TelemetryContract.java
@@ -68,16 +68,19 @@ public interface TelemetryContract {
         // Action occurred via a context menu.
         public static final String CONTEXT_MENU = "contextmenu";
 
         // Action triggered from a view grid item, like a thumbnail.
         public static final String GRID_ITEM = "griditem";
 
         // Action triggered from a view list item, like a row of a list.
         public static final String LIST_ITEM = "listitem";
+
+        // Action triggered from a suggestion provided to the user.
+        public static final String SUGGESTION = "suggestion";
     }
 
     /**
      * Holds session names. Intended for use with
      * Telemetry.startUISession() as the "sessionName" parameter.
      */
     public interface Session {
         // Started when a user enters about:home.
@@ -88,16 +91,19 @@ public interface TelemetryContract {
         public static final String HOME_PANEL = "homepanel.1:";
 
         // Started when a Reader viewer becomes active in the foreground.
         // Note: Only used in JavaScript for now, but here for completeness.
         public static final String READER = "reader.1";
 
         // URL bar focused.
         public static final String URLBAR_FOCUSED = "urlbar.1:";
+
+        // Awesomescreen frecency search is active.
+        public static final String FRECENCY = "frecency.1:";
     }
 
     /**
      * Holds reasons for stopping a session. Intended for use in
      * Telemetry.stopUISession() as the "reason" parameter.
      */
     public interface Reason {}
 }
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -6,16 +6,18 @@
 package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.PrefsHelper;
 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.BrowserDB.URLColumns;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 import org.mozilla.gecko.home.SearchEngine;
 import org.mozilla.gecko.home.SearchLoader.SearchCursorLoader;
 import org.mozilla.gecko.mozglue.RobocopTarget;
 import org.mozilla.gecko.toolbar.AutocompleteHandler;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.StringUtils;
@@ -216,16 +218,30 @@ public class BrowserSearch extends HomeF
     @Override
     public void onStop() {
         super.onStop();
 
         getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
     }
 
     @Override
+    public void onResume() {
+        super.onResume();
+
+        Telemetry.startUISession(TelemetryContract.Session.FRECENCY);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+
+        Telemetry.stopUISession(TelemetryContract.Session.FRECENCY);
+    }
+
+    @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         // All list views are styled to look the same with a global activity theme.
         // If the style of the list changes, inflate it from an XML.
         mView = (LinearLayout) inflater.inflate(R.layout.browser_search, container, false);
         mList = (HomeListView) mView.findViewById(R.id.home_list_view);
 
         return mView;
     }
@@ -259,16 +275,21 @@ public class BrowserSearch extends HomeF
                     return;
                 }
 
                 // Account for the search engine rows.
                 position -= getSuggestEngineCount();
                 final Cursor c = mAdapter.getCursor(position);
                 final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
 
+                // The "urlbar" and "frecency" sessions can be open at the same time. Use the LIST_ITEM
+                // method to set this LOAD_URL event apart from the case where the user commits what's in
+                // the url bar.
+                Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM);
+
                 // This item is a TwoLinePageRow, so we allow switch-to-tab.
                 mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));
             }
         });
 
         mList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
             @Override
             public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
--- a/mobile/android/base/home/SearchEngineRow.java
+++ b/mobile/android/base/home/SearchEngineRow.java
@@ -1,16 +1,18 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.Telemetry;
+import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.home.BrowserSearch.OnEditSuggestionListener;
 import org.mozilla.gecko.home.BrowserSearch.OnSearchListener;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.AnimatedHeightLayout;
 import org.mozilla.gecko.widget.FaviconView;
 import org.mozilla.gecko.widget.FlowLayout;
 
@@ -74,16 +76,18 @@ class SearchEngineRow extends AnimatedHe
             public void onClick(View v) {
                 final String suggestion = getSuggestionTextFromView(v);
 
                 // If we're not clicking the user-entered view (the first suggestion item)
                 // and the search matches a URL pattern, go to that URL. Otherwise, do a
                 // search for the term.
                 if (v != mUserEnteredView && !StringUtils.isSearchQuery(suggestion, false)) {
                     if (mUrlOpenListener != null) {
+                        Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.SUGGESTION, "url");
+
                         mUrlOpenListener.onUrlOpen(suggestion, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
                     }
                 } else if (mSearchListener != null) {
                     mSearchListener.onSearch(mSearchEngine, suggestion);
                 }
             }
         };