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

[Sharing Hub] Create method for recording TimeToShare.

This removes copying the histogram name for every new option added.

Bug:1079467

Change-Id: I54dae11cf34535f71146923c3e0f85f87c3bb2ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324722Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Commit-Queue: Sophey Dong <sophey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792782}
parent 80b41c10
...@@ -181,9 +181,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -181,9 +181,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.ScreenshotSelected"); RecordUserAction.record("SharingHubAndroid.ScreenshotSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mScreenshotCoordinator = new ScreenshotCoordinator(mActivity, mScreenshotCoordinator = new ScreenshotCoordinator(mActivity,
mTabProvider.get(), mChromeOptionShareCallback, mBottomSheetController); mTabProvider.get(), mChromeOptionShareCallback, mBottomSheetController);
// Capture a screenshot once the bottom sheet is fully hidden. The // Capture a screenshot once the bottom sheet is fully hidden. The
...@@ -204,9 +202,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -204,9 +202,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.CopyURLSelected"); RecordUserAction.record("SharingHubAndroid.CopyURLSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService( ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(
Context.CLIPBOARD_SERVICE); Context.CLIPBOARD_SERVICE);
...@@ -226,9 +222,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -226,9 +222,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.CopyImageSelected"); RecordUserAction.record("SharingHubAndroid.CopyImageSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
if (!mShareParams.getFileUris().isEmpty()) { if (!mShareParams.getFileUris().isEmpty()) {
Clipboard.getInstance().setImageUri(mShareParams.getFileUris().get(0)); Clipboard.getInstance().setImageUri(mShareParams.getFileUris().get(0));
...@@ -246,9 +240,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -246,9 +240,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.CopyTextSelected"); RecordUserAction.record("SharingHubAndroid.CopyTextSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService( ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(
Context.CLIPBOARD_SERVICE); Context.CLIPBOARD_SERVICE);
...@@ -268,9 +260,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -268,9 +260,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.SendTabToSelfSelected"); RecordUserAction.record("SharingHubAndroid.SendTabToSelfSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
SendTabToSelfShareActivity.actionHandler(mActivity, mUrl, SendTabToSelfShareActivity.actionHandler(mActivity, mUrl,
mShareParams.getTitle(), mShareParams.getTitle(),
...@@ -294,9 +284,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -294,9 +284,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.QRCodeSelected"); RecordUserAction.record("SharingHubAndroid.QRCodeSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
QrCodeCoordinator qrCodeCoordinator = new QrCodeCoordinator(mActivity, mUrl); QrCodeCoordinator qrCodeCoordinator = new QrCodeCoordinator(mActivity, mUrl);
qrCodeCoordinator.show(); qrCodeCoordinator.show();
...@@ -314,9 +302,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -314,9 +302,7 @@ class ChromeProvidedSharingOptionsProvider {
(view) (view)
-> { -> {
RecordUserAction.record("SharingHubAndroid.PrintSelected"); RecordUserAction.record("SharingHubAndroid.PrintSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
mPrintTabCallback.onResult(mTabProvider.get()); mPrintTabCallback.onResult(mTabProvider.get());
}, },
...@@ -332,9 +318,7 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -332,9 +318,7 @@ class ChromeProvidedSharingOptionsProvider {
(currentActivity) (currentActivity)
-> { -> {
RecordUserAction.record("SharingHubAndroid.LinkToTextSelected"); RecordUserAction.record("SharingHubAndroid.LinkToTextSelected");
RecordHistogram.recordMediumTimesHistogram( recordTimeToShare(mShareStartTime);
"Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true); mBottomSheetController.hideContent(mBottomSheetContent, true);
// TODO(1102382): Init and call link-to-text feature. // TODO(1102382): Init and call link-to-text feature.
}, },
...@@ -357,4 +341,9 @@ class ChromeProvidedSharingOptionsProvider { ...@@ -357,4 +341,9 @@ class ChromeProvidedSharingOptionsProvider {
} }
return chromeShareExtras.getImageSrcUrl(); return chromeShareExtras.getImageSrcUrl();
} }
static void recordTimeToShare(long shareStartTime) {
RecordHistogram.recordMediumTimesHistogram("Sharing.SharingHubAndroid.TimeToShare",
System.currentTimeMillis() - shareStartTime);
}
} }
...@@ -101,8 +101,8 @@ public class ShareSheetPropertyModelBuilder { ...@@ -101,8 +101,8 @@ public class ShareSheetPropertyModelBuilder {
* <li>If a URL is present, {@code isUrlOfVisiblePage} determines whether to add * <li>If a URL is present, {@code isUrlOfVisiblePage} determines whether to add
* {@link ContentType.LINK_PAGE_VISIBLE} or {@link ContentType.LINK_PAGE_NOT_VISIBLE}. * {@link ContentType.LINK_PAGE_VISIBLE} or {@link ContentType.LINK_PAGE_NOT_VISIBLE}.
* <li>If the text being shared is not the same as the URL, add {@link ContentType.TEXT} * <li>If the text being shared is not the same as the URL, add {@link ContentType.TEXT}
<li>If text is highlighted by user, add {@link ContentType.HIGHLIGHTED_TEXT}. * <li>If text is highlighted by user, add {@link ContentType.HIGHLIGHTED_TEXT}.
<li>If the share contains files and the {@code fileContentType} is an image, add * <li>If the share contains files and the {@code fileContentType} is an image, add
* {@link ContentType.IMAGE}. Otherwise, add {@link ContentType.OTHER_FILE_TYPE}. * {@link ContentType.IMAGE}. Otherwise, add {@link ContentType.OTHER_FILE_TYPE}.
* </ul> * </ul>
*/ */
...@@ -181,7 +181,7 @@ public class ShareSheetPropertyModelBuilder { ...@@ -181,7 +181,7 @@ public class ShareSheetPropertyModelBuilder {
(String) info.loadLabel(mPackageManager), onClickListener, (String) info.loadLabel(mPackageManager), onClickListener,
/*isFirstParty=*/false); /*isFirstParty=*/false);
models.add(propertyModel); models.add(propertyModel);
}; }
return models; return models;
} }
...@@ -193,8 +193,7 @@ public class ShareSheetPropertyModelBuilder { ...@@ -193,8 +193,7 @@ public class ShareSheetPropertyModelBuilder {
RecordUserAction.record("SharingHubAndroid.ThirdPartyAppSelected"); RecordUserAction.record("SharingHubAndroid.ThirdPartyAppSelected");
RecordHistogram.recordEnumeratedHistogram( RecordHistogram.recordEnumeratedHistogram(
"Sharing.SharingHubAndroid.ThirdPartyAppUsage", logIndex, MAX_NUM_APPS + 1); "Sharing.SharingHubAndroid.ThirdPartyAppUsage", logIndex, MAX_NUM_APPS + 1);
RecordHistogram.recordMediumTimesHistogram("Sharing.SharingHubAndroid.TimeToShare", ChromeProvidedSharingOptionsProvider.recordTimeToShare(shareStartTime);
System.currentTimeMillis() - shareStartTime);
ComponentName component = new ComponentName(ai.applicationInfo.packageName, ai.name); ComponentName component = new ComponentName(ai.applicationInfo.packageName, ai.name);
if (callback != null) { if (callback != null) {
callback.onTargetChosen(component); callback.onTargetChosen(component);
......
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