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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 | 260 |
261 if (!is_active_) | 261 if (!is_active_) |
262 return; | 262 return; |
263 | 263 |
264 DCHECK(data.is_installable); | 264 DCHECK(data.is_installable); |
265 DCHECK(!data.primary_icon_url.is_empty()); | 265 DCHECK(!data.primary_icon_url.is_empty()); |
266 DCHECK(data.primary_icon); | 266 DCHECK(data.primary_icon); |
267 | 267 |
268 primary_icon_url_ = data.primary_icon_url; | 268 primary_icon_url_ = data.primary_icon_url; |
269 primary_icon_.reset(new SkBitmap(*data.primary_icon)); | 269 primary_icon_ = *data.primary_icon; |
270 | 270 |
271 SendBannerPromptRequest(); | 271 SendBannerPromptRequest(); |
272 } | 272 } |
273 | 273 |
274 void AppBannerManager::RecordDidShowBanner(const std::string& event_name) { | 274 void AppBannerManager::RecordDidShowBanner(const std::string& event_name) { |
275 content::WebContents* contents = web_contents(); | 275 content::WebContents* contents = web_contents(); |
276 DCHECK(contents); | 276 DCHECK(contents); |
277 | 277 |
278 AppBannerSettingsHelper::RecordBannerEvent( | 278 AppBannerSettingsHelper::RecordBannerEvent( |
279 contents, validated_url_, GetAppIdentifier(), | 279 contents, validated_url_, GetAppIdentifier(), |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 } else { | 508 } else { |
509 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION); | 509 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_NO_ACTION); |
510 } | 510 } |
511 | 511 |
512 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( | 512 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( |
513 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); | 513 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); |
514 | 514 |
515 DCHECK(!manifest_url_.is_empty()); | 515 DCHECK(!manifest_url_.is_empty()); |
516 DCHECK(!manifest_.IsEmpty()); | 516 DCHECK(!manifest_.IsEmpty()); |
517 DCHECK(!primary_icon_url_.is_empty()); | 517 DCHECK(!primary_icon_url_.is_empty()); |
518 DCHECK(primary_icon_.get()); | 518 DCHECK(!primary_icon_.drawsNothing()); |
519 | 519 |
520 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); | 520 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); |
521 ShowBanner(); | 521 ShowBanner(); |
522 is_active_ = false; | 522 is_active_ = false; |
523 } | 523 } |
524 | 524 |
525 void AppBannerManager::DisplayAppBanner() { | 525 void AppBannerManager::DisplayAppBanner() { |
526 if (was_canceled_by_page_) { | 526 if (was_canceled_by_page_) { |
527 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 527 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
528 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 528 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
529 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 529 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
530 } else { | 530 } else { |
531 // Log that the prompt request was made for when we get the prompt reply. | 531 // Log that the prompt request was made for when we get the prompt reply. |
532 page_requested_prompt_ = true; | 532 page_requested_prompt_ = true; |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 } // namespace banners | 536 } // namespace banners |
OLD | NEW |