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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 * Constructs a WebApkInfo from the passed in Intent and <meta-data> in the WebAPK's Android | 45 * Constructs a WebApkInfo from the passed in Intent and <meta-data> in the WebAPK's Android |
46 * manifest. | 46 * manifest. |
47 * @param intent Intent containing info about the app. | 47 * @param intent Intent containing info about the app. |
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 | |
56 String url = urlFromIntent(intent); | 55 String url = urlFromIntent(intent); |
57 int source = sourceFromIntent(intent); | 56 int source = sourceFromIntent(intent); |
57 return create(webApkPackageName, url, source); | |
58 } | |
58 | 59 |
60 /** | |
61 * Constructs a WebApkInfo from the passed as parameter and <meta-data> in t he WebAPK's Android | |
62 * manifest. | |
pkotwicz
2017/01/18 02:08:20
Nit: "passed as parameter ..." -> "passed in param
pkotwicz
2017/01/20 16:57:16
^^^ I think you missed this comment
gonzalon
2017/01/20 19:27:01
Done.
| |
63 * | |
64 * @param webApkPackageName The package name of the WebAPK. | |
65 * @param url Url that the WebAPK should navigate to when launched. | |
66 * @param source Source that the WebAPK was launched from. | |
67 */ | |
68 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 | 69 // 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 | 70 // 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 | 71 // 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. | 72 // from the <meta-data> in the WebAPK's Android manifest. |
63 | 73 |
64 Bundle bundle = extractWebApkMetaData(webApkPackageName); | 74 Bundle bundle = extractWebApkMetaData(webApkPackageName); |
65 if (bundle == null) { | 75 if (bundle == null) { |
66 return null; | 76 return null; |
67 } | 77 } |
68 | 78 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 return ScreenOrientationValues.PORTRAIT; | 349 return ScreenOrientationValues.PORTRAIT; |
340 } else if (orientation.equals("portrait-primary")) { | 350 } else if (orientation.equals("portrait-primary")) { |
341 return ScreenOrientationValues.PORTRAIT_PRIMARY; | 351 return ScreenOrientationValues.PORTRAIT_PRIMARY; |
342 } else if (orientation.equals("portrait-secondary")) { | 352 } else if (orientation.equals("portrait-secondary")) { |
343 return ScreenOrientationValues.PORTRAIT_SECONDARY; | 353 return ScreenOrientationValues.PORTRAIT_SECONDARY; |
344 } else { | 354 } else { |
345 return ScreenOrientationValues.DEFAULT; | 355 return ScreenOrientationValues.DEFAULT; |
346 } | 356 } |
347 } | 357 } |
348 } | 358 } |
OLD | NEW |