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

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: Splitting out into a new metric 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
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_metrics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 referrer_.erase(); 108 referrer_.erase();
109 web_contents->HasManifest( 109 web_contents->HasManifest(
110 base::Bind(&AppBannerDataFetcher::OnDidHasManifest, this)); 110 base::Bind(&AppBannerDataFetcher::OnDidHasManifest, this));
111 } 111 }
112 112
113 void AppBannerDataFetcher::Cancel() { 113 void AppBannerDataFetcher::Cancel() {
114 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 114 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
115 if (is_active_) { 115 if (is_active_) {
116 FOR_EACH_OBSERVER(Observer, observer_list_, 116 FOR_EACH_OBSERVER(Observer, observer_list_,
117 OnDecidedWhetherToShow(this, false)); 117 OnDecidedWhetherToShow(this, false));
118 if (was_canceled_by_page_ && !page_requested_prompt_)
119 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED);
benwells 2016/07/05 05:34:49 Nit: This name is a bit misleading, I think it mea
dominickn 2016/07/05 06:00:09 Done.
120
118 is_active_ = false; 121 is_active_ = false;
119 was_canceled_by_page_ = false; 122 was_canceled_by_page_ = false;
120 page_requested_prompt_ = false; 123 page_requested_prompt_ = false;
121 referrer_.erase(); 124 referrer_.erase();
122 } 125 }
123 } 126 }
124 127
125 void AppBannerDataFetcher::ReplaceWebContents( 128 void AppBannerDataFetcher::ReplaceWebContents(
126 content::WebContents* web_contents) { 129 content::WebContents* web_contents) {
127 Observe(web_contents); 130 Observe(web_contents);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // called if a redisplay isn't asked for. 184 // called if a redisplay isn't asked for.
182 // 185 //
183 // The redisplay request may be received before the Cancel prompt reply 186 // The redisplay request may be received before the Cancel prompt reply
184 // *after* if it is made before the beforeinstallprompt event handler 187 // *after* if it is made before the beforeinstallprompt event handler
185 // concludes (e.g. in the event handler itself), so allow the pipeline 188 // concludes (e.g. in the event handler itself), so allow the pipeline
186 // to continue in this case. 189 // to continue in this case.
187 // 190 //
188 // Stash the referrer for the case where the banner is redisplayed. 191 // Stash the referrer for the case where the banner is redisplayed.
189 if (reply == blink::WebAppBannerPromptReply::Cancel && 192 if (reply == blink::WebAppBannerPromptReply::Cancel &&
190 !page_requested_prompt_) { 193 !page_requested_prompt_) {
194 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PREVENT_DEFAULT);
191 was_canceled_by_page_ = true; 195 was_canceled_by_page_ = true;
192 referrer_ = referrer; 196 referrer_ = referrer;
193 OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel, 197 OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel,
194 is_debug_mode_); 198 is_debug_mode_);
195 return; 199 return;
196 } 200 }
197 201
198 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( 202 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
199 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); 203 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
200 204
201 // Definitely going to show the banner now. 205 // Definitely going to show the banner now.
202 FOR_EACH_OBSERVER(Observer, observer_list_, 206 FOR_EACH_OBSERVER(Observer, observer_list_,
203 OnDecidedWhetherToShow(this, true)); 207 OnDecidedWhetherToShow(this, true));
204 208
209 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE);
205 ShowBanner(app_icon_url_, app_icon_.get(), app_title_, referrer); 210 ShowBanner(app_icon_url_, app_icon_.get(), app_title_, referrer);
206 is_active_ = false; 211 is_active_ = false;
207 } 212 }
208 213
209 void AppBannerDataFetcher::OnRequestShowAppBanner( 214 void AppBannerDataFetcher::OnRequestShowAppBanner(
210 content::RenderFrameHost* render_frame_host, 215 content::RenderFrameHost* render_frame_host,
211 int request_id) { 216 int request_id) {
217 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PROMPT_CALLED);
218
212 if (was_canceled_by_page_) { 219 if (was_canceled_by_page_) {
213 // Simulate an "OK" from the website to restart the banner display pipeline. 220 // Simulate an "OK" from the website to restart the banner display pipeline.
214 was_canceled_by_page_ = false; 221 was_canceled_by_page_ = false;
215 OnBannerPromptReply(render_frame_host, request_id, 222 OnBannerPromptReply(render_frame_host, request_id,
216 blink::WebAppBannerPromptReply::None, referrer_); 223 blink::WebAppBannerPromptReply::None, referrer_);
217 } else { 224 } else {
218 // Log that the prompt request was made for when we get the prompt reply. 225 // Log that the prompt request was made for when we get the prompt reply.
219 page_requested_prompt_ = true; 226 page_requested_prompt_ = true;
220 } 227 }
221 } 228 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 RecordCouldShowBanner(); 401 RecordCouldShowBanner();
395 if (!is_debug_mode_ && !CheckIfShouldShowBanner()) { 402 if (!is_debug_mode_ && !CheckIfShouldShowBanner()) {
396 // At this point, the only possible case is that the banner has been added 403 // At this point, the only possible case is that the banner has been added
397 // to the homescreen, given all of the other checks that have been made. 404 // to the homescreen, given all of the other checks that have been made.
398 Cancel(); 405 Cancel();
399 return; 406 return;
400 } 407 }
401 408
402 app_icon_.reset(new SkBitmap(bitmap)); 409 app_icon_.reset(new SkBitmap(bitmap));
403 event_request_id_ = ++gCurrentRequestID; 410 event_request_id_ = ++gCurrentRequestID;
411
412 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED);
404 web_contents->GetMainFrame()->Send( 413 web_contents->GetMainFrame()->Send(
405 new ChromeViewMsg_AppBannerPromptRequest( 414 new ChromeViewMsg_AppBannerPromptRequest(
406 web_contents->GetMainFrame()->GetRoutingID(), 415 web_contents->GetMainFrame()->GetRoutingID(),
407 event_request_id_, 416 event_request_id_,
408 GetBannerType())); 417 GetBannerType()));
409 } 418 }
410 419
411 bool AppBannerDataFetcher::IsWebAppInstalled( 420 bool AppBannerDataFetcher::IsWebAppInstalled(
412 content::BrowserContext* browser_context, 421 content::BrowserContext* browser_context,
413 const GURL& start_url) { 422 const GURL& start_url) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 486
478 if (!DoesManifestContainRequiredIcon(manifest)) { 487 if (!DoesManifestContainRequiredIcon(manifest)) {
479 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon, 488 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon,
480 is_debug_mode); 489 is_debug_mode);
481 return false; 490 return false;
482 } 491 }
483 return true; 492 return true;
484 } 493 }
485 494
486 } // namespace banners 495 } // namespace banners
OLDNEW
« 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