| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 bool AppBannerManager::CheckIfShouldShowBanner() { | 425 bool AppBannerManager::CheckIfShouldShowBanner() { |
| 426 content::WebContents* contents = web_contents(); | 426 content::WebContents* contents = web_contents(); |
| 427 DCHECK(contents); | 427 DCHECK(contents); |
| 428 | 428 |
| 429 InstallableStatusCode code = AppBannerSettingsHelper::ShouldShowBanner( | 429 InstallableStatusCode code = AppBannerSettingsHelper::ShouldShowBanner( |
| 430 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); | 430 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); |
| 431 if (code == NO_ERROR_DETECTED) | 431 if (code == NO_ERROR_DETECTED) |
| 432 return true; | 432 return true; |
| 433 | 433 |
| 434 switch (code) { |
| 435 case ALREADY_INSTALLED: |
| 436 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_INSTALLED_PREVIOUSLY); |
| 437 break; |
| 438 case PREVIOUSLY_BLOCKED: |
| 439 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_BLOCKED_PREVIOUSLY); |
| 440 break; |
| 441 case PREVIOUSLY_IGNORED: |
| 442 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_IGNORED_PREVIOUSLY); |
| 443 break; |
| 444 case INSUFFICIENT_ENGAGEMENT: |
| 445 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_NOT_VISITED_ENOUGH); |
| 446 break; |
| 447 default: |
| 448 break; |
| 449 } |
| 450 |
| 434 // If we are in debug mode, AppBannerSettingsHelper::ShouldShowBanner must | 451 // If we are in debug mode, AppBannerSettingsHelper::ShouldShowBanner must |
| 435 // return NO_ERROR_DETECTED (bypass flag is set) or we must not have entered | 452 // return NO_ERROR_DETECTED (bypass flag is set) or we must not have entered |
| 436 // this method. | 453 // this method. |
| 437 DCHECK(!IsDebugMode()); | 454 DCHECK(!IsDebugMode()); |
| 438 ReportStatus(web_contents(), code); | 455 ReportStatus(web_contents(), code); |
| 439 return false; | 456 return false; |
| 440 } | 457 } |
| 441 | 458 |
| 442 bool AppBannerManager::OnMessageReceived( | 459 bool AppBannerManager::OnMessageReceived( |
| 443 const IPC::Message& message, | 460 const IPC::Message& message, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 529 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
| 513 OnBannerPromptReply(render_frame_host, request_id, | 530 OnBannerPromptReply(render_frame_host, request_id, |
| 514 blink::WebAppBannerPromptReply::None, referrer_); | 531 blink::WebAppBannerPromptReply::None, referrer_); |
| 515 } else { | 532 } else { |
| 516 // Log that the prompt request was made for when we get the prompt reply. | 533 // Log that the prompt request was made for when we get the prompt reply. |
| 517 page_requested_prompt_ = true; | 534 page_requested_prompt_ = true; |
| 518 } | 535 } |
| 519 } | 536 } |
| 520 | 537 |
| 521 } // namespace banners | 538 } // namespace banners |
| OLD | NEW |