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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 2122783002: Add metrics for app banner preventDefault() and prompt(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/banners/app_banner_data_fetcher.h" 5 #include "chrome/browser/banners/app_banner_data_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // called if a redisplay isn't asked for. 181 // called if a redisplay isn't asked for.
182 // 182 //
183 // The redisplay request may be received before the Cancel prompt reply 183 // The redisplay request may be received before the Cancel prompt reply
184 // *after* if it is made before the beforeinstallprompt event handler 184 // *after* if it is made before the beforeinstallprompt event handler
185 // concludes (e.g. in the event handler itself), so allow the pipeline 185 // concludes (e.g. in the event handler itself), so allow the pipeline
186 // to continue in this case. 186 // to continue in this case.
187 // 187 //
188 // Stash the referrer for the case where the banner is redisplayed. 188 // Stash the referrer for the case where the banner is redisplayed.
189 if (reply == blink::WebAppBannerPromptReply::Cancel && 189 if (reply == blink::WebAppBannerPromptReply::Cancel &&
190 !page_requested_prompt_) { 190 !page_requested_prompt_) {
191 TrackDisplayEvent(DISPLAY_EVENT_CANCELED_BY_PAGE);
191 was_canceled_by_page_ = true; 192 was_canceled_by_page_ = true;
192 referrer_ = referrer; 193 referrer_ = referrer;
193 OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel, 194 OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel,
194 is_debug_mode_); 195 is_debug_mode_);
195 return; 196 return;
196 } 197 }
197 198
198 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( 199 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
199 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); 200 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
200 201
201 // Definitely going to show the banner now. 202 // Definitely going to show the banner now.
202 FOR_EACH_OBSERVER(Observer, observer_list_, 203 FOR_EACH_OBSERVER(Observer, observer_list_,
203 OnDecidedWhetherToShow(this, true)); 204 OnDecidedWhetherToShow(this, true));
204 205
205 ShowBanner(app_icon_.get(), app_title_, referrer); 206 ShowBanner(app_icon_.get(), app_title_, referrer);
206 is_active_ = false; 207 is_active_ = false;
207 } 208 }
208 209
209 void AppBannerDataFetcher::OnRequestShowAppBanner( 210 void AppBannerDataFetcher::OnRequestShowAppBanner(
210 content::RenderFrameHost* render_frame_host, 211 content::RenderFrameHost* render_frame_host,
211 int request_id) { 212 int request_id) {
212 if (was_canceled_by_page_) { 213 if (was_canceled_by_page_) {
213 // Simulate an "OK" from the website to restart the banner display pipeline. 214 // Simulate an "OK" from the website to restart the banner display pipeline.
214 was_canceled_by_page_ = false; 215 was_canceled_by_page_ = false;
216 TrackDisplayEvent(DISPLAY_EVENT_PROMPTED_BY_PAGE);
215 OnBannerPromptReply(render_frame_host, request_id, 217 OnBannerPromptReply(render_frame_host, request_id,
216 blink::WebAppBannerPromptReply::None, referrer_); 218 blink::WebAppBannerPromptReply::None, referrer_);
217 } else { 219 } else {
218 // Log that the prompt request was made for when we get the prompt reply. 220 // Log that the prompt request was made for when we get the prompt reply.
219 page_requested_prompt_ = true; 221 page_requested_prompt_ = true;
benwells 2016/07/05 02:56:20 Should we also track something here?
dominickn 2016/07/05 03:15:33 Good catch. The BeforeInstallPromptEvent should en
220 } 222 }
221 } 223 }
222 224
223 AppBannerDataFetcher::~AppBannerDataFetcher() { 225 AppBannerDataFetcher::~AppBannerDataFetcher() {
224 FOR_EACH_OBSERVER(Observer, observer_list_, OnFetcherDestroyed(this)); 226 FOR_EACH_OBSERVER(Observer, observer_list_, OnFetcherDestroyed(this));
225 } 227 }
226 228
227 std::string AppBannerDataFetcher::GetBannerType() { 229 std::string AppBannerDataFetcher::GetBannerType() {
228 return "web"; 230 return "web";
229 } 231 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 481
480 if (!DoesManifestContainRequiredIcon(manifest)) { 482 if (!DoesManifestContainRequiredIcon(manifest)) {
481 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon, 483 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon,
482 is_debug_mode); 484 is_debug_mode);
483 return false; 485 return false;
484 } 486 }
485 return true; 487 return true;
486 } 488 }
487 489
488 } // namespace banners 490 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_metrics.h » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698