| 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.document; | 5 package org.chromium.chrome.browser.document; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.ActivityManager; | 10 import android.app.ActivityManager; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import android.provider.Browser; | 25 import android.provider.Browser; |
| 26 import android.support.customtabs.CustomTabsIntent; | 26 import android.support.customtabs.CustomTabsIntent; |
| 27 import android.text.TextUtils; | 27 import android.text.TextUtils; |
| 28 | 28 |
| 29 import org.chromium.base.ApiCompatibilityUtils; | 29 import org.chromium.base.ApiCompatibilityUtils; |
| 30 import org.chromium.base.ApplicationStatus; | 30 import org.chromium.base.ApplicationStatus; |
| 31 import org.chromium.base.CommandLineInitUtil; | 31 import org.chromium.base.CommandLineInitUtil; |
| 32 import org.chromium.base.Log; | 32 import org.chromium.base.Log; |
| 33 import org.chromium.base.TraceEvent; | 33 import org.chromium.base.TraceEvent; |
| 34 import org.chromium.chrome.browser.ChromeApplication; | 34 import org.chromium.chrome.browser.ChromeApplication; |
| 35 import org.chromium.chrome.browser.ChromeSwitches; |
| 35 import org.chromium.chrome.browser.ChromeTabbedActivity; | 36 import org.chromium.chrome.browser.ChromeTabbedActivity; |
| 36 import org.chromium.chrome.browser.IntentHandler; | 37 import org.chromium.chrome.browser.IntentHandler; |
| 37 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 38 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
| 38 import org.chromium.chrome.browser.ShortcutHelper; | 39 import org.chromium.chrome.browser.ShortcutHelper; |
| 39 import org.chromium.chrome.browser.ShortcutSource; | 40 import org.chromium.chrome.browser.ShortcutSource; |
| 40 import org.chromium.chrome.browser.UrlConstants; | 41 import org.chromium.chrome.browser.UrlConstants; |
| 41 import org.chromium.chrome.browser.WarmupManager; | 42 import org.chromium.chrome.browser.WarmupManager; |
| 42 import org.chromium.chrome.browser.customtabs.CustomTabActivity; | 43 import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
| 43 import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler; | 44 import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler; |
| 44 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; | 45 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 public void processUrlViewIntent(String url, String referer, String headers, | 273 public void processUrlViewIntent(String url, String referer, String headers, |
| 273 IntentHandler.TabOpenType tabOpenType, String externalAppId, | 274 IntentHandler.TabOpenType tabOpenType, String externalAppId, |
| 274 int tabIdToBringToFront, boolean hasUserGesture, Intent intent) { | 275 int tabIdToBringToFront, boolean hasUserGesture, Intent intent) { |
| 275 assert false; | 276 assert false; |
| 276 } | 277 } |
| 277 | 278 |
| 278 /** | 279 /** |
| 279 * @return Whether the intent sent is for launching a Custom Tab. | 280 * @return Whether the intent sent is for launching a Custom Tab. |
| 280 */ | 281 */ |
| 281 private boolean isCustomTabIntent() { | 282 private boolean isCustomTabIntent() { |
| 282 if (getIntent() == null || !getIntent().hasExtra(CustomTabsIntent.EXTRA_
SESSION)) { | 283 // HERB: Determine whether or not a CCT will be used for the incoming In
tent. |
| 284 String flavor = ChromePreferenceManager.getInstance(this).getHerbFlavor(
); |
| 285 boolean isHerbyIntent = !TextUtils.isEmpty(flavor); |
| 286 if (isHerbyIntent) { |
| 287 Log.d(TAG, "Herb flavor: " + flavor); |
| 288 isHerbyIntent &= TextUtils.equals(getIntent().getAction(), Intent.AC
TION_VIEW); |
| 289 |
| 290 if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ANISE) |
| 291 || TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_BASIL
)) { |
| 292 // Only View Intents without NEW_TASK and NEW_DOCUMENT will trig
ger a CCT. |
| 293 boolean isSameTask = (getIntent().getFlags() & Intent.FLAG_ACTIV
ITY_NEW_TASK) == 0; |
| 294 boolean isSameDocument = |
| 295 (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUM
ENT) == 0; |
| 296 isHerbyIntent &= isSameTask && isSameDocument; |
| 297 Log.d(TAG, "Herb Intent proprties -- SAME TASK: " |
| 298 + isSameTask + ", SAME DOCUMENT: " + isSameDocument); |
| 299 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_CHIVE
)) { |
| 300 // Chive sends all View Intents to the main browser. |
| 301 isHerbyIntent = false; |
| 302 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_DILL)
) { |
| 303 // Dill always opens View Intents in CCTs -- even home screen sh
ortcuts. |
| 304 } |
| 305 } |
| 306 |
| 307 if (getIntent() == null || (!getIntent().hasExtra(CustomTabsIntent.EXTRA
_SESSION) |
| 308 && !isHerbyIntent)) { |
| 283 return false; | 309 return false; |
| 284 } | 310 } |
| 285 | 311 |
| 286 String url = IntentHandler.getUrlFromIntent(getIntent()); | 312 String url = IntentHandler.getUrlFromIntent(getIntent()); |
| 287 if (url == null) return false; | 313 if (url == null) return false; |
| 288 | 314 |
| 289 if (!ChromePreferenceManager.getInstance(this).getCustomTabsEnabled()) r
eturn false; | 315 if (!ChromePreferenceManager.getInstance(this).getCustomTabsEnabled()) r
eturn false; |
| 290 return true; | 316 return true; |
| 291 } | 317 } |
| 292 | 318 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 return true; | 850 return true; |
| 825 } | 851 } |
| 826 | 852 |
| 827 /** | 853 /** |
| 828 * Send the number of times an exception was caught when trying to move a ta
sk back to front. | 854 * Send the number of times an exception was caught when trying to move a ta
sk back to front. |
| 829 */ | 855 */ |
| 830 public static void sendExceptionCount() { | 856 public static void sendExceptionCount() { |
| 831 sMoveToFrontExceptionHistogram.commitHistogram(); | 857 sMoveToFrontExceptionHistogram.commitHistogram(); |
| 832 } | 858 } |
| 833 } | 859 } |
| OLD | NEW |