Chromium Code Reviews| 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 boolean isTrusted = IntentHandler.wasIntentSenderChrome(intent, |
| 63 ApplicationStatus.getApplicationContext()); | |
|
gone
2016/04/07 19:10:44
Indentation is wonky here (indent by 8 then 4). W
dominickn
2016/04/08 01:10:45
I just used another variable. Seems a bit nicer th
| |
| 64 if (isTrusted | |
| 65 || (webappMac != null | |
| 66 && WebappAuthenticator.isUrlValid(this, webappUrl, webap pMac))) { | |
| 62 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap pUrl, webappSource); | 67 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap pUrl, webappSource); |
| 63 | 68 |
| 64 String activityName = WebappActivity.class.getName(); | 69 String activityName = WebappActivity.class.getName(); |
| 65 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | 70 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |
| 66 // Specifically assign the app to a particular WebappActivit y instance. | 71 // Specifically assign the app to a particular WebappActivit y instance. |
| 67 int activityIndex = ActivityAssigner.instance(this).assign(w ebappId); | 72 int activityIndex = ActivityAssigner.instance(this).assign(w ebappId); |
| 68 activityName += String.valueOf(activityIndex); | 73 activityName += String.valueOf(activityIndex); |
| 69 } | 74 } |
| 70 | 75 |
| 71 // Create an intent to launch the Webapp in an unmapped WebappAc tivity. | 76 // 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) { | 118 && webappActivity.getActivityTab().getId() == tabId) { |
| 114 Tab tab = webappActivity.getActivityTab(); | 119 Tab tab = webappActivity.getActivityTab(); |
| 115 tab.getTabWebContentsDelegateAndroid().activateContents(); | 120 tab.getTabWebContentsDelegateAndroid().activateContents(); |
| 116 return true; | 121 return true; |
| 117 } | 122 } |
| 118 } | 123 } |
| 119 | 124 |
| 120 return false; | 125 return false; |
| 121 } | 126 } |
| 122 } | 127 } |
| OLD | NEW |