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

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

Issue 2957063002: Update app banner state machine to use more states. (Closed)
Patch Set: Rebase Created 3 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_manager.h" 5 #include "chrome/browser/banners/app_banner_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void AppBannerManager::SetTotalEngagementToTrigger(double engagement) { 55 void AppBannerManager::SetTotalEngagementToTrigger(double engagement) {
56 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); 56 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement);
57 } 57 }
58 58
59 void AppBannerManager::RequestAppBanner(const GURL& validated_url, 59 void AppBannerManager::RequestAppBanner(const GURL& validated_url,
60 bool is_debug_mode) { 60 bool is_debug_mode) {
61 content::WebContents* contents = web_contents(); 61 content::WebContents* contents = web_contents();
62 62
63 // The only time we should start the pipeline while it is already running is 63 // The only time we should start the pipeline while it is already running is
64 // if it's been triggered from devtools. 64 // if it's been triggered from devtools.
65 if (is_active_or_pending()) { 65 if (state_ != State::INACTIVE) {
66 DCHECK(is_debug_mode); 66 DCHECK(is_debug_mode);
67 ResetBindings(); 67 ResetBindings();
68 } 68 }
69 69
70 UpdateState(State::ACTIVE); 70 UpdateState(State::ACTIVE);
71 triggered_by_devtools_ = is_debug_mode; 71 triggered_by_devtools_ = is_debug_mode;
72 page_requested_prompt_ = false;
73 72
74 // We only need to call ReportStatus if we aren't in debug mode (this avoids 73 // We only need to call ReportStatus if we aren't in debug mode (this avoids
75 // skew from testing). 74 // skew from testing).
76 DCHECK(!need_to_log_status_); 75 DCHECK(!need_to_log_status_);
77 need_to_log_status_ = !IsDebugMode(); 76 need_to_log_status_ = !IsDebugMode();
78 77
79 // Exit if this is an incognito window, non-main frame, or insecure context. 78 // Exit if this is an incognito window, non-main frame, or insecure context.
80 InstallableStatusCode code = NO_ERROR_DETECTED; 79 InstallableStatusCode code = NO_ERROR_DETECTED;
81 if (Profile::FromBrowserContext(contents->GetBrowserContext()) 80 if (Profile::FromBrowserContext(contents->GetBrowserContext())
82 ->IsOffTheRecord()) { 81 ->IsOffTheRecord()) {
(...skipping 10 matching lines...) Expand all
93 return; 92 return;
94 } 93 }
95 94
96 if (validated_url_.is_empty()) 95 if (validated_url_.is_empty())
97 validated_url_ = validated_url; 96 validated_url_ = validated_url;
98 97
99 // Any existing binding is invalid when we request a new banner. 98 // Any existing binding is invalid when we request a new banner.
100 if (binding_.is_bound()) 99 if (binding_.is_bound())
101 binding_.Close(); 100 binding_.Close();
102 101
103 UpdateState(State::PENDING_MANIFEST); 102 UpdateState(State::FETCHING_MANIFEST);
104 manager_->GetData( 103 manager_->GetData(
105 ParamsToGetManifest(), 104 ParamsToGetManifest(),
106 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); 105 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr()));
107 } 106 }
108 107
109 void AppBannerManager::OnInstall() { 108 void AppBannerManager::OnInstall() {
110 blink::mojom::InstallationServicePtr installation_service; 109 blink::mojom::InstallationServicePtr installation_service;
111 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( 110 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
112 mojo::MakeRequest(&installation_service)); 111 mojo::MakeRequest(&installation_service));
113 DCHECK(installation_service); 112 DCHECK(installation_service);
(...skipping 16 matching lines...) Expand all
130 129
131 AppBannerManager::AppBannerManager(content::WebContents* web_contents) 130 AppBannerManager::AppBannerManager(content::WebContents* web_contents)
132 : content::WebContentsObserver(web_contents), 131 : content::WebContentsObserver(web_contents),
133 SiteEngagementObserver(SiteEngagementService::Get( 132 SiteEngagementObserver(SiteEngagementService::Get(
134 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), 133 Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
135 state_(State::INACTIVE), 134 state_(State::INACTIVE),
136 manager_(InstallableManager::FromWebContents(web_contents)), 135 manager_(InstallableManager::FromWebContents(web_contents)),
137 binding_(this), 136 binding_(this),
138 has_sufficient_engagement_(false), 137 has_sufficient_engagement_(false),
139 load_finished_(false), 138 load_finished_(false),
140 page_requested_prompt_(false),
141 triggered_by_devtools_(false), 139 triggered_by_devtools_(false),
142 need_to_log_status_(false), 140 need_to_log_status_(false),
143 weak_factory_(this) { 141 weak_factory_(this) {
144 DCHECK(manager_); 142 DCHECK(manager_);
145 143
146 AppBannerSettingsHelper::UpdateFromFieldTrial(); 144 AppBannerSettingsHelper::UpdateFromFieldTrial();
147 } 145 }
148 146
149 AppBannerManager::~AppBannerManager() { } 147 AppBannerManager::~AppBannerManager() { }
150 148
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 manifest_ = content::Manifest(); 289 manifest_ = content::Manifest();
292 manifest_url_ = GURL(); 290 manifest_url_ = GURL();
293 validated_url_ = GURL(); 291 validated_url_ = GURL();
294 referrer_.erase(); 292 referrer_.erase();
295 } 293 }
296 294
297 void AppBannerManager::Stop() { 295 void AppBannerManager::Stop() {
298 // Record the status if we are currently waiting for data. 296 // Record the status if we are currently waiting for data.
299 InstallableStatusCode code = NO_ERROR_DETECTED; 297 InstallableStatusCode code = NO_ERROR_DETECTED;
300 switch (state_) { 298 switch (state_) {
301 case State::PENDING_EVENT: 299 case State::PENDING_PROMPT:
302 if (!page_requested_prompt_) { 300 TrackBeforeInstallEvent(
303 TrackBeforeInstallEvent( 301 BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED_AFTER_PREVENT_DEFAULT);
304 BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED_AFTER_PREVENT_DEFAULT); 302 code = RENDERER_CANCELLED;
305 code = RENDERER_CANCELLED;
306 }
307 break; 303 break;
308 case State::PENDING_ENGAGEMENT: 304 case State::PENDING_ENGAGEMENT:
309 if (!has_sufficient_engagement_) { 305 if (!has_sufficient_engagement_) {
310 TrackDisplayEvent(DISPLAY_EVENT_NOT_VISITED_ENOUGH); 306 TrackDisplayEvent(DISPLAY_EVENT_NOT_VISITED_ENOUGH);
311 code = INSUFFICIENT_ENGAGEMENT; 307 code = INSUFFICIENT_ENGAGEMENT;
312 } 308 }
313 break; 309 break;
314 case State::PENDING_MANIFEST: 310 case State::FETCHING_MANIFEST:
315 code = WAITING_FOR_MANIFEST; 311 code = WAITING_FOR_MANIFEST;
316 break; 312 break;
317 case State::PENDING_INSTALLABLE_CHECK: 313 case State::PENDING_INSTALLABLE_CHECK:
318 code = WAITING_FOR_INSTALLABLE_CHECK; 314 code = WAITING_FOR_INSTALLABLE_CHECK;
319 break; 315 break;
320 case State::ACTIVE: 316 case State::ACTIVE:
317 case State::SENDING_EVENT:
318 case State::SENDING_EVENT_GOT_EARLY_PROMPT:
321 case State::INACTIVE: 319 case State::INACTIVE:
322 case State::COMPLETE: 320 case State::COMPLETE:
323 break; 321 break;
324 } 322 }
325 323
326 if (code != NO_ERROR_DETECTED) 324 if (code != NO_ERROR_DETECTED)
327 ReportStatus(web_contents(), code); 325 ReportStatus(web_contents(), code);
328 326
329 // In every non-debug run through the banner pipeline, we should have called 327 // In every non-debug run through the banner pipeline, we should have called
330 // ReportStatus() and set need_to_log_status_ to false. The only case where 328 // ReportStatus() and set need_to_log_status_ to false. The only case where
331 // we don't is if we're still active and waiting for native app data, which is 329 // we don't is if we're still running and aren't blocked on the network. When
332 // explicitly not logged. 330 // running and blocked on the network the state should be logged.
333 DCHECK(!need_to_log_status_ || is_active()); 331 // TODO(dominickn): log when the pipeline is fetching native app banner
332 // details.
333 DCHECK(!need_to_log_status_ || (IsRunning() && !IsBlockedOnNetwork()));
334 334
335 ResetBindings(); 335 ResetBindings();
336 UpdateState(State::COMPLETE); 336 UpdateState(State::COMPLETE);
337 need_to_log_status_ = false; 337 need_to_log_status_ = false;
338 has_sufficient_engagement_ = false; 338 has_sufficient_engagement_ = false;
339 } 339 }
340 340
341 void AppBannerManager::SendBannerPromptRequest() { 341 void AppBannerManager::SendBannerPromptRequest() {
342 RecordCouldShowBanner(); 342 RecordCouldShowBanner();
343
344 UpdateState(State::SENDING_EVENT);
343 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); 345 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED);
344 346
345 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( 347 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
346 mojo::MakeRequest(&controller_)); 348 mojo::MakeRequest(&controller_));
347 349
348 blink::mojom::AppBannerServicePtr banner_proxy; 350 blink::mojom::AppBannerServicePtr banner_proxy;
349 binding_.Bind(mojo::MakeRequest(&banner_proxy)); 351 binding_.Bind(mojo::MakeRequest(&banner_proxy));
350 controller_->BannerPromptRequest( 352 controller_->BannerPromptRequest(
351 std::move(banner_proxy), mojo::MakeRequest(&event_), {GetBannerType()}, 353 std::move(banner_proxy), mojo::MakeRequest(&event_), {GetBannerType()},
352 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); 354 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr()));
353 } 355 }
354 356
355 void AppBannerManager::UpdateState(State state) { 357 void AppBannerManager::UpdateState(State state) {
356 state_ = state; 358 state_ = state;
357
358 // If we are PENDING_EVENT, we must have sufficient engagement.
359 DCHECK(!is_pending_event() || has_sufficient_engagement_);
360 } 359 }
361 360
362 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { 361 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) {
363 if (!handle->IsInMainFrame() || handle->IsSameDocument()) 362 if (!handle->IsInMainFrame() || handle->IsSameDocument())
364 return; 363 return;
365 364
366 if (is_active_or_pending()) 365 if (state_ != State::COMPLETE && state_ != State::INACTIVE)
367 Stop(); 366 Stop();
368 UpdateState(State::INACTIVE); 367 UpdateState(State::INACTIVE);
369 load_finished_ = false; 368 load_finished_ = false;
370 has_sufficient_engagement_ = false; 369 has_sufficient_engagement_ = false;
371 page_requested_prompt_ = false;
372 } 370 }
373 371
374 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { 372 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {
375 if (handle->IsInMainFrame() && handle->HasCommitted() && 373 if (handle->IsInMainFrame() && handle->HasCommitted() &&
376 !handle->IsSameDocument()) { 374 !handle->IsSameDocument()) {
377 ResetCurrentPageData(); 375 ResetCurrentPageData();
378 } 376 }
379 } 377 }
380 378
381 void AppBannerManager::DidFinishLoad( 379 void AppBannerManager::DidFinishLoad(
(...skipping 12 matching lines...) Expand all
394 // Additionally, if the page already has enough engagement, trigger the 392 // Additionally, if the page already has enough engagement, trigger the
395 // pipeline immediately. 393 // pipeline immediately.
396 if (AppBannerSettingsHelper::HasSufficientEngagement(0) || 394 if (AppBannerSettingsHelper::HasSufficientEngagement(0) ||
397 AppBannerSettingsHelper::HasSufficientEngagement( 395 AppBannerSettingsHelper::HasSufficientEngagement(
398 GetSiteEngagementService()->GetScore(validated_url))) { 396 GetSiteEngagementService()->GetScore(validated_url))) {
399 has_sufficient_engagement_ = true; 397 has_sufficient_engagement_ = true;
400 } 398 }
401 399
402 // Start the pipeline immediately if we pass (or bypass) the engagement check, 400 // Start the pipeline immediately if we pass (or bypass) the engagement check,
403 // or if the feature to run the installability check on page load is enabled. 401 // or if the feature to run the installability check on page load is enabled.
404 if (!is_active_or_pending() && 402 if (state_ == State::INACTIVE &&
405 (has_sufficient_engagement_ || 403 (has_sufficient_engagement_ ||
406 base::FeatureList::IsEnabled( 404 base::FeatureList::IsEnabled(
407 features::kCheckInstallabilityForBannerOnLoad))) { 405 features::kCheckInstallabilityForBannerOnLoad))) {
408 RequestAppBanner(validated_url, false /* is_debug_mode */); 406 RequestAppBanner(validated_url, false /* is_debug_mode */);
409 } 407 }
410 } 408 }
411 409
412 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info, 410 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info,
413 const MediaPlayerId& id) { 411 const MediaPlayerId& id) {
414 active_media_players_.push_back(id); 412 active_media_players_.push_back(id);
415 } 413 }
416 414
417 void AppBannerManager::MediaStoppedPlaying(const MediaPlayerInfo& media_info, 415 void AppBannerManager::MediaStoppedPlaying(const MediaPlayerInfo& media_info,
418 const MediaPlayerId& id) { 416 const MediaPlayerId& id) {
419 active_media_players_.erase(std::remove(active_media_players_.begin(), 417 active_media_players_.erase(std::remove(active_media_players_.begin(),
420 active_media_players_.end(), id), 418 active_media_players_.end(), id),
421 active_media_players_.end()); 419 active_media_players_.end());
422 } 420 }
423 421
424 void AppBannerManager::WebContentsDestroyed() { 422 void AppBannerManager::WebContentsDestroyed() {
425 Stop(); 423 Stop();
426 } 424 }
427 425
428 void AppBannerManager::OnEngagementIncreased(content::WebContents* contents, 426 void AppBannerManager::OnEngagementIncreased(content::WebContents* contents,
429 const GURL& url, 427 const GURL& url,
430 double score) { 428 double score) {
431 // In the ACTIVE state, we may have triggered the installability check, but
432 // not checked engagement yet. In the INACTIVE or PENDING_ENGAGEMENT states,
433 // we are waiting for an engagement signal to trigger the pipeline.
434 if (is_complete() || is_pending_event())
435 return;
436
437 // Only trigger a banner using site engagement if: 429 // Only trigger a banner using site engagement if:
438 // 1. engagement increased for the web contents which we are attached to; and 430 // 1. engagement increased for the web contents which we are attached to; and
439 // 2. there are no currently active media players; and 431 // 2. there are no currently active media players; and
440 // 3. we have accumulated sufficient engagement. 432 // 3. we have accumulated sufficient engagement.
441 if (web_contents() == contents && active_media_players_.empty() && 433 if (web_contents() == contents && active_media_players_.empty() &&
442 AppBannerSettingsHelper::HasSufficientEngagement(score)) { 434 AppBannerSettingsHelper::HasSufficientEngagement(score)) {
443 has_sufficient_engagement_ = true; 435 has_sufficient_engagement_ = true;
444 436
445 if (is_pending_engagement()) { 437 if (is_pending_engagement()) {
446 // We have already finished the installability eligibility checks. Proceed 438 // We have already finished the installability eligibility checks. Proceed
447 // directly to sending the banner prompt request. 439 // directly to sending the banner prompt request.
448 UpdateState(State::ACTIVE); 440 UpdateState(State::ACTIVE);
449 SendBannerPromptRequest(); 441 SendBannerPromptRequest();
450 } else if (load_finished_ && !is_active_or_pending()) { 442 } else if (load_finished_ && state_ == State::INACTIVE) {
451 // This performs some simple tests and starts async checks to test 443 // This performs some simple tests and starts async checks to test
452 // installability. It should be safe to start in response to user input. 444 // installability. It should be safe to start in response to user input.
453 // Don't call if we're already working on processing a banner request. 445 // Don't call if we're already working on processing a banner request.
454 RequestAppBanner(url, false /* is_debug_mode */); 446 RequestAppBanner(url, false /* is_debug_mode */);
455 } 447 }
456 } 448 }
457 } 449 }
458 450
451 bool AppBannerManager::IsRunning() const {
452 switch (state_) {
453 case State::INACTIVE:
454 case State::PENDING_PROMPT:
455 case State::PENDING_ENGAGEMENT:
456 case State::COMPLETE:
457 return false;
458 case State::ACTIVE:
459 case State::FETCHING_MANIFEST:
460 case State::PENDING_INSTALLABLE_CHECK:
461 case State::SENDING_EVENT:
462 case State::SENDING_EVENT_GOT_EARLY_PROMPT:
463 return true;
464 }
465 return false;
466 }
467
468 bool AppBannerManager::IsBlockedOnNetwork() const {
469 return (state_ == State::FETCHING_MANIFEST ||
470 state_ == State::PENDING_INSTALLABLE_CHECK);
471 }
472
459 void AppBannerManager::ResetBindings() { 473 void AppBannerManager::ResetBindings() {
460 weak_factory_.InvalidateWeakPtrs(); 474 weak_factory_.InvalidateWeakPtrs();
461 binding_.Close(); 475 binding_.Close();
462 controller_.reset(); 476 controller_.reset();
463 event_.reset(); 477 event_.reset();
464 } 478 }
465 479
466 void AppBannerManager::RecordCouldShowBanner() { 480 void AppBannerManager::RecordCouldShowBanner() {
467 content::WebContents* contents = web_contents(); 481 content::WebContents* contents = web_contents();
468 DCHECK(contents); 482 DCHECK(contents);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // We don't need the controller any more, so reset it so the Blink-side object 532 // We don't need the controller any more, so reset it so the Blink-side object
519 // is destroyed. 533 // is destroyed.
520 controller_.reset(); 534 controller_.reset();
521 content::WebContents* contents = web_contents(); 535 content::WebContents* contents = web_contents();
522 536
523 // The renderer might have requested the prompt to be canceled. They may 537 // The renderer might have requested the prompt to be canceled. They may
524 // request that it is redisplayed later, so don't Stop() here. However, log 538 // request that it is redisplayed later, so don't Stop() here. However, log
525 // that the cancelation was requested, so Stop() can be called if a redisplay 539 // that the cancelation was requested, so Stop() can be called if a redisplay
526 // isn't asked for. 540 // isn't asked for.
527 // 541 //
528 // We use the additional page_requested_prompt_ variable because the redisplay 542 // If the redisplay request has not been received already, we stop here and
529 // request may be received *before* the Cancel prompt reply (e.g. if redisplay 543 // wait for the prompt function to be called. If the redisplay request has
530 // is requested in the beforeinstallprompt event handler). 544 // already been received before cancel was sent (e.g. if redisplay was
545 // requested in the beforeinstallprompt event handle), we keep going and show
dominickn 2017/07/07 06:23:18 Nit: "handler"
benwells 2017/07/07 06:29:27 Done.
546 // the banner immediately.
531 referrer_ = referrer; 547 referrer_ = referrer;
532 if (reply == blink::mojom::AppBannerPromptReply::CANCEL) { 548 if (reply == blink::mojom::AppBannerPromptReply::CANCEL) {
533 UpdateState(State::PENDING_EVENT);
534 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PREVENT_DEFAULT_CALLED); 549 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_PREVENT_DEFAULT_CALLED);
535 if (!page_requested_prompt_) 550 if (state_ == State::SENDING_EVENT) {
551 UpdateState(State::PENDING_PROMPT);
536 return; 552 return;
553 }
554 DCHECK(state_ == State::SENDING_EVENT_GOT_EARLY_PROMPT);
dominickn 2017/07/07 06:23:18 DCHECK_EQ(State::SENDING_EVENT_GOT_EARLY_PROMPT, s
benwells 2017/07/07 06:29:27 Done.
537 } 555 }
538 556
539 // If we haven't yet returned, but we're in the PENDING_EVENT state or 557 // If we are still in the SENDING_EVENT state, the prompt was never canceled
540 // |page_requested_prompt_| is true, the page has requested a delayed showing 558 // by the page. Otherwise the page requested a delayed showing of the prompt.
541 // of the prompt. Otherwise, the prompt was never canceled by the page. 559 if (state_ == State::SENDING_EVENT) {
542 if (is_pending_event()) { 560 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION);
561 } else {
543 TrackBeforeInstallEvent( 562 TrackBeforeInstallEvent(
544 BEFORE_INSTALL_EVENT_PROMPT_CALLED_AFTER_PREVENT_DEFAULT); 563 BEFORE_INSTALL_EVENT_PROMPT_CALLED_AFTER_PREVENT_DEFAULT);
545 UpdateState(State::ACTIVE);
546 } else {
547 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION);
548 } 564 }
549 565
550 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( 566 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
551 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); 567 contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
552 568
553 DCHECK(!manifest_url_.is_empty()); 569 DCHECK(!manifest_url_.is_empty());
554 DCHECK(!manifest_.IsEmpty()); 570 DCHECK(!manifest_.IsEmpty());
555 DCHECK(!primary_icon_url_.is_empty()); 571 DCHECK(!primary_icon_url_.is_empty());
556 DCHECK(!primary_icon_.drawsNothing()); 572 DCHECK(!primary_icon_.drawsNothing());
557 573
558 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); 574 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE);
559 ShowBanner(); 575 ShowBanner();
560 UpdateState(State::COMPLETE); 576 UpdateState(State::COMPLETE);
561 } 577 }
562 578
563 void AppBannerManager::DisplayAppBanner(bool user_gesture) { 579 void AppBannerManager::DisplayAppBanner(bool user_gesture) {
564 if (is_pending_event()) { 580 if (state_ == State::PENDING_PROMPT) {
565 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 581 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
566 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 582 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
567 } else { 583 } else if (state_ == State::SENDING_EVENT) {
568 // Log that the prompt request was made for when we get the prompt reply. 584 UpdateState(State::SENDING_EVENT_GOT_EARLY_PROMPT);
569 page_requested_prompt_ = true;
570 } 585 }
571 } 586 }
572 587
573 } // namespace banners 588 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698