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

Unified Diff: chrome/browser/android/webapk/webapk_web_manifest_checker.cc

Issue 2248293002: Do not install WebAPKs with web manifests with invalid URL components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_installable_checker Created 4 years, 4 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/webapk/webapk_web_manifest_checker.cc
diff --git a/chrome/browser/android/webapk/webapk_web_manifest_checker.cc b/chrome/browser/android/webapk/webapk_web_manifest_checker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6aad70b467088afcd81f703e6afb89967380b4b3
--- /dev/null
+++ b/chrome/browser/android/webapk/webapk_web_manifest_checker.cc
@@ -0,0 +1,33 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"
+
+#include "content/public/common/manifest.h"
+#include "url/gurl.h"
+
+namespace {
+
+// Returns whether a URL in the Web Manifest is WebAPK compatible.
+bool IsUrlWebApkCompatible(const GURL& url) {
+ // WebAPK web manifests are stored on the Chrome WebAPK server. Do not
+ // generate WebAPKs for Web Manifests with URLs with a user name or password
+ // in order to avoid storing user names and passwords on the WebAPK server.
+ return !url.has_username() && !url.has_password();
+}
+
+} // anonymous namespace
+
+bool AreWebManifestUrlsWebApkCompatible(const content::Manifest& manifest) {
+ for (const content::Manifest::Icon& icon : manifest.icons) {
+ if (!IsUrlWebApkCompatible(icon.src))
+ return false;
+ }
+
+ // Do not check "related_applications" URLs because they are not used by
+ // WebAPKs.
+
+ return IsUrlWebApkCompatible(manifest.start_url) &&
+ IsUrlWebApkCompatible(manifest.scope);
+}

Powered by Google App Engine
This is Rietveld 408576698