Commit 9c216dd8 authored by Sophey Dong's avatar Sophey Dong Committed by Commit Bot

[ShareCCT] Add logging for shares in CCT.

Bug: 1135311
Change-Id: I5fa5d931a9eba2ff82bed1bda09dcb4723f35c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508198Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Sophey Dong <sophey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823699}
parent 46c65f1d
......@@ -38,6 +38,7 @@ import androidx.browser.trusted.sharing.ShareTarget;
import org.chromium.base.IntentUtils;
import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.IntentHandler;
......@@ -76,6 +77,22 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
int MEDIA_LAUNCHER_ACTIVITY = 3;
}
// These values are persisted to logs. Entries should not be renumbered and numeric values
// should never be reused.
@IntDef({ShareOptionLocation.TOOLBAR, ShareOptionLocation.MENU,
ShareOptionLocation.TOOLBAR_FULL_MENU_FALLBACK, ShareOptionLocation.NO_SPACE,
ShareOptionLocation.SHARE_DISABLED, ShareOptionLocation.NUM_ENTRIES})
private @interface ShareOptionLocation {
int TOOLBAR = 0;
int MENU = 1;
int TOOLBAR_FULL_MENU_FALLBACK = 2;
int NO_SPACE = 3;
int SHARE_DISABLED = 4;
// Must be the last one.
int NUM_ENTRIES = 5;
}
/**
* Extra used to keep the caller alive. Its value is an Intent.
*/
......@@ -492,16 +509,30 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT))) {
if (mToolbarButtons.isEmpty()) {
mToolbarButtons.add(CustomButtonParams.createShareButton(context, mToolbarColor));
logShareOptionLocation(ShareOptionLocation.TOOLBAR);
} else if (mMenuEntries.isEmpty()) {
mShowShareItemInMenu = true;
logShareOptionLocation(ShareOptionLocation.TOOLBAR_FULL_MENU_FALLBACK);
} else {
logShareOptionLocation(ShareOptionLocation.NO_SPACE);
}
} else {
mShowShareItemInMenu = IntentUtils.safeGetBooleanExtra(intent,
CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM,
mIsOpenedByChrome && mUiType == CustomTabsUiType.DEFAULT);
if (mShowShareItemInMenu) {
logShareOptionLocation(ShareOptionLocation.MENU);
} else {
logShareOptionLocation(ShareOptionLocation.SHARE_DISABLED);
}
}
}
private static void logShareOptionLocation(@ShareOptionLocation int shareOptionLocation) {
RecordHistogram.recordEnumeratedHistogram("CustomTabs.ShareOptionLocation",
shareOptionLocation, ShareOptionLocation.NUM_ENTRIES);
}
/**
* Returns the color passed from the client app.
*/
......
......@@ -8,6 +8,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.chromium.base.metrics.RecordUserAction;
/**
* Receives shared content broadcast from Chrome Custom Tabs and shows a share sheet to share the
* url.
......@@ -15,6 +17,7 @@ import android.content.Intent;
public final class CustomTabsShareBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
RecordUserAction.record("MobileTopToolbarShareButton");
String url = intent.getDataString();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
......
......@@ -66724,6 +66724,19 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
</int>
</enum>
<enum name="ShareOptionLocation">
<int value="0" label="TOOLBAR"/>
<int value="1" label="MENU">Share option chosen to be shown in the menu.</int>
<int value="2" label="TOOLBAR_FULL_MENU_FALLBACK">
Share option shown in the menu because the toolbar is full.
</int>
<int value="3" label="NO_SPACE">
No share option shown despite share being enabled. This is due to the
existence of custom buttons and menu items, which take precedence.
</int>
<int value="4" label="SHARE_DISABLED"/>
</enum>
<enum name="SharingActionSource">
<!--
SharingActionSource must be kept in sync with ValidSharingActionSource defined
......@@ -213,6 +213,13 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="CustomTabs.ShareOptionLocation" enum="ShareOptionLocation"
expires_after="M91">
<owner>sophey@chromium.org</owner>
<owner>src/components/send_tab_to_self/OWNERS</owner>
<summary>Records the location of the share option in the Custom Tab.</summary>
</histogram>
<histogram name="CustomTabs.SpareWebContents.Status2"
enum="SpareWebContentsStatus2" expires_after="2020-12-20">
<owner>lizeb@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment