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