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

Unified Diff: chrome/browser/android/banners/app_banner_data_fetcher_android.cc

Issue 2050933002: Upstream: Add additional checks before creating a WebAPK after clicking "Add to Homescreen" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'create_webapk_requirements_enum_class' into create_webapk_requirements2 Created 4 years, 5 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/android/banners/app_banner_data_fetcher_android.cc
diff --git a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc
index 10164088aa5ddfb2cfc92468681e243ffb5e2a2e..461cb960217f02cc8ad8a59b239a67565266fcf2 100644
--- a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc
+++ b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
#include "chrome/browser/android/shortcut_helper.h"
@@ -15,6 +16,7 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/manifest/manifest_icon_selector.h"
#include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
+#include "chrome/common/chrome_switches.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace banners {
@@ -32,6 +34,7 @@ AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid(
ideal_icon_size_in_dp,
minimum_icon_size_in_dp,
is_debug_mode),
+ webapp_type_(ShortcutInfo::Type::OTHER),
ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp),
minimum_splash_image_size_in_dp_(minimum_splash_image_size_in_dp) {}
@@ -54,6 +57,20 @@ bool AppBannerDataFetcherAndroid::ContinueFetching(
return FetchAppIcon(GetWebContents(), image_url);
}
+bool AppBannerDataFetcherAndroid::CheckManifest(
+ const content::Manifest& manifest,
+ OutputDeveloperMessageCode* code) {
+ bool manifest_valid_for_webapp =
+ AppBannerDataFetcher::CheckManifest(manifest, code);
+ if (manifest_valid_for_webapp) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ webapp_type_ = command_line->HasSwitch(switches::kEnableWebApk)
+ ? ShortcutInfo::Type::WEBAPK
+ : ShortcutInfo::Type::WEBAPP;
+ }
+ return manifest_valid_for_webapp;
+}
+
std::string AppBannerDataFetcherAndroid::GetAppIdentifier() {
return native_app_data_.is_null()
? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_;
@@ -85,7 +102,8 @@ void AppBannerDataFetcherAndroid::ShowBanner(const GURL& icon_url,
std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate(
new AppBannerInfoBarDelegateAndroid(event_request_id(), this, title,
icon_url, new SkBitmap(*icon),
- manifest_url(), manifest()));
+ manifest_url(), manifest(),
+ webapp_type_));
infobar = new AppBannerInfoBarAndroid(std::move(delegate),
manifest().start_url);

Powered by Google App Engine
This is Rietveld 408576698