| 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.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.PendingIntent; | 8 import android.app.PendingIntent; |
| 9 import android.app.PendingIntent.CanceledException; | 9 import android.app.PendingIntent.CanceledException; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 /** | 338 /** |
| 339 * Triggers the client-defined action when the user clicks a custom menu ite
m. | 339 * Triggers the client-defined action when the user clicks a custom menu ite
m. |
| 340 * @param menuIndex The index that the menu item is shown in the result of | 340 * @param menuIndex The index that the menu item is shown in the result of |
| 341 * {@link #getMenuTitles()} | 341 * {@link #getMenuTitles()} |
| 342 */ | 342 */ |
| 343 public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, Str
ing url) { | 343 public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, Str
ing url) { |
| 344 Intent addedIntent = new Intent(); | 344 Intent addedIntent = new Intent(); |
| 345 addedIntent.setData(Uri.parse(url)); | 345 addedIntent.setData(Uri.parse(url)); |
| 346 try { | 346 try { |
| 347 // Media viewers pass in PendingIntents that contain CHOOSER Intents
. Setting the data |
| 348 // in these cases prevents the Intent from firing correctly. |
| 347 PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; | 349 PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; |
| 348 pendingIntent.send(activity, 0, addedIntent, mOnFinished, null); | 350 pendingIntent.send( |
| 351 activity, 0, isMediaViewer() ? null : addedIntent, mOnFinish
ed, null); |
| 349 } catch (CanceledException e) { | 352 } catch (CanceledException e) { |
| 350 Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); | 353 Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); |
| 351 } | 354 } |
| 352 } | 355 } |
| 353 | 356 |
| 354 /** | 357 /** |
| 355 * @return Whether chrome should animate when it finishes. We show animation
s only if the client | 358 * @return Whether chrome should animate when it finishes. We show animation
s only if the client |
| 356 * app has supplied the correct animation resources via intent extra
. | 359 * app has supplied the correct animation resources via intent extra
. |
| 357 */ | 360 */ |
| 358 public boolean shouldAnimateOnFinish() { | 361 public boolean shouldAnimateOnFinish() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 if (TextUtils.isEmpty(herbFlavor) | 445 if (TextUtils.isEmpty(herbFlavor) |
| 443 || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, herbFla
vor)) { | 446 || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, herbFla
vor)) { |
| 444 return; | 447 return; |
| 445 } | 448 } |
| 446 if (!IntentHandler.isIntentChromeOrFirstParty(intent, context)) return; | 449 if (!IntentHandler.isIntentChromeOrFirstParty(intent, context)) return; |
| 447 | 450 |
| 448 mIsOpenedByChrome = IntentUtils.safeGetBooleanExtra( | 451 mIsOpenedByChrome = IntentUtils.safeGetBooleanExtra( |
| 449 intent, EXTRA_IS_OPENED_BY_CHROME, false); | 452 intent, EXTRA_IS_OPENED_BY_CHROME, false); |
| 450 } | 453 } |
| 451 } | 454 } |
| OLD | NEW |