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

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: Created 4 years, 6 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 b8dd12d87021e58ccb76f0cfadb1561f97822f81..797b2328d4262b30a5ee8968122d84c8b0e53eef 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_;
@@ -84,7 +101,7 @@ void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon,
std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate(
new AppBannerInfoBarDelegateAndroid(event_request_id(), this, title,
new SkBitmap(*icon),
- web_app_data()));
+ web_app_data(), webapp_type_));
infobar = new AppBannerInfoBarAndroid(std::move(delegate),
web_app_data().start_url);

Powered by Google App Engine
This is Rietveld 408576698