| 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.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.Notification; | 9 import android.app.Notification; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 if (!canBeHijackedByHerb(getIntent())) return false; | 326 if (!canBeHijackedByHerb(getIntent())) return false; |
| 327 | 327 |
| 328 // Different Herb flavors handle incoming intents differently. | 328 // Different Herb flavors handle incoming intents differently. |
| 329 String flavor = FeatureUtilities.getHerbFlavor(); | 329 String flavor = FeatureUtilities.getHerbFlavor(); |
| 330 if (TextUtils.isEmpty(flavor) | 330 if (TextUtils.isEmpty(flavor) |
| 331 || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)
) { | 331 || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)
) { |
| 332 return false; | 332 return false; |
| 333 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERR
Y)) { | 333 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERR
Y)) { |
| 334 return IntentUtils.safeGetBooleanExtra(getIntent(), | 334 return IntentUtils.safeGetBooleanExtra(getIntent(), |
| 335 ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT,
true); | 335 ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT,
true); |
| 336 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ANISE) | |
| 337 || TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_BASIL) | |
| 338 || TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_DILL)) { | |
| 339 // Only Intents without NEW_TASK and NEW_DOCUMENT will trigger a Cus
tom Tab. | |
| 340 boolean isSameTask = (getIntent().getFlags() & Intent.FLAG_ACTIVITY_
NEW_TASK) == 0; | |
| 341 boolean isSameDocument = | |
| 342 (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
== 0; | |
| 343 Log.d(TAG, "Herb Intent proprties -- SAME TASK: " | |
| 344 + isSameTask + ", SAME DOCUMENT: " + isSameDocument); | |
| 345 return isSameTask && isSameDocument; | |
| 346 } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_CHIVE)) { | |
| 347 // Send all View Intents to the main browser. | |
| 348 return false; | |
| 349 } else { | 336 } else { |
| 350 assert false; | 337 // Legacy Herb Flavors might hit this path before the caching logic
corrects it, so |
| 338 // treat this as disabled. |
| 351 return false; | 339 return false; |
| 352 } | 340 } |
| 353 } | 341 } |
| 354 | 342 |
| 355 /** | 343 /** |
| 356 * Adds extras to the Intent that are needed by Herb. | 344 * Adds extras to the Intent that are needed by Herb. |
| 357 */ | 345 */ |
| 358 public static void updateHerbIntent(Context context, Intent newIntent, Uri u
ri) { | 346 public static void updateHerbIntent(Context context, Intent newIntent, Uri u
ri) { |
| 359 // For Elderberry flavored Herbs that are to be launched in a separate t
ask, add a random | 347 // For Elderberry flavored Herbs that are to be launched in a separate t
ask, add a random |
| 360 // UUID to try and prevent Android from refocusing/clobbering items that
share the same | 348 // UUID to try and prevent Android from refocusing/clobbering items that
share the same |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 IntentHandler.ExternalAppId source = | 571 IntentHandler.ExternalAppId source = |
| 584 IntentHandler.determineExternalIntentSource(getPackageName(), in
tent); | 572 IntentHandler.determineExternalIntentSource(getPackageName(), in
tent); |
| 585 if (intent.getPackage() == null && source != IntentHandler.ExternalAppId
.CHROME) { | 573 if (intent.getPackage() == null && source != IntentHandler.ExternalAppId
.CHROME) { |
| 586 int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_AC
TIVITY_NEW_DOCUMENT; | 574 int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_AC
TIVITY_NEW_DOCUMENT; |
| 587 int maskedFlags = intent.getFlags() & flagsOfInterest; | 575 int maskedFlags = intent.getFlags() & flagsOfInterest; |
| 588 sIntentFlagsHistogram.record(maskedFlags); | 576 sIntentFlagsHistogram.record(maskedFlags); |
| 589 } | 577 } |
| 590 MediaNotificationUma.recordClickSource(intent); | 578 MediaNotificationUma.recordClickSource(intent); |
| 591 } | 579 } |
| 592 } | 580 } |
| OLD | NEW |