Commit e0c686cc authored by benwells's avatar benwells Committed by Commit bot

Add infobar metrics for the new search geolocation disclosure.

The new metrics record the action the user took after the disclosure was
shown (ignored, clicked settings, or dismissed), as well as the time
that the infobar was shown for.

BUG=661011

Review-Url: https://codereview.chromium.org/2534363002
Cr-Commit-Position: refs/heads/master@{#435567}
parent bf4e9d86
......@@ -5,6 +5,7 @@
#include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
......@@ -15,12 +16,29 @@
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
// This enum is used in histograms, and is thus append only. Do not remove or
// re-order items.
enum class SearchGeolocationDisclosureInfoBarDelegate::DisclosureResult {
IGNORED = 0,
SETTINGS_CLICKED,
DISMISSED,
COUNT,
};
SearchGeolocationDisclosureInfoBarDelegate::
~SearchGeolocationDisclosureInfoBarDelegate() {}
~SearchGeolocationDisclosureInfoBarDelegate() {
UMA_HISTOGRAM_ENUMERATION(
"GeolocationDisclosure.DisclosureResult",
static_cast<base::HistogramBase::Sample>(result_),
static_cast<base::HistogramBase::Sample>(DisclosureResult::COUNT));
UMA_HISTOGRAM_MEDIUM_TIMES("GeolocationDisclosure.InfoBarVisibleTime",
base::Time::Now() - creation_time_);
}
// static
void SearchGeolocationDisclosureInfoBarDelegate::Create(
content::WebContents* web_contents, const GURL& search_url) {
content::WebContents* web_contents,
const GURL& search_url) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
// Add the new delegate.
......@@ -47,11 +65,20 @@ bool SearchGeolocationDisclosureInfoBarDelegate::
return false;
}
void SearchGeolocationDisclosureInfoBarDelegate::RecordSettingsClicked() {
result_ = DisclosureResult::SETTINGS_CLICKED;
// This counts as a dismissed so the dialog isn't shown again.
pref_service_->SetBoolean(prefs::kSearchGeolocationDisclosureDismissed, true);
}
SearchGeolocationDisclosureInfoBarDelegate::
SearchGeolocationDisclosureInfoBarDelegate(
content::WebContents* web_contents,
const GURL& search_url)
: infobars::InfoBarDelegate(), search_url_(search_url) {
: infobars::InfoBarDelegate(),
search_url_(search_url),
result_(DisclosureResult::IGNORED),
creation_time_(base::Time::Now()) {
pref_service_ = Profile::FromBrowserContext(web_contents->GetBrowserContext())
->GetPrefs();
base::string16 link = l10n_util::GetStringUTF16(
......@@ -63,6 +90,7 @@ SearchGeolocationDisclosureInfoBarDelegate::
}
void SearchGeolocationDisclosureInfoBarDelegate::InfoBarDismissed() {
result_ = DisclosureResult::DISMISSED;
pref_service_->SetBoolean(prefs::kSearchGeolocationDisclosureDismissed, true);
}
......
......@@ -16,6 +16,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/infobars/core/infobar_delegate.h"
#include "ui/gfx/range/range.h"
......@@ -40,6 +41,8 @@ class SearchGeolocationDisclosureInfoBarDelegate
static bool IsSearchGeolocationDisclosureOpen(
content::WebContents* web_contents);
void RecordSettingsClicked();
// The translated text of the message to display.
const base::string16& message_text() const { return message_text_; }
......@@ -50,6 +53,8 @@ class SearchGeolocationDisclosureInfoBarDelegate
const GURL& search_url() const { return search_url_; }
private:
enum class DisclosureResult;
explicit SearchGeolocationDisclosureInfoBarDelegate(
content::WebContents* web_contents,
const GURL& search_url);
......@@ -72,6 +77,12 @@ class SearchGeolocationDisclosureInfoBarDelegate
// The pref service to record prefs in.
PrefService* pref_service_;
// The result of showing the disclosure.
DisclosureResult result_;
// The time the infobar was created.
base::Time creation_time_;
DISALLOW_COPY_AND_ASSIGN(SearchGeolocationDisclosureInfoBarDelegate);
};
......
......@@ -35,8 +35,7 @@ void SearchGeolocationDisclosureInfoBar::OnLinkClicked(
if (!owner())
return; // We're closing; don't call anything, it might access the owner.
// This counts as a dismissed so the dialog isn't shown again.
delegate()->InfoBarDismissed();
GetDelegate()->RecordSettingsClicked();
ScopedJavaLocalRef<jstring> search_url =
base::android::ConvertUTF8ToJavaString(
......
......@@ -19211,6 +19211,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="GeolocationDisclosure.DisclosureResult"
enum="GeolocationDisclosureResult">
<owner>benwells@chromium.org</owner>
<summary>
Records the action the user took after the geolocation disclosure has been
displayed.
</summary>
</histogram>
<histogram name="GeolocationDisclosure.InfoBarVisibleTime" units="ms">
<owner>benwells@chromium.org</owner>
<summary>
Records how long the search geolocation disclosure infobar was visible for.
</summary>
</histogram>
<histogram name="GeolocationDisclosure.PostDisclosurePermission"
enum="PermissionStatus">
<owner>benwells@chromium.org</owner>
......@@ -88716,6 +88732,12 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="32770" label="PDF"/>
</enum>
<enum name="GeolocationDisclosureResult" type="int">
<int value="0" label="Ignored"/>
<int value="1" label="Settings clicked"/>
<int value="2" label="Dismissed"/>
</enum>
<enum name="GeolocationInfoBarDelegateAndroidEvent" type="int">
<obsolete>
Deprecated 9/2014, and replaced by PermissionAction.
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