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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/document/DocumentUma.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 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_staging/src/org/chromium/chrome/browser/document/DocumentUma.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/document/DocumentUma.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/DocumentUma.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f83a68d01748c346843fd6ce50cbaf6021ebca2
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/DocumentUma.java
@@ -0,0 +1,98 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.document;
+
+import android.content.Intent;
+
+import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.chrome.browser.BookmarkUtils;
+import org.chromium.chrome.browser.IntentHandler;
+import org.chromium.chrome.browser.util.IntentUtils;
+
+/**
+ * Records UMA relevant to Document mode.
+ */
+public class DocumentUma {
+ /**
+ * Records what caused a DocumentActivity to be resumed.
+ */
+ static void recordStartedBy(int source) {
+ RecordHistogram.recordSparseSlowlyHistogram("DocumentActivity.StartedBy", source);
+ }
+
+ public static void recordInDocumentMode(boolean isInDocumentMode) {
+ RecordHistogram.recordEnumeratedHistogram(
+ "DocumentActivity.RunningMode", isInDocumentMode ? 0 : 1, 2);
+ }
+
+ /**
+ * Records UMA about the Intent fired to create a DocumentActivity.
+ * @param packageName Name of the the application package.
+ * @param intent Intent used to launch the Activity.
+ */
+ static void recordStartedBy(String packageName, Intent intent) {
+ if (intent == null) {
+ recordStartedBy(DocumentMetricIds.STARTED_BY_UNKNOWN);
+ return;
+ }
+
+ int intentSource = DocumentMetricIds.STARTED_BY_UNKNOWN;
+ IntentHandler.ExternalAppId appId =
+ IntentHandler.determineExternalIntentSource(packageName, intent);
+
+ if (intent.hasExtra(IntentHandler.EXTRA_STARTED_BY)) {
+ intentSource = IntentUtils.safeGetIntExtra(intent,
+ IntentHandler.EXTRA_STARTED_BY, DocumentMetricIds.STARTED_BY_UNKNOWN);
+ } else if (IntentUtils.safeGetBooleanExtra(intent,
+ BookmarkUtils.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, false)) {
+ // TODO(dfalcantara): Add a new a boolean instead of piggybacking on this Intent extra.
+ intentSource = DocumentMetricIds.STARTED_BY_LAUNCHER;
+ } else if (IntentUtils.safeGetBooleanExtra(
+ intent, IntentHandler.EXTRA_APPEND_TASK, false)) {
+ intentSource = DocumentMetricIds.STARTED_BY_SEARCH_RESULT_PAGE;
+ } else if (IntentUtils.safeGetBooleanExtra(
+ intent, IntentHandler.EXTRA_PRESERVE_TASK, false)) {
+ // TODO(dfalcantara): Figure out how split apart Intents fired by the search box.
+ intentSource = DocumentMetricIds.STARTED_BY_SEARCH_SUGGESTION_EXTERNAL;
+ } else if (appId == IntentHandler.ExternalAppId.GMAIL) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GMAIL;
+ } else if (appId == IntentHandler.ExternalAppId.FACEBOOK) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_FACEBOOK;
+ } else if (appId == IntentHandler.ExternalAppId.PLUS) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_PLUS;
+ } else if (appId == IntentHandler.ExternalAppId.TWITTER) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_TWITTER;
+ } else if (appId == IntentHandler.ExternalAppId.CHROME) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_CHROME;
+ } else if (appId == IntentHandler.ExternalAppId.HANGOUTS) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_HANGOUTS;
+ } else if (appId == IntentHandler.ExternalAppId.MESSENGER) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_MESSENGER;
+ } else if (appId == IntentHandler.ExternalAppId.NEWS) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_NEWS;
+ } else if (appId == IntentHandler.ExternalAppId.LINE) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_LINE;
+ } else if (appId == IntentHandler.ExternalAppId.WHATSAPP) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_WHATSAPP;
+ } else if (appId == IntentHandler.ExternalAppId.GSA) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GSA;
+ } else if (appId == IntentHandler.ExternalAppId.OTHER) {
+ intentSource = DocumentMetricIds.STARTED_BY_EXTERNAL_APP_OTHER;
+ }
+
+ if (intentSource == DocumentMetricIds.STARTED_BY_UNKNOWN) {
+ android.util.Log.d("DocumentUma", "Unknown source detected");
+ }
+
+ if (intentSource >= DocumentMetricIds.STARTED_BY_EXTERNAL_APP_GMAIL
+ && intentSource < DocumentMetricIds.STARTED_BY_CONTEXTUAL_SEARCH) {
+ // Document activity was started from an external app, record which one.
+ RecordHistogram.recordEnumeratedHistogram("MobileIntent.PageLoadDueToExternalApp",
+ appId.ordinal(), IntentHandler.ExternalAppId.INDEX_BOUNDARY.ordinal());
+ }
+
+ recordStartedBy(intentSource);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698