| 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 09bc96fa963f59b40d2341d91fcbf7e0338619e5..6c276ba5cf711f0ad1631c273bf070e12ade547b 100644
|
| --- a/chrome/browser/banners/app_banner_data_fetcher.cc
|
| +++ b/chrome/browser/banners/app_banner_data_fetcher.cc
|
| @@ -10,9 +10,9 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| -#include "chrome/browser/banners/app_banner_debug_log.h"
|
| #include "chrome/browser/banners/app_banner_metrics.h"
|
| #include "chrome/browser/banners/app_banner_settings_helper.h"
|
| +#include "chrome/browser/banners/webapp_manifest_validator.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/manifest/manifest_icon_downloader.h"
|
| #include "chrome/browser/manifest/manifest_icon_selector.h"
|
| @@ -35,30 +35,6 @@ namespace {
|
| base::LazyInstance<base::TimeDelta> gTimeDeltaForTesting =
|
| LAZY_INSTANCE_INITIALIZER;
|
| int gCurrentRequestID = -1;
|
| -const char kPngExtension[] = ".png";
|
| -
|
| -// The requirement for now is an image/png that is at least 144x144.
|
| -const int kIconMinimumSize = 144;
|
| -bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) {
|
| - for (const auto& icon : manifest.icons) {
|
| - // The type field is optional. If it isn't present, fall back on checking
|
| - // the src extension, and allow the icon if the extension ends with png.
|
| - if (!base::EqualsASCII(icon.type.string(), "image/png") &&
|
| - !(icon.type.is_null() &&
|
| - base::EndsWith(icon.src.ExtractFileName(), kPngExtension,
|
| - base::CompareCase::INSENSITIVE_ASCII)))
|
| - continue;
|
| -
|
| - for (const auto& size : icon.sizes) {
|
| - if (size.IsEmpty()) // "any"
|
| - return true;
|
| - if (size.width() >= kIconMinimumSize && size.height() >= kIconMinimumSize)
|
| - return true;
|
| - }
|
| - }
|
| -
|
| - return false;
|
| -}
|
|
|
| } // anonymous namespace
|
|
|
| @@ -297,7 +273,9 @@ void AppBannerDataFetcher::OnDidGetManifest(
|
| }
|
| }
|
|
|
| - if (!IsManifestValidForWebApp(manifest, web_contents, is_debug_mode_)) {
|
| + OutputDeveloperMessageCode error_code = OutputDeveloperMessageCode::kNone;
|
| + if (!CheckManifest(manifest, &error_code)) {
|
| + OutputDeveloperNotShownMessage(web_contents, error_code, is_debug_mode_);
|
| Cancel();
|
| return;
|
| }
|
| @@ -415,6 +393,11 @@ void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) {
|
| GetBannerType()));
|
| }
|
|
|
| +bool AppBannerDataFetcher::CheckManifest(const content::Manifest& manifest,
|
| + OutputDeveloperMessageCode* code) {
|
| + return webapp_manifest_validator::IsManifestGoodForWebapp(manifest, code);
|
| +}
|
| +
|
| bool AppBannerDataFetcher::IsWebAppInstalled(
|
| content::BrowserContext* browser_context,
|
| const GURL& start_url) {
|
| @@ -453,51 +436,4 @@ bool AppBannerDataFetcher::CheckFetcherIsStillAlive(
|
| return true;
|
| }
|
|
|
| -// static
|
| -bool AppBannerDataFetcher::IsManifestValidForWebApp(
|
| - const content::Manifest& manifest,
|
| - content::WebContents* web_contents,
|
| - bool is_debug_mode) {
|
| - if (manifest.IsEmpty()) {
|
| - OutputDeveloperNotShownMessage(web_contents,
|
| - OutputDeveloperMessageCode::kManifestEmpty,
|
| - is_debug_mode);
|
| - return false;
|
| - }
|
| - if (!manifest.start_url.is_valid()) {
|
| - OutputDeveloperNotShownMessage(
|
| - web_contents, OutputDeveloperMessageCode::kStartURLNotValid,
|
| - is_debug_mode);
|
| - return false;
|
| - }
|
| - if ((manifest.name.is_null() || manifest.name.string().empty()) &&
|
| - (manifest.short_name.is_null() || manifest.short_name.string().empty())) {
|
| - OutputDeveloperNotShownMessage(
|
| - web_contents,
|
| - OutputDeveloperMessageCode::kManifestMissingNameOrShortName,
|
| - is_debug_mode);
|
| - return false;
|
| - }
|
| -
|
| - // TODO(dominickn,mlamouri): when Chrome supports "minimal-ui", it should be
|
| - // accepted. If we accept it today, it would fallback to "browser" and make
|
| - // this check moot. See https://crbug.com/604390
|
| - if (manifest.display != blink::WebDisplayModeStandalone &&
|
| - manifest.display != blink::WebDisplayModeFullscreen) {
|
| - OutputDeveloperNotShownMessage(
|
| - web_contents,
|
| - OutputDeveloperMessageCode::kManifestDisplayStandaloneFullscreen,
|
| - is_debug_mode);
|
| - return false;
|
| - }
|
| -
|
| - if (!DoesManifestContainRequiredIcon(manifest)) {
|
| - OutputDeveloperNotShownMessage(
|
| - web_contents, OutputDeveloperMessageCode::kManifestMissingSuitableIcon,
|
| - is_debug_mode);
|
| - return false;
|
| - }
|
| - return true;
|
| -}
|
| -
|
| } // namespace banners
|
|
|