Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 | 424 |
| 425 load_finished_ = true; | 425 load_finished_ = true; |
| 426 validated_url_ = validated_url; | 426 validated_url_ = validated_url; |
| 427 | 427 |
| 428 // If the bypass flag is on, or if we require no engagement to trigger the | 428 // If the bypass flag is on, or if we require no engagement to trigger the |
| 429 // banner, the rest of the banner pipeline should operate as if the engagement | 429 // banner, the rest of the banner pipeline should operate as if the engagement |
| 430 // threshold has been met. | 430 // threshold has been met. |
| 431 if (AppBannerSettingsHelper::HasSufficientEngagement(0)) | 431 if (AppBannerSettingsHelper::HasSufficientEngagement(0)) |
| 432 has_sufficient_engagement_ = true; | 432 has_sufficient_engagement_ = true; |
| 433 | 433 |
| 434 // If the page already has enough engagement, trigger the pipeline | |
| 435 // immediately. | |
| 436 if (AppBannerSettingsHelper::HasSufficientEngagement( | |
| 437 SiteEngagementService::Get( | |
|
dominickn
2017/06/23 04:55:35
This is called quite a lot. Instead, just have a s
dominickn
2017/06/23 04:57:44
That might also let you combine this if statement
benwells
2017/06/23 05:12:04
Done.
benwells
2017/06/23 05:12:04
Done.
| |
| 438 Profile::FromBrowserContext(web_contents()->GetBrowserContext())) | |
| 439 ->GetScore(validated_url))) { | |
| 440 has_sufficient_engagement_ = true; | |
| 441 } | |
| 442 | |
| 434 // Start the pipeline immediately if we pass (or bypass) the engagement check, | 443 // Start the pipeline immediately if we pass (or bypass) the engagement check, |
| 435 // or if the feature to run the installability check on page load is enabled. | 444 // or if the feature to run the installability check on page load is enabled. |
| 436 if (has_sufficient_engagement_ || | 445 if (has_sufficient_engagement_ || |
| 437 base::FeatureList::IsEnabled( | 446 base::FeatureList::IsEnabled( |
| 438 features::kCheckInstallabilityForBannerOnLoad)) { | 447 features::kCheckInstallabilityForBannerOnLoad)) { |
| 439 RequestAppBanner(validated_url, false /* is_debug_mode */); | 448 RequestAppBanner(validated_url, false /* is_debug_mode */); |
| 440 } | 449 } |
| 441 } | 450 } |
| 442 | 451 |
| 443 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info, | 452 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 if (is_pending_event()) { | 596 if (is_pending_event()) { |
| 588 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 597 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 589 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 598 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 590 } else { | 599 } else { |
| 591 // Log that the prompt request was made for when we get the prompt reply. | 600 // Log that the prompt request was made for when we get the prompt reply. |
| 592 page_requested_prompt_ = true; | 601 page_requested_prompt_ = true; |
| 593 } | 602 } |
| 594 } | 603 } |
| 595 | 604 |
| 596 } // namespace banners | 605 } // namespace banners |
| OLD | NEW |