OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.os.Build; | 10 import android.os.Build; |
11 import android.os.Bundle; | 11 import android.os.Bundle; |
12 import android.util.Base64; | 12 import android.util.Base64; |
13 | 13 |
14 import org.chromium.base.ApiCompatibilityUtils; | 14 import org.chromium.base.ApiCompatibilityUtils; |
15 import org.chromium.base.ApplicationStatus; | 15 import org.chromium.base.ApplicationStatus; |
16 import org.chromium.base.Log; | 16 import org.chromium.base.Log; |
| 17 import org.chromium.chrome.browser.IntentHandler; |
17 import org.chromium.chrome.browser.ShortcutHelper; | 18 import org.chromium.chrome.browser.ShortcutHelper; |
18 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 19 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
19 import org.chromium.chrome.browser.metrics.LaunchMetrics; | 20 import org.chromium.chrome.browser.metrics.LaunchMetrics; |
20 import org.chromium.chrome.browser.tab.Tab; | 21 import org.chromium.chrome.browser.tab.Tab; |
21 import org.chromium.chrome.browser.util.IntentUtils; | 22 import org.chromium.chrome.browser.util.IntentUtils; |
22 | 23 |
23 import java.lang.ref.WeakReference; | 24 import java.lang.ref.WeakReference; |
24 | 25 |
25 /** | 26 /** |
26 * Launches web apps. This was separated from the ChromeLauncherActivity becaus
e the | 27 * Launches web apps. This was separated from the ChromeLauncherActivity becaus
e the |
(...skipping 24 matching lines...) Expand all Loading... |
51 String webappUrl = webappInfo.uri().toString(); | 52 String webappUrl = webappInfo.uri().toString(); |
52 int webappSource = webappInfo.source(); | 53 int webappSource = webappInfo.source(); |
53 | 54 |
54 if (webappId != null && webappUrl != null) { | 55 if (webappId != null && webappUrl != null) { |
55 String webappMacString = IntentUtils.safeGetStringExtra( | 56 String webappMacString = IntentUtils.safeGetStringExtra( |
56 intent, ShortcutHelper.EXTRA_MAC); | 57 intent, ShortcutHelper.EXTRA_MAC); |
57 byte[] webappMac = | 58 byte[] webappMac = |
58 webappMacString == null ? null : Base64.decode(webappMacStri
ng, Base64.DEFAULT); | 59 webappMacString == null ? null : Base64.decode(webappMacStri
ng, Base64.DEFAULT); |
59 | 60 |
60 Intent launchIntent = null; | 61 Intent launchIntent = null; |
61 if (webappMac != null && WebappAuthenticator.isUrlValid(this, webapp
Url, webappMac)) { | 62 |
| 63 // Permit the launch to a standalone web app frame if the intent was
sent by Chrome, or |
| 64 // if the MAC is present and valid for the URL to be opened. |
| 65 boolean isTrusted = IntentHandler.wasIntentSenderChrome(intent, |
| 66 ApplicationStatus.getApplicationContext()); |
| 67 boolean isUrlValid = (webappMac != null |
| 68 && WebappAuthenticator.isUrlValid(this, webappUrl, webappMac
)); |
| 69 |
| 70 if (isTrusted || isUrlValid) { |
62 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap
pUrl, webappSource); | 71 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap
pUrl, webappSource); |
63 | 72 |
64 String activityName = WebappActivity.class.getName(); | 73 String activityName = WebappActivity.class.getName(); |
65 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | 74 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |
66 // Specifically assign the app to a particular WebappActivit
y instance. | 75 // Specifically assign the app to a particular WebappActivit
y instance. |
67 int activityIndex = ActivityAssigner.instance(this).assign(w
ebappId); | 76 int activityIndex = ActivityAssigner.instance(this).assign(w
ebappId); |
68 activityName += String.valueOf(activityIndex); | 77 activityName += String.valueOf(activityIndex); |
69 } | 78 } |
70 | 79 |
71 // Create an intent to launch the Webapp in an unmapped WebappAc
tivity. | 80 // Create an intent to launch the Webapp in an unmapped WebappAc
tivity. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 && webappActivity.getActivityTab().getId() == tabId) { | 122 && webappActivity.getActivityTab().getId() == tabId) { |
114 Tab tab = webappActivity.getActivityTab(); | 123 Tab tab = webappActivity.getActivityTab(); |
115 tab.getTabWebContentsDelegateAndroid().activateContents(); | 124 tab.getTabWebContentsDelegateAndroid().activateContents(); |
116 return true; | 125 return true; |
117 } | 126 } |
118 } | 127 } |
119 | 128 |
120 return false; | 129 return false; |
121 } | 130 } |
122 } | 131 } |
OLD | NEW |