| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 if (!is_active()) | 262 if (!is_active()) |
| 263 return; | 263 return; |
| 264 | 264 |
| 265 DCHECK(data.is_installable); | 265 DCHECK(data.is_installable); |
| 266 DCHECK(!data.primary_icon_url.is_empty()); | 266 DCHECK(!data.primary_icon_url.is_empty()); |
| 267 DCHECK(data.primary_icon); | 267 DCHECK(data.primary_icon); |
| 268 | 268 |
| 269 primary_icon_url_ = data.primary_icon_url; | 269 primary_icon_url_ = data.primary_icon_url; |
| 270 primary_icon_.reset(new SkBitmap(*data.primary_icon)); | 270 primary_icon_ = *data.primary_icon; |
| 271 | 271 |
| 272 // If we triggered the installability check on page load, then it's possible | 272 // If we triggered the installability check on page load, then it's possible |
| 273 // we don't have enough engagement yet. If that's the case, return here but | 273 // we don't have enough engagement yet. If that's the case, return here but |
| 274 // don't call Stop(). We wait for OnEngagementIncreased to tell us that we | 274 // don't call Stop(). We wait for OnEngagementIncreased to tell us that we |
| 275 // should trigger. | 275 // should trigger. |
| 276 if (!has_sufficient_engagement_) { | 276 if (!has_sufficient_engagement_) { |
| 277 UpdateState(State::PENDING_ENGAGEMENT); | 277 UpdateState(State::PENDING_ENGAGEMENT); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } else { | 533 } else { |
| 534 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION); | 534 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION); |
| 535 } | 535 } |
| 536 | 536 |
| 537 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( | 537 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( |
| 538 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); | 538 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); |
| 539 | 539 |
| 540 DCHECK(!manifest_url_.is_empty()); | 540 DCHECK(!manifest_url_.is_empty()); |
| 541 DCHECK(!manifest_.IsEmpty()); | 541 DCHECK(!manifest_.IsEmpty()); |
| 542 DCHECK(!primary_icon_url_.is_empty()); | 542 DCHECK(!primary_icon_url_.is_empty()); |
| 543 DCHECK(primary_icon_.get()); | 543 DCHECK(!primary_icon_.drawsNothing()); |
| 544 | 544 |
| 545 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); | 545 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); |
| 546 ShowBanner(); | 546 ShowBanner(); |
| 547 UpdateState(State::COMPLETE); | 547 UpdateState(State::COMPLETE); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void AppBannerManager::DisplayAppBanner() { | 550 void AppBannerManager::DisplayAppBanner() { |
| 551 if (is_pending_event()) { | 551 if (is_pending_event()) { |
| 552 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 552 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 553 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 553 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 554 } else { | 554 } else { |
| 555 // Log that the prompt request was made for when we get the prompt reply. | 555 // Log that the prompt request was made for when we get the prompt reply. |
| 556 page_requested_prompt_ = true; | 556 page_requested_prompt_ = true; |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace banners | 560 } // namespace banners |
| OLD | NEW |