| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.content.pm.ApplicationInfo; | 8 import android.content.pm.ApplicationInfo; |
| 9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 */ | 48 */ |
| 49 public static WebApkInfo create(Intent intent) { | 49 public static WebApkInfo create(Intent intent) { |
| 50 String webApkPackageName = | 50 String webApkPackageName = |
| 51 IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBA
PK_PACKAGE_NAME); | 51 IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBA
PK_PACKAGE_NAME); |
| 52 if (TextUtils.isEmpty(webApkPackageName)) { | 52 if (TextUtils.isEmpty(webApkPackageName)) { |
| 53 return null; | 53 return null; |
| 54 } | 54 } |
| 55 | 55 |
| 56 String url = urlFromIntent(intent); | 56 String url = urlFromIntent(intent); |
| 57 int source = sourceFromIntent(intent); | 57 int source = sourceFromIntent(intent); |
| 58 return create(webApkPackageName, url, source); |
| 59 } |
| 58 | 60 |
| 61 /** |
| 62 * Constructs a WebApkInfo from the passed in parameters and <meta-data> in
the WebAPK's Android |
| 63 * manifest. |
| 64 * |
| 65 * @param webApkPackageName The package name of the WebAPK. |
| 66 * @param url Url that the WebAPK should navigate to when launched. |
| 67 * @param source Source that the WebAPK was launched from. |
| 68 */ |
| 69 public static WebApkInfo create(String webApkPackageName, String url, int so
urce) { |
| 59 // Unlike non-WebAPK web apps, WebAPK ids are predictable. A malicious a
ctor may send an | 70 // Unlike non-WebAPK web apps, WebAPK ids are predictable. A malicious a
ctor may send an |
| 60 // intent with a valid start URL and arbitrary other data. Only use the
start URL, the | 71 // intent with a valid start URL and arbitrary other data. Only use the
start URL, the |
| 61 // package name and the ShortcutSource from the launch intent and extrac
t the remaining data | 72 // package name and the ShortcutSource from the launch intent and extrac
t the remaining data |
| 62 // from the <meta-data> in the WebAPK's Android manifest. | 73 // from the <meta-data> in the WebAPK's Android manifest. |
| 63 | 74 |
| 64 Bundle bundle = extractWebApkMetaData(webApkPackageName); | 75 Bundle bundle = extractWebApkMetaData(webApkPackageName); |
| 65 if (bundle == null) { | 76 if (bundle == null) { |
| 66 return null; | 77 return null; |
| 67 } | 78 } |
| 68 | 79 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return ScreenOrientationValues.PORTRAIT; | 350 return ScreenOrientationValues.PORTRAIT; |
| 340 } else if (orientation.equals("portrait-primary")) { | 351 } else if (orientation.equals("portrait-primary")) { |
| 341 return ScreenOrientationValues.PORTRAIT_PRIMARY; | 352 return ScreenOrientationValues.PORTRAIT_PRIMARY; |
| 342 } else if (orientation.equals("portrait-secondary")) { | 353 } else if (orientation.equals("portrait-secondary")) { |
| 343 return ScreenOrientationValues.PORTRAIT_SECONDARY; | 354 return ScreenOrientationValues.PORTRAIT_SECONDARY; |
| 344 } else { | 355 } else { |
| 345 return ScreenOrientationValues.DEFAULT; | 356 return ScreenOrientationValues.DEFAULT; |
| 346 } | 357 } |
| 347 } | 358 } |
| 348 } | 359 } |
| OLD | NEW |