| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" |
| 6 |
| 7 #include "content/public/common/manifest.h" |
| 8 #include "url/gurl.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 // Returns whether a URL in the Web Manifest is WebAPK compatible. |
| 13 bool IsUrlWebApkCompatible(const GURL& url) { |
| 14 // WebAPK web manifests are stored on the Chrome WebAPK server. Do not |
| 15 // generate WebAPKs for Web Manifests with URLs with a user name or password |
| 16 // in order to avoid storing user names and passwords on the WebAPK server. |
| 17 return !url.has_username() && !url.has_password(); |
| 18 } |
| 19 |
| 20 } // anonymous namespace |
| 21 |
| 22 bool AreWebManifestUrlsWebApkCompatible(const content::Manifest& manifest) { |
| 23 for (const content::Manifest::Icon& icon : manifest.icons) { |
| 24 if (!IsUrlWebApkCompatible(icon.src)) |
| 25 return false; |
| 26 } |
| 27 |
| 28 // Do not check "related_applications" URLs because they are not used by |
| 29 // WebAPKs. |
| 30 |
| 31 return IsUrlWebApkCompatible(manifest.start_url) && |
| 32 IsUrlWebApkCompatible(manifest.scope); |
| 33 } |
| OLD | NEW |