OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.document; |
| 6 |
| 7 import android.content.Intent; |
| 8 |
| 9 import org.chromium.base.metrics.RecordHistogram; |
| 10 import org.chromium.chrome.browser.BookmarkUtils; |
| 11 import org.chromium.chrome.browser.IntentHandler; |
| 12 import org.chromium.chrome.browser.util.IntentUtils; |
| 13 |
| 14 /** |
| 15 * Records UMA relevant to Document mode. |
| 16 */ |
| 17 public class DocumentUma { |
| 18 /** |
| 19 * Records what caused a DocumentActivity to be resumed. |
| 20 */ |
| 21 static void recordStartedBy(int source) { |
| 22 RecordHistogram.recordSparseSlowlyHistogram("DocumentActivity.StartedBy"
, source); |
| 23 } |
| 24 |
| 25 public static void recordInDocumentMode(boolean isInDocumentMode) { |
| 26 RecordHistogram.recordEnumeratedHistogram( |
| 27 "DocumentActivity.RunningMode", isInDocumentMode ? 0 : 1, 2); |
| 28 } |
| 29 |
| 30 /** |
| 31 * Records UMA about the Intent fired to create a DocumentActivity. |
| 32 * @param packageName Name of the the application package. |
| 33 * @param intent Intent used to launch the Activity. |
| 34 */ |
| 35 static void recordStartedBy(String packageName, Intent intent) { |
| 36 if (intent == null) { |
| 37 recordStartedBy(DocumentMetricIds.STARTED_BY_UNKNOWN); |
| 38 return; |
| 39 } |
| 40 |
| 41 int intentSource = DocumentMetricIds.STARTED_BY_UNKNOWN; |
| 42 IntentHandler.ExternalAppId appId = |
| 43 IntentHandler.determineExternalIntentSource(packageName, intent)
; |
| 44 |
| 45 if (intent.hasExtra(IntentHandler.EXTRA_STARTED_BY)) { |
| 46 intentSource = IntentUtils.safeGetIntExtra(intent, |
| 47 IntentHandler.EXTRA_STARTED_BY, DocumentMetricIds.STARTED_BY
_UNKNOWN); |
| 48 } else if (IntentUtils.safeGetBooleanExtra(intent, |
| 49 BookmarkUtils.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, false)) { |
| 50 // TODO(dfalcantara): Add a new a boolean instead of piggybacking on
this Intent extra. |
| 51 intentSource = DocumentMetricIds.STARTED_BY_LAUNCHER; |
| 52 } else if (IntentUtils.safeGetBooleanExtra( |
| 53 intent, IntentHandler.EXTRA_APPEND_TASK, false)) { |
| 54 intentSource = DocumentMetricIds.STARTED_BY_SEARCH_RESULT_PAGE; |
| 55 } else if (IntentUtils.safeGetBooleanExtra( |
| 56 intent, IntentHandler.EXTRA_PRESERVE_TASK, false)) { |
| 57 // TODO(dfalcantara): Figure out how split apart Intents fired by th
e search box. |
| 58 intentSource = DocumentMetricIds.STARTED_BY_SEARCH_SUGGESTION_EXTERN
AL; |
| 59 } else if (appId == IntentHandler.ExternalAppId.GMAIL) { |
| 60 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GMAIL; |
| 61 } else if (appId == IntentHandler.ExternalAppId.FACEBOOK) { |
| 62 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_FACEBOOK; |
| 63 } else if (appId == IntentHandler.ExternalAppId.PLUS) { |
| 64 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_PLUS; |
| 65 } else if (appId == IntentHandler.ExternalAppId.TWITTER) { |
| 66 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_TWITTER; |
| 67 } else if (appId == IntentHandler.ExternalAppId.CHROME) { |
| 68 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_CHROME; |
| 69 } else if (appId == IntentHandler.ExternalAppId.HANGOUTS) { |
| 70 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_HANGOUTS; |
| 71 } else if (appId == IntentHandler.ExternalAppId.MESSENGER) { |
| 72 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_MESSENGER; |
| 73 } else if (appId == IntentHandler.ExternalAppId.NEWS) { |
| 74 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_NEWS; |
| 75 } else if (appId == IntentHandler.ExternalAppId.LINE) { |
| 76 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_LINE; |
| 77 } else if (appId == IntentHandler.ExternalAppId.WHATSAPP) { |
| 78 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_WHATSAPP; |
| 79 } else if (appId == IntentHandler.ExternalAppId.GSA) { |
| 80 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GSA; |
| 81 } else if (appId == IntentHandler.ExternalAppId.OTHER) { |
| 82 intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_OTHER; |
| 83 } |
| 84 |
| 85 if (intentSource == DocumentMetricIds.STARTED_BY_UNKNOWN) { |
| 86 android.util.Log.d("DocumentUma", "Unknown source detected"); |
| 87 } |
| 88 |
| 89 if (intentSource >= DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GMAIL |
| 90 && intentSource < DocumentMetricIds.STARTED_BY_CONTEXTUAL_SEARCH
) { |
| 91 // Document activity was started from an external app, record which
one. |
| 92 RecordHistogram.recordEnumeratedHistogram("MobileIntent.PageLoadDueT
oExternalApp", |
| 93 appId.ordinal(), IntentHandler.ExternalAppId.INDEX_BOUNDARY.
ordinal()); |
| 94 } |
| 95 |
| 96 recordStartedBy(intentSource); |
| 97 } |
| 98 } |
OLD | NEW |