1 // Copyright 2020 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 #include "chrome/browser/chromeos/apps/metrics/intent_handling_metrics.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "chrome/browser/apps/intent_helper/apps_navigation_types.h"
9 #include "components/arc/metrics/arc_metrics_constants.h"
10
11 namespace apps {
12
IntentHandlingMetrics()13 IntentHandlingMetrics::IntentHandlingMetrics() {}
14
RecordIntentPickerMetrics(Source source,bool should_persist,AppsNavigationThrottle::PickerAction action,AppsNavigationThrottle::Platform platform)15 void IntentHandlingMetrics::RecordIntentPickerMetrics(
16 Source source,
17 bool should_persist,
18 AppsNavigationThrottle::PickerAction action,
19 AppsNavigationThrottle::Platform platform) {
20 // TODO(crbug.com/985233) For now External Protocol Dialog is only querying
21 // ARC apps.
22 if (source == Source::kExternalProtocol) {
23 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.ExternalProtocolDialog", action);
24 } else {
25 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.IntentPickerAction", action);
26
27 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.IntentPickerDestinationPlatform",
28 platform);
29 }
30 }
31
RecordIntentPickerUserInteractionMetrics(const std::string & selected_app_package,PickerEntryType entry_type,IntentPickerCloseReason close_reason,Source source,bool should_persist)32 void IntentHandlingMetrics::RecordIntentPickerUserInteractionMetrics(
33 const std::string& selected_app_package,
34 PickerEntryType entry_type,
35 IntentPickerCloseReason close_reason,
36 Source source,
37 bool should_persist) {
38 if (entry_type == PickerEntryType::kArc &&
39 (close_reason == IntentPickerCloseReason::PREFERRED_APP_FOUND ||
40 close_reason == IntentPickerCloseReason::OPEN_APP)) {
41 UMA_HISTOGRAM_ENUMERATION("Arc.UserInteraction",
42 arc::UserInteractionType::APP_STARTED_FROM_LINK);
43 }
44 AppsNavigationThrottle::PickerAction action =
45 AppsNavigationThrottle::GetPickerAction(entry_type, close_reason,
46 should_persist);
47 AppsNavigationThrottle::Platform platform =
48 AppsNavigationThrottle::GetDestinationPlatform(selected_app_package,
49 action);
50 RecordIntentPickerMetrics(source, should_persist, action, platform);
51 }
52
RecordExternalProtocolMetrics(arc::Scheme scheme,PickerEntryType entry_type,bool accepted,bool persisted)53 void IntentHandlingMetrics::RecordExternalProtocolMetrics(
54 arc::Scheme scheme,
55 PickerEntryType entry_type,
56 bool accepted,
57 bool persisted) {
58 arc::ProtocolAction action =
59 arc::GetProtocolAction(scheme, entry_type, accepted, persisted);
60 if (accepted) {
61 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.ExternalProtocolDialog.Accepted",
62 action);
63 } else {
64 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.ExternalProtocolDialog.Rejected",
65 action);
66 }
67 }
68
RecordOpenBrowserMetrics(AppType type)69 void IntentHandlingMetrics::RecordOpenBrowserMetrics(AppType type) {
70 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Apps.OpenBrowser", type);
71 }
72
73 } // namespace apps
74