Commit da52b2f3 authored by dfalcantara's avatar dfalcantara Committed by Commit bot

[App banners] Add RAPPOR support

* Adds support for tracking which domains trigger app banners.
  These metrics are split between native apps and web apps
  since developers are likely to prefer one over the other.

* Changes rappor.xml to have information about the new metrics.

BUG=458548

Review URL: https://codereview.chromium.org/939263002

Cr-Commit-Position: refs/heads/master@{#317158}
parent f6cf0acf
......@@ -17,6 +17,7 @@
#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/metrics/rappor/sampling.h"
#include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h"
......@@ -121,12 +122,18 @@ void AppBannerInfoBarDelegate::InfoBarDismissed() {
native_app_package_,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
AppBannerManager::GetCurrentTime());
rappor::SampleDomainAndRegistryFromGURL("AppBanner.NativeApp.Dismissed",
web_contents->GetURL());
} else if (!web_app_data_.IsEmpty()) {
AppBannerSettingsHelper::RecordBannerEvent(
web_contents, web_contents->GetURL(),
web_app_data_.start_url.spec(),
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
AppBannerManager::GetCurrentTime());
rappor::SampleDomainAndRegistryFromGURL("AppBanner.WebApp.Dismissed",
web_contents->GetURL());
}
}
......@@ -177,6 +184,8 @@ bool AppBannerInfoBarDelegate::Accept() {
true);
TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED);
rappor::SampleDomainAndRegistryFromGURL("AppBanner.WebApp.Installed",
web_contents->GetURL());
return true;
}
......@@ -229,6 +238,8 @@ void AppBannerInfoBarDelegate::OnInstallIntentReturned(
AppBannerManager::GetCurrentTime());
TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_STARTED);
rappor::SampleDomainAndRegistryFromGURL("AppBanner.NativeApp.Installed",
web_contents->GetURL());
}
UpdateInstallState(env, obj);
......
......@@ -17,6 +17,7 @@
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/metrics/rappor/sampling.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
......@@ -243,8 +244,13 @@ void AppBannerManager::OnFetchComplete(BannerBitmapFetcher* fetcher,
return;
fetcher_ = nullptr;
if (!bitmap || url != app_icon_url_)
if (!web_contents()
|| web_contents()->IsBeingDestroyed()
|| validated_url_ != web_contents()->GetURL()
|| !bitmap
|| url != app_icon_url_) {
return;
}
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> jobj = weak_java_banner_view_manager_.get(env);
......@@ -265,6 +271,9 @@ void AppBannerManager::OnFetchComplete(BannerBitmapFetcher* fetcher,
new SkBitmap(*bitmap),
native_app_data_,
native_app_package_);
rappor::SampleDomainAndRegistryFromGURL("AppBanner.NativeApp.Shown",
web_contents()->GetURL());
} else if (!web_app_data_.IsEmpty()){
RecordCouldShowBanner(web_app_data_.start_url.spec());
if (!CheckIfShouldShow(web_app_data_.start_url.spec()))
......@@ -275,6 +284,9 @@ void AppBannerManager::OnFetchComplete(BannerBitmapFetcher* fetcher,
app_title_,
new SkBitmap(*bitmap),
web_app_data_);
rappor::SampleDomainAndRegistryFromGURL("AppBanner.WebApp.Shown",
web_contents()->GetURL());
}
if (weak_infobar_ptr != nullptr)
......
......@@ -43,6 +43,52 @@ components/rappor/rappor_service.cc.
<rappor-metrics>
<!-- Rappor metric definitions -->
<rappor-metric name="AppBanner.NativeApp.Dismissed" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a native app banner, which was explicitly
dismissed by the user.
</summary>
</rappor-metric>
<rappor-metric name="AppBanner.NativeApp.Installed" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a native app banner, which resulted in
the user installing the promoted application.
</summary>
</rappor-metric>
<rappor-metric name="AppBanner.NativeApp.Shown" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a native app banner.
</summary>
</rappor-metric>
<rappor-metric name="AppBanner.WebApp.Dismissed" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a web app banner, which was explicitly
dismissed by the user.
</summary>
</rappor-metric>
<rappor-metric name="AppBanner.WebApp.Installed" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a web app banner, which resulted in the
user installing the promoted application.
</summary>
</rappor-metric>
<rappor-metric name="AppBanner.WebApp.Shown" type="ETLD_PLUS_ONE">
<owner>dfalcantara@chromium.org</owner>
<summary>
The eTLD+1 of a URL that displayed a web app banner.
</summary>
</rappor-metric>
<rappor-metric name="ContentSettings.MixedScript.DisplayedShield"
type="ETLD_PLUS_ONE">
<owner>lgarron@chromium.org</owner>
......
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