| 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 if (url.has_username() || url.has_password()) |
| 18 return false; |
| 19 |
| 20 // For the sake of simplicity we do not generate WebAPKs for Web Manifests |
| 21 // with URLs with a custom port. |
| 22 return !url.has_port(); |
| 23 } |
| 24 |
| 25 } // anonymous namespace |
| 26 |
| 27 bool AreWebManifestUrlsWebApkCompatible(const content::Manifest& manifest) { |
| 28 for (const content::Manifest::Icon& icon : manifest.icons) { |
| 29 if (!IsUrlWebApkCompatible(icon.src)) |
| 30 return false; |
| 31 } |
| 32 |
| 33 // Do not check "related_applications" URLs because they are not used by |
| 34 // WebAPKs. |
| 35 |
| 36 return IsUrlWebApkCompatible(manifest.start_url) && |
| 37 IsUrlWebApkCompatible(manifest.scope); |
| 38 } |
| OLD | NEW |