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 30 matching lines...) Expand all Loading... |
41 return new WebApkInfo(); | 41 return new WebApkInfo(); |
42 } | 42 } |
43 | 43 |
44 /** | 44 /** |
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, WebApkConstants.EXTRA_WEB
APK_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); | 58 return create(webApkPackageName, url, source); |
59 } | 59 } |
60 | 60 |
61 /** | 61 /** |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 public Map<String, String> iconUrlToMurmur2HashMap() { | 187 public Map<String, String> iconUrlToMurmur2HashMap() { |
188 return mIconUrlToMurmur2HashMap; | 188 return mIconUrlToMurmur2HashMap; |
189 } | 189 } |
190 | 190 |
191 @Override | 191 @Override |
192 public void setWebappIntentExtras(Intent intent) { | 192 public void setWebappIntentExtras(Intent intent) { |
193 // For launching a {@link WebApkActivity}. | 193 // For launching a {@link WebApkActivity}. |
194 intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); | 194 intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); |
195 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); | 195 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); |
196 intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageN
ame()); | 196 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackage
Name()); |
197 } | 197 } |
198 | 198 |
199 /** | 199 /** |
200 * Extracts meta data from a WebAPK's Android Manifest. | 200 * Extracts meta data from a WebAPK's Android Manifest. |
201 * @param webApkPackageName WebAPK's package name. | 201 * @param webApkPackageName WebAPK's package name. |
202 * @return Bundle with the extracted meta data. | 202 * @return Bundle with the extracted meta data. |
203 */ | 203 */ |
204 private static Bundle extractWebApkMetaData(String webApkPackageName) { | 204 private static Bundle extractWebApkMetaData(String webApkPackageName) { |
205 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); | 205 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); |
206 try { | 206 try { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 return ScreenOrientationValues.PORTRAIT; | 350 return ScreenOrientationValues.PORTRAIT; |
351 } else if (orientation.equals("portrait-primary")) { | 351 } else if (orientation.equals("portrait-primary")) { |
352 return ScreenOrientationValues.PORTRAIT_PRIMARY; | 352 return ScreenOrientationValues.PORTRAIT_PRIMARY; |
353 } else if (orientation.equals("portrait-secondary")) { | 353 } else if (orientation.equals("portrait-secondary")) { |
354 return ScreenOrientationValues.PORTRAIT_SECONDARY; | 354 return ScreenOrientationValues.PORTRAIT_SECONDARY; |
355 } else { | 355 } else { |
356 return ScreenOrientationValues.DEFAULT; | 356 return ScreenOrientationValues.DEFAULT; |
357 } | 357 } |
358 } | 358 } |
359 } | 359 } |
OLD | NEW |