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

Unified Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1569893003: Add "Request app banner" context menu in DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on https://codereview.chromium.org/1571633002/ Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/banners/app_banner_data_fetcher.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc
index 0090d1016e30f8a0d631bed8c18b4e25b7c66ed8..896e4832589ca82a1ac39bd54ca8279207903b0b 100644
--- a/chrome/browser/banners/app_banner_data_fetcher.cc
+++ b/chrome/browser/banners/app_banner_data_fetcher.cc
@@ -71,11 +71,11 @@ void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) {
gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
}
-AppBannerDataFetcher::AppBannerDataFetcher(
- content::WebContents* web_contents,
- base::WeakPtr<Delegate> delegate,
- int ideal_icon_size_in_dp,
- int minimum_icon_size_in_dp)
+AppBannerDataFetcher::AppBannerDataFetcher(content::WebContents* web_contents,
+ base::WeakPtr<Delegate> delegate,
+ int ideal_icon_size_in_dp,
+ int minimum_icon_size_in_dp,
+ bool is_debug_mode)
: WebContentsObserver(web_contents),
weak_delegate_(delegate),
ideal_icon_size_in_dp_(ideal_icon_size_in_dp),
@@ -83,7 +83,8 @@ AppBannerDataFetcher::AppBannerDataFetcher(
is_active_(false),
was_canceled_by_page_(false),
page_requested_prompt_(false),
- event_request_id_(-1) {
+ event_request_id_(-1),
+ is_debug_mode_(is_debug_mode) {
DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp);
}
@@ -184,7 +185,8 @@ void AppBannerDataFetcher::OnBannerPromptReply(
!page_requested_prompt_) {
was_canceled_by_page_ = true;
referrer_ = referrer;
- OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel);
+ OutputDeveloperNotShownMessage(web_contents, kRendererRequestCancel,
+ is_debug_mode_);
return;
}
@@ -247,7 +249,7 @@ void AppBannerDataFetcher::OnDidHasManifest(bool has_manifest) {
if (!CheckFetcherIsStillAlive(web_contents) || !has_manifest) {
if (!has_manifest)
- OutputDeveloperNotShownMessage(web_contents, kNoManifest);
+ OutputDeveloperNotShownMessage(web_contents, kNoManifest, is_debug_mode_);
Cancel();
return;
@@ -265,7 +267,8 @@ void AppBannerDataFetcher::OnDidGetManifest(
return;
}
if (manifest.IsEmpty()) {
- OutputDeveloperNotShownMessage(web_contents, kManifestEmpty);
+ OutputDeveloperNotShownMessage(web_contents, kManifestEmpty,
+ is_debug_mode_);
Cancel();
return;
}
@@ -280,7 +283,7 @@ void AppBannerDataFetcher::OnDidGetManifest(
}
}
- if (!IsManifestValidForWebApp(manifest, web_contents)) {
+ if (!IsManifestValidForWebApp(manifest, web_contents, is_debug_mode_)) {
Cancel();
return;
}
@@ -292,7 +295,8 @@ void AppBannerDataFetcher::OnDidGetManifest(
manifest.start_url) &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kBypassAppBannerEngagementChecks)) {
- OutputDeveloperNotShownMessage(web_contents, kBannerAlreadyAdded);
+ OutputDeveloperNotShownMessage(web_contents, kBannerAlreadyAdded,
+ is_debug_mode_);
Cancel();
return;
}
@@ -324,7 +328,8 @@ void AppBannerDataFetcher::OnDidCheckHasServiceWorker(
if (!has_service_worker) {
TrackDisplayEvent(DISPLAY_EVENT_LACKS_SERVICE_WORKER);
- OutputDeveloperNotShownMessage(web_contents, kNoMatchingServiceWorker);
+ OutputDeveloperNotShownMessage(web_contents, kNoMatchingServiceWorker,
+ is_debug_mode_);
Cancel();
return;
}
@@ -342,7 +347,8 @@ void AppBannerDataFetcher::OnHasServiceWorker(
gfx::Screen::GetScreenFor(web_contents->GetNativeView()));
if (!FetchAppIcon(web_contents, icon_url)) {
- OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon);
+ OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon,
+ is_debug_mode_);
Cancel();
}
}
@@ -367,16 +373,18 @@ void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) {
return;
}
if (bitmap.drawsNothing()) {
- OutputDeveloperNotShownMessage(web_contents, kNoIconAvailable);
+ OutputDeveloperNotShownMessage(web_contents, kNoIconAvailable,
+ is_debug_mode_);
Cancel();
return;
}
RecordCouldShowBanner();
- if (!CheckIfShouldShowBanner()) {
+ if (!is_debug_mode_ && !CheckIfShouldShowBanner()) {
// At this point, the only possible case is that the banner has been added
// to the homescreen, given all of the other checks that have been made.
- OutputDeveloperNotShownMessage(web_contents, kBannerAlreadyAdded);
+ OutputDeveloperNotShownMessage(web_contents, kBannerAlreadyAdded,
+ is_debug_mode_);
Cancel();
return;
}
@@ -416,8 +424,8 @@ bool AppBannerDataFetcher::CheckIfShouldShowBanner() {
bool AppBannerDataFetcher::CheckFetcherIsStillAlive(
content::WebContents* web_contents) {
if (!is_active_) {
- OutputDeveloperNotShownMessage(web_contents,
- kUserNavigatedBeforeBannerShown);
+ OutputDeveloperNotShownMessage(
+ web_contents, kUserNavigatedBeforeBannerShown, is_debug_mode_);
return false;
}
if (!web_contents) {
@@ -429,22 +437,25 @@ bool AppBannerDataFetcher::CheckFetcherIsStillAlive(
// static
bool AppBannerDataFetcher::IsManifestValidForWebApp(
const content::Manifest& manifest,
- content::WebContents* web_contents) {
+ content::WebContents* web_contents,
+ bool is_debug_mode) {
if (manifest.IsEmpty()) {
- OutputDeveloperNotShownMessage(web_contents, kManifestEmpty);
+ OutputDeveloperNotShownMessage(web_contents, kManifestEmpty, is_debug_mode);
return false;
}
if (!manifest.start_url.is_valid()) {
- OutputDeveloperNotShownMessage(web_contents, kStartURLNotValid);
+ OutputDeveloperNotShownMessage(web_contents, kStartURLNotValid,
+ is_debug_mode);
return false;
}
if (manifest.name.is_null() && manifest.short_name.is_null()) {
- OutputDeveloperNotShownMessage(web_contents,
- kManifestMissingNameOrShortName);
+ OutputDeveloperNotShownMessage(
+ web_contents, kManifestMissingNameOrShortName, is_debug_mode);
return false;
}
if (!DoesManifestContainRequiredIcon(manifest)) {
- OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon);
+ OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon,
+ is_debug_mode);
return false;
}
return true;

Powered by Google App Engine
This is Rietveld 408576698