diff options
author | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 02:29:50 +0000 |
---|---|---|
committer | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 02:29:50 +0000 |
commit | fd237cb917c93cfe78d8daf616e2d9bc8af612b7 (patch) | |
tree | faf37c353ce233277f5ab2290010379847e00c4e /chrome/browser/geolocation | |
parent | b8586fba2a877b0d4494ea82a722a4acdead5311 (diff) | |
download | chromium_src-fd237cb917c93cfe78d8daf616e2d9bc8af612b7.zip chromium_src-fd237cb917c93cfe78d8daf616e2d9bc8af612b7.tar.gz chromium_src-fd237cb917c93cfe78d8daf616e2d9bc8af612b7.tar.bz2 |
Geolocation: add UMA instrumentation to the infobar.
Review URL: https://codereview.chromium.org/26255002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
3 files changed, 87 insertions, 2 deletions
diff --git a/chrome/browser/geolocation/geolocation_infobar_delegate.cc b/chrome/browser/geolocation/geolocation_infobar_delegate.cc index 65e645e..fba08a8 100644 --- a/chrome/browser/geolocation/geolocation_infobar_delegate.cc +++ b/chrome/browser/geolocation/geolocation_infobar_delegate.cc @@ -4,6 +4,7 @@ #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" +#include "base/metrics/histogram.h" #include "chrome/browser/content_settings/permission_queue_controller.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/infobars/infobar_service.h" @@ -23,6 +24,41 @@ typedef GeolocationInfoBarDelegateAndroid DelegateType; typedef GeolocationInfoBarDelegate DelegateType; #endif +namespace { + +enum GeolocationInfoBarDelegateEvent { + // NOTE: Do not renumber these as that would confuse interpretation of + // previously logged data. When making changes, also update the enum list + // in tools/metrics/histograms/histograms.xml to keep it in sync. + + // The bar was created. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE = 0, + + // User allowed use of geolocation. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_ALLOW = 1, + + // User denied use of geolocation. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_DENY = 2, + + // User dismissed the bar. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_DISMISS = 3, + + // User clicked on link. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_LINK_CLICK = 4, + + // User ignored the bar. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_IGNORED = 5, + + // NOTE: Add entries only immediately above this line. + GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT = 6 +}; + +void RecordUmaEvent(GeolocationInfoBarDelegateEvent event) { + UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegate.Event", + event, GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT); +} + +} // namespace // static InfoBarDelegate* GeolocationInfoBarDelegate::Create( @@ -31,6 +67,7 @@ InfoBarDelegate* GeolocationInfoBarDelegate::Create( const PermissionRequestID& id, const GURL& requesting_frame, const std::string& display_languages) { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); const content::NavigationEntry* committed_entry = infobar_service->web_contents()->GetController().GetLastCommittedEntry(); return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( @@ -51,13 +88,18 @@ GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( id_(id), requesting_frame_(requesting_frame.GetOrigin()), contents_unique_id_(contents_unique_id), - display_languages_(display_languages) { + display_languages_(display_languages), + user_has_interacted_(false) { } GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { + if (!user_has_interacted_) + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_IGNORED); } bool GeolocationInfoBarDelegate::Accept() { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_ALLOW); + set_user_has_interacted(); SetPermission(true, true); return true; } @@ -72,6 +114,8 @@ void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting, } void GeolocationInfoBarDelegate::InfoBarDismissed() { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_DISMISS); + set_user_has_interacted(); SetPermission(false, false); } @@ -106,6 +150,8 @@ string16 GeolocationInfoBarDelegate::GetButtonLabel( } bool GeolocationInfoBarDelegate::Cancel() { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_DENY); + set_user_has_interacted(); SetPermission(true, false); return true; } @@ -116,6 +162,7 @@ string16 GeolocationInfoBarDelegate::GetLinkText() const { bool GeolocationInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_LINK_CLICK); const char kGeolocationLearnMoreUrl[] = #if defined(OS_CHROMEOS) "https://www.google.com/support/chromeos/bin/answer.py?answer=142065"; diff --git a/chrome/browser/geolocation/geolocation_infobar_delegate.h b/chrome/browser/geolocation/geolocation_infobar_delegate.h index 6dc4b45..7444a678 100644 --- a/chrome/browser/geolocation/geolocation_infobar_delegate.h +++ b/chrome/browser/geolocation/geolocation_infobar_delegate.h @@ -42,6 +42,13 @@ class GeolocationInfoBarDelegate : public ConfirmInfoBarDelegate { // Call back to the controller, to inform of the user's decision. void SetPermission(bool update_content_setting, bool allowed); + // Marks a flag internally to indicate that the user has interacted with the + // bar. This makes it possible to log from the destructor when the bar has not + // been used, i.e. it has been ignored by the user. + void set_user_has_interacted() { + user_has_interacted_ = true; + } + private: // ConfirmInfoBarDelegate: virtual void InfoBarDismissed() OVERRIDE; @@ -61,6 +68,9 @@ class GeolocationInfoBarDelegate : public ConfirmInfoBarDelegate { int contents_unique_id_; std::string display_languages_; + // Whether the user has interacted with the geolocation infobar. + bool user_has_interacted_; + DISALLOW_COPY_AND_ASSIGN(GeolocationInfoBarDelegate); }; diff --git a/chrome/browser/geolocation/geolocation_infobar_delegate_android.cc b/chrome/browser/geolocation/geolocation_infobar_delegate_android.cc index 52c2b5b..4193181 100644 --- a/chrome/browser/geolocation/geolocation_infobar_delegate_android.cc +++ b/chrome/browser/geolocation/geolocation_infobar_delegate_android.cc @@ -4,6 +4,7 @@ #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" +#include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/android/google_location_settings_helper.h" #include "grit/generated_resources.h" @@ -11,6 +12,28 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" +namespace { +enum GeolocationInfoBarDelegateAndroidEvent { + // NOTE: Do not renumber these as that would confuse interpretation of + // previously logged data. When making changes, also update the enum list + // in tools/metrics/histograms/histograms.xml to keep it in sync. + + // User allowed the page to use geolocation. + GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW = 0, + + // User opened geolocation settings. + GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS = 1, + + // NOTE: Add entries only immediately above this line. + GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT = 2 +}; + +void RecordUmaEvent(GeolocationInfoBarDelegateAndroidEvent event) { + UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegateAndroid.Event", + event, GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT); +} +} // namespace + GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( InfoBarService* infobar_service, PermissionQueueController* controller, @@ -29,13 +52,18 @@ GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { } bool GeolocationInfoBarDelegateAndroid::Accept() { + set_user_has_interacted(); + // Accept button text could be either 'Allow' or 'Google Location Settings'. // If 'Allow' we follow the regular flow. - if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) + if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW); return GeolocationInfoBarDelegate::Accept(); + } // If 'Google Location Settings', we need to open the system Google Location // Settings activity. + RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS); google_location_settings_helper_->ShowGoogleLocationSettings(); SetPermission(false, false); return true; |