| 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; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.app.Activity; |
| 7 import android.app.KeyguardManager; | 8 import android.app.KeyguardManager; |
| 8 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
| 9 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| 10 import android.content.ComponentName; | 11 import android.content.ComponentName; |
| 11 import android.content.Context; | 12 import android.content.Context; |
| 12 import android.content.Intent; | 13 import android.content.Intent; |
| 13 import android.net.Uri; | 14 import android.net.Uri; |
| 14 import android.os.Bundle; | 15 import android.os.Bundle; |
| 15 import android.os.SystemClock; | 16 import android.os.SystemClock; |
| 16 import android.provider.Browser; | 17 import android.provider.Browser; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 private static int sReferrerId; | 177 private static int sReferrerId; |
| 177 private static String sPendingIncognitoUrl; | 178 private static String sPendingIncognitoUrl; |
| 178 | 179 |
| 179 private static final String PACKAGE_GSA = "com.google.android.googlequicksea
rchbox"; | 180 private static final String PACKAGE_GSA = "com.google.android.googlequicksea
rchbox"; |
| 180 private static final String PACKAGE_GMAIL = "com.google.android.gm"; | 181 private static final String PACKAGE_GMAIL = "com.google.android.gm"; |
| 181 private static final String PACKAGE_PLUS = "com.google.android.apps.plus"; | 182 private static final String PACKAGE_PLUS = "com.google.android.apps.plus"; |
| 182 private static final String PACKAGE_HANGOUTS = "com.google.android.talk"; | 183 private static final String PACKAGE_HANGOUTS = "com.google.android.talk"; |
| 183 private static final String PACKAGE_MESSENGER = "com.google.android.apps.mes
saging"; | 184 private static final String PACKAGE_MESSENGER = "com.google.android.apps.mes
saging"; |
| 184 private static final String PACKAGE_LINE = "jp.naver.line.android"; | 185 private static final String PACKAGE_LINE = "jp.naver.line.android"; |
| 185 private static final String PACKAGE_WHATSAPP = "com.whatsapp"; | 186 private static final String PACKAGE_WHATSAPP = "com.whatsapp"; |
| 186 private static final String FACEBOOK_LINK_PREFIX = "http://m.facebook.com/l.
php?"; | 187 private static final String FACEBOOK_REFERRER_URL = "android-app://m.faceboo
k.com"; |
| 188 private static final String FACEBOOK_INTERNAL_BROWSER_REFERRER = "http://m.f
acebook.com"; |
| 187 private static final String TWITTER_LINK_PREFIX = "http://t.co/"; | 189 private static final String TWITTER_LINK_PREFIX = "http://t.co/"; |
| 188 private static final String NEWS_LINK_PREFIX = "http://news.google.com/news/
url?"; | 190 private static final String NEWS_LINK_PREFIX = "http://news.google.com/news/
url?"; |
| 189 | 191 |
| 190 /** | 192 /** |
| 191 * Represents popular external applications that can load a page in Chrome v
ia intent. | 193 * Represents popular external applications that can load a page in Chrome v
ia intent. |
| 192 */ | 194 */ |
| 193 public static enum ExternalAppId { | 195 public static enum ExternalAppId { |
| 194 OTHER, | 196 OTHER, |
| 195 GMAIL, | 197 GMAIL, |
| 196 FACEBOOK, | 198 FACEBOOK, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 * Determines what App was used to fire this Intent. | 287 * Determines what App was used to fire this Intent. |
| 286 * @param packageName Package name of this application. | 288 * @param packageName Package name of this application. |
| 287 * @param intent Intent that was used to launch Chrome. | 289 * @param intent Intent that was used to launch Chrome. |
| 288 * @return ExternalAppId representing the app. | 290 * @return ExternalAppId representing the app. |
| 289 */ | 291 */ |
| 290 public static ExternalAppId determineExternalIntentSource(String packageName
, Intent intent) { | 292 public static ExternalAppId determineExternalIntentSource(String packageName
, Intent intent) { |
| 291 String appId = IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPL
ICATION_ID); | 293 String appId = IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPL
ICATION_ID); |
| 292 ExternalAppId externalId = ExternalAppId.OTHER; | 294 ExternalAppId externalId = ExternalAppId.OTHER; |
| 293 if (appId == null) { | 295 if (appId == null) { |
| 294 String url = getUrlFromIntent(intent); | 296 String url = getUrlFromIntent(intent); |
| 297 String referrer = getReferrerUrl(intent); |
| 295 if (url != null && url.startsWith(TWITTER_LINK_PREFIX)) { | 298 if (url != null && url.startsWith(TWITTER_LINK_PREFIX)) { |
| 296 externalId = ExternalAppId.TWITTER; | 299 externalId = ExternalAppId.TWITTER; |
| 297 } else if (url != null && url.startsWith(FACEBOOK_LINK_PREFIX)) { | 300 } else if (FACEBOOK_REFERRER_URL.equals(referrer)) { |
| 301 // This happens when "Links Open Externally" is checked in the F
acebook app. |
| 298 externalId = ExternalAppId.FACEBOOK; | 302 externalId = ExternalAppId.FACEBOOK; |
| 299 } else if (url != null && url.startsWith(NEWS_LINK_PREFIX)) { | 303 } else if (url != null && url.startsWith(NEWS_LINK_PREFIX)) { |
| 300 externalId = ExternalAppId.NEWS; | 304 externalId = ExternalAppId.NEWS; |
| 305 } else { |
| 306 Bundle headers = IntentUtils.safeGetBundleExtra(intent, Browser.
EXTRA_HEADERS); |
| 307 if (headers != null |
| 308 && FACEBOOK_INTERNAL_BROWSER_REFERRER.equals(headers.get
("Referer"))) { |
| 309 // This happens when "Links Open Externally" is unchecked in
the Facebook app, |
| 310 // and we use "Open With..." from the internal browser. |
| 311 externalId = ExternalAppId.FACEBOOK; |
| 312 } |
| 301 } | 313 } |
| 302 } else { | 314 } else { |
| 303 if (appId.equals(PACKAGE_PLUS)) { | 315 if (appId.equals(PACKAGE_PLUS)) { |
| 304 externalId = ExternalAppId.PLUS; | 316 externalId = ExternalAppId.PLUS; |
| 305 } else if (appId.equals(PACKAGE_GMAIL)) { | 317 } else if (appId.equals(PACKAGE_GMAIL)) { |
| 306 externalId = ExternalAppId.GMAIL; | 318 externalId = ExternalAppId.GMAIL; |
| 307 } else if (appId.equals(PACKAGE_HANGOUTS)) { | 319 } else if (appId.equals(PACKAGE_HANGOUTS)) { |
| 308 externalId = ExternalAppId.HANGOUTS; | 320 externalId = ExternalAppId.HANGOUTS; |
| 309 } else if (appId.equals(PACKAGE_MESSENGER)) { | 321 } else if (appId.equals(PACKAGE_MESSENGER)) { |
| 310 externalId = ExternalAppId.MESSENGER; | 322 externalId = ExternalAppId.MESSENGER; |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 } | 1062 } |
| 1051 | 1063 |
| 1052 /** | 1064 /** |
| 1053 * @param intent An Intent to be checked. | 1065 * @param intent An Intent to be checked. |
| 1054 * @return The launch type of the tab to be created. | 1066 * @return The launch type of the tab to be created. |
| 1055 */ | 1067 */ |
| 1056 public static TabLaunchType getTabLaunchType(Intent intent) { | 1068 public static TabLaunchType getTabLaunchType(Intent intent) { |
| 1057 return IntentUtils.safeGetSerializableExtra(intent, EXTRA_TAB_LAUNCH_TYP
E); | 1069 return IntentUtils.safeGetSerializableExtra(intent, EXTRA_TAB_LAUNCH_TYP
E); |
| 1058 } | 1070 } |
| 1059 } | 1071 } |
| OLD | NEW |