| 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. Returns |
| 13 // NO_ERROR_DETECTED if it is compatible and the error code otherwise. |
| 14 InstallableStatusCode CheckUrlWebApkCompatible(const GURL& url) { |
| 15 // WebAPK web manifests are stored on the Chrome WebAPK server. Do not |
| 16 // generate WebAPKs for Web Manifests with URLs with a user name or password |
| 17 // in order to avoid storing user names and passwords on the WebAPK server. |
| 18 if (url.has_username() || url.has_password()) |
| 19 return URL_USERNAME_AND_PASSWORD_NOT_SUPPORTED_FOR_WEBAPK; |
| 20 |
| 21 // For the sake of simplicity we do not generate WebAPKs for Web Manifests |
| 22 // with URLs with a custom port. |
| 23 if (url.has_port()) |
| 24 return URL_PORT_NOT_SUPPORTED_FOR_WEBAPK; |
| 25 |
| 26 return NO_ERROR_DETECTED; |
| 27 } |
| 28 |
| 29 } // anonymous namespace |
| 30 |
| 31 InstallableStatusCode CheckWebManifestUrlsWebApkCompatible( |
| 32 const content::Manifest& manifest) { |
| 33 InstallableStatusCode error_code = NO_ERROR_DETECTED; |
| 34 |
| 35 for (const content::Manifest::Icon& icon : manifest.icons) { |
| 36 error_code = CheckUrlWebApkCompatible(icon.src); |
| 37 if (error_code != NO_ERROR_DETECTED) |
| 38 return error_code; |
| 39 } |
| 40 |
| 41 // Do not check "related_applications" URLs because they are not used by |
| 42 // WebAPKs. |
| 43 |
| 44 error_code = CheckUrlWebApkCompatible(manifest.start_url); |
| 45 if (error_code != NO_ERROR_DETECTED) |
| 46 return error_code; |
| 47 |
| 48 return CheckUrlWebApkCompatible(manifest.scope); |
| 49 } |
| OLD | NEW |