Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3425)

Unified Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 2132483002: Add metrics for app banner preventDefault() and prompt(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/banners/app_banner_data_fetcher.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc
index 48589c0116663d3e26774bee7ecd8002a1145b9f..d01dbfee5c7566204f9426aa39bdfa6d1e5c4a9a 100644
--- a/chrome/browser/banners/app_banner_data_fetcher.cc
+++ b/chrome/browser/banners/app_banner_data_fetcher.cc
@@ -115,6 +115,11 @@ void AppBannerDataFetcher::Cancel() {
if (is_active_) {
FOR_EACH_OBSERVER(Observer, observer_list_,
OnDecidedWhetherToShow(this, false));
+ if (was_canceled_by_page_ && !page_requested_prompt_) {
+ TrackBeforeInstallEvent(
+ BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED_AFTER_PREVENT_DEFAULT);
+ }
+
is_active_ = false;
was_canceled_by_page_ = false;
page_requested_prompt_ = false;
@@ -188,6 +193,7 @@ void AppBannerDataFetcher::OnBannerPromptReply(
// Stash the referrer for the case where the banner is redisplayed.
if (reply == blink::WebAppBannerPromptReply::Cancel &&
!page_requested_prompt_) {
+ TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PREVENT_DEFAULT_CALLED);
was_canceled_by_page_ = true;
referrer_ = referrer;
OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel,
@@ -195,6 +201,17 @@ void AppBannerDataFetcher::OnBannerPromptReply(
return;
}
+ // If we haven't yet returned, but either of |was_canceled_by_page_| or
+ // |page_requested_prompt_| is true, the page has requested a delayed showing
+ // of the prompt. Otherwise, the prompt was never canceled by the page.
+ if (was_canceled_by_page_ || page_requested_prompt_) {
+ TrackBeforeInstallEvent(
+ BEFORE_INSTALL_EVENT_PROMPT_CALLED_AFTER_PREVENT_DEFAULT);
+ was_canceled_by_page_ = false;
+ } else {
+ TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION);
+ }
+
AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
@@ -202,6 +219,7 @@ void AppBannerDataFetcher::OnBannerPromptReply(
FOR_EACH_OBSERVER(Observer, observer_list_,
OnDecidedWhetherToShow(this, true));
+ TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE);
ShowBanner(app_icon_.get(), app_title_, referrer);
is_active_ = false;
}
@@ -211,7 +229,7 @@ void AppBannerDataFetcher::OnRequestShowAppBanner(
int request_id) {
if (was_canceled_by_page_) {
// Simulate an "OK" from the website to restart the banner display pipeline.
- was_canceled_by_page_ = false;
+ // Don't reset |was_canceled_by_page_| yet for metrics purposes.
OnBannerPromptReply(render_frame_host, request_id,
blink::WebAppBannerPromptReply::None, referrer_);
} else {
@@ -403,6 +421,8 @@ void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) {
app_icon_.reset(new SkBitmap(bitmap));
event_request_id_ = ++gCurrentRequestID;
+
+ TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED);
web_contents->GetMainFrame()->Send(
new ChromeViewMsg_AppBannerPromptRequest(
web_contents->GetMainFrame()->GetRoutingID(),
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698