Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / password_manager / core / browser / password_manager_metrics_util.h
1 // Copyright 2014 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 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_METRICS_UTIL_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_METRICS_UTIL_H_
7
8 #include <string>
9
10 class PrefService;
11
12 namespace password_manager {
13
14 namespace metrics_util {
15
16 // Metrics: "PasswordManager.InfoBarResponse"
17 enum ResponseType {
18   NO_RESPONSE = 0,
19   REMEMBER_PASSWORD,
20   NEVER_REMEMBER_PASSWORD,
21   INFOBAR_DISMISSED,
22   NUM_RESPONSE_TYPES,
23 };
24
25 // Metrics: "PasswordBubble.DisplayDisposition"
26 enum UIDisplayDisposition {
27   AUTOMATIC_WITH_PASSWORD_PENDING = 0,
28   MANUAL_WITH_PASSWORD_PENDING,
29   MANUAL_MANAGE_PASSWORDS,
30   MANUAL_BLACKLISTED,
31   AUTOMATIC_GENERATED_PASSWORD_CONFIRMATION,
32   NUM_DISPLAY_DISPOSITIONS
33 };
34
35 // Metrics: "PasswordManager.UIDismissalReason"
36 enum UIDismissalReason {
37   // We use this to mean both "Bubble lost focus" and "No interaction with the
38   // infobar", depending on which experiment is active.
39   NO_DIRECT_INTERACTION = 0,
40   CLICKED_SAVE,
41   CLICKED_NOPE,
42   CLICKED_NEVER,
43   CLICKED_MANAGE,
44   CLICKED_DONE,
45   CLICKED_UNBLACKLIST,
46   CLICKED_OK,
47   NUM_UI_RESPONSES,
48
49   // If we add the omnibox icon _without_ intending to display the bubble,
50   // we actually call Close() after creating the bubble view. We don't want
51   // that to count in the metrics, so we need this placeholder value.
52   NOT_DISPLAYED
53 };
54
55 // We monitor the performance of the save password heuristic for a handful of
56 // domains. For privacy reasons we are not reporting UMA signals by domain, but
57 // by a domain group. A domain group can contain multiple domains, and a domain
58 // can be contained in multiple groups.
59 // For more information see http://goo.gl/vUuFd5.
60
61 // The number of groups in which each monitored website appears.
62 // It is a half of the total number of groups.
63 const size_t kGroupsPerDomain = 10u;
64
65 // Check whether the |url_host| is monitored or not. If yes, we return
66 // the id of the group which contains the domain name otherwise
67 // returns 0. |pref_service| needs to be the profile preference service.
68 size_t MonitoredDomainGroupId(const std::string& url_host,
69                               PrefService* pref_service);
70
71 // A version of the UMA_HISTOGRAM_ENUMERATION macro that allows the |name|
72 // to vary over the program's runtime.
73 void LogUMAHistogramEnumeration(const std::string& name,
74                                 int sample,
75                                 int boundary_value);
76
77 // A version of the UMA_HISTOGRAM_BOOLEAN macro that allows the |name|
78 // to vary over the program's runtime.
79 void LogUMAHistogramBoolean(const std::string& name, bool sample);
80
81 // Returns a string which contains group_|group_id|. If the
82 // |group_id| corresponds to an unmonitored domain returns an empty string.
83 std::string GroupIdToString(size_t group_id);
84
85 // Log the |reason| a user dismissed the password manager UI.
86 void LogUIDismissalReason(UIDismissalReason reason);
87
88 // Given a ResponseType, log the appropriate UIResponse. We'll use this
89 // mapping to migrate from "PasswordManager.InfoBarResponse" to
90 // "PasswordManager.UIDismissalReason" so we can accurately evaluate the
91 // impact of the bubble UI.
92 //
93 // TODO(mkwst): Drop this (and the infobar metric itself) once the new metric
94 // has rolled out to stable.
95 void LogUIDismissalReason(ResponseType type);
96
97 // Log the appropriate display disposition.
98 void LogUIDisplayDisposition(UIDisplayDisposition disposition);
99
100 }  // namespace metrics_util
101
102 }  // namespace password_manager
103
104 #endif  // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_METRICS_UTIL_H_