Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.tabmodel.document; | 5 package org.chromium.chrome.browser.tabmodel.document; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.net.Uri; | 10 import android.net.Uri; |
| 11 import android.os.Bundle; | 11 import android.os.Bundle; |
| 12 import android.provider.Browser; | 12 import android.provider.Browser; |
| 13 import android.support.customtabs.CustomTabsIntent; | |
| 13 | 14 |
| 14 import org.chromium.base.ApiCompatibilityUtils; | 15 import org.chromium.base.ApiCompatibilityUtils; |
| 16 import org.chromium.base.ApplicationStatus; | |
| 15 import org.chromium.base.ContextUtils; | 17 import org.chromium.base.ContextUtils; |
| 18 import org.chromium.chrome.R; | |
| 19 import org.chromium.chrome.browser.ChromeActivity; | |
| 16 import org.chromium.chrome.browser.IntentHandler; | 20 import org.chromium.chrome.browser.IntentHandler; |
| 17 import org.chromium.chrome.browser.ServiceTabLauncher; | 21 import org.chromium.chrome.browser.ServiceTabLauncher; |
| 18 import org.chromium.chrome.browser.TabState; | 22 import org.chromium.chrome.browser.TabState; |
| 19 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 23 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 20 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 24 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| 21 import org.chromium.chrome.browser.tab.Tab; | 25 import org.chromium.chrome.browser.tab.Tab; |
| 22 import org.chromium.chrome.browser.tab.TabIdManager; | 26 import org.chromium.chrome.browser.tab.TabIdManager; |
| 23 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; | 27 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; |
| 24 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator; | 28 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator; |
| 25 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 29 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 Class<? extends Activity> targetActivity = | 91 Class<? extends Activity> targetActivity = |
| 88 MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(acti vity); | 92 MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(acti vity); |
| 89 if (targetActivity == null) return; | 93 if (targetActivity == null) return; |
| 90 | 94 |
| 91 MultiWindowUtils.setOpenInOtherWindowIntentExtras(intent, activity, targ etActivity); | 95 MultiWindowUtils.setOpenInOtherWindowIntentExtras(intent, activity, targ etActivity); |
| 92 IntentHandler.addTrustedIntentExtras(intent); | 96 IntentHandler.addTrustedIntentExtras(intent); |
| 93 MultiWindowUtils.onMultiInstanceModeStarted(); | 97 MultiWindowUtils.onMultiInstanceModeStarted(); |
| 94 activity.startActivity(intent); | 98 activity.startActivity(intent); |
| 95 } | 99 } |
| 96 | 100 |
| 101 /** | |
| 102 * Creates a popup custom tab to open the url. The popup tab is animated in from bottom to top | |
| 103 * and out from top to bottom. | |
|
please use gerrit instead
2017/06/02 03:43:16
Add a comment that this is used by PaymentRequestE
gogerald1
2017/06/02 13:21:39
Done.
| |
| 104 * | |
| 105 * @param requestId The tab launch request ID from the {@link ServiceTabLa uncher}. | |
| 106 * @param url The url to open in the new tab. | |
| 107 */ | |
| 108 public boolean createPopupCustomTab(int requestId, String url) { | |
| 109 // Do not open the popup custom tab if the chrome activity is not in the forground. | |
| 110 Activity lastTrackedActivity = ApplicationStatus.getLastTrackedFocusedAc tivity(); | |
| 111 if (!(lastTrackedActivity instanceof ChromeActivity)) return false; | |
| 112 | |
| 113 CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); | |
| 114 builder.setShowTitle(true); | |
| 115 builder.setStartAnimations(lastTrackedActivity, R.anim.slide_in_up, 0); | |
| 116 builder.setExitAnimations(lastTrackedActivity, 0, R.anim.slide_out_down) ; | |
| 117 CustomTabsIntent customTabsIntent = builder.build(); | |
| 118 customTabsIntent.intent.setPackage(ContextUtils.getApplicationContext(). getPackageName()); | |
| 119 customTabsIntent.intent.putExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EX TRA, requestId); | |
| 120 customTabsIntent.intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_ TAB, mIsIncognito); | |
| 121 customTabsIntent.intent.putExtra(Browser.EXTRA_APPLICATION_ID, | |
| 122 ContextUtils.getApplicationContext().getPackageName()); | |
| 123 | |
| 124 customTabsIntent.launchUrl(lastTrackedActivity, Uri.parse(url)); | |
| 125 | |
| 126 return true; | |
| 127 } | |
| 128 | |
| 97 @Override | 129 @Override |
| 98 public Tab launchUrl(String url, TabLaunchType type) { | 130 public Tab launchUrl(String url, TabLaunchType type) { |
| 99 return createNewTab(new LoadUrlParams(url), type, null); | 131 return createNewTab(new LoadUrlParams(url), type, null); |
| 100 } | 132 } |
| 101 | 133 |
| 102 @Override | 134 @Override |
| 103 public Tab createNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent) { | 135 public Tab createNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent) { |
| 104 AsyncTabCreationParams asyncParams = new AsyncTabCreationParams(loadUrlP arams); | 136 AsyncTabCreationParams asyncParams = new AsyncTabCreationParams(loadUrlP arams); |
| 105 createNewTab(asyncParams, type, parent == null ? Tab.INVALID_TAB_ID : pa rent.getId()); | 137 createNewTab(asyncParams, type, parent == null ? Tab.INVALID_TAB_ID : pa rent.getId()); |
| 106 return null; | 138 return null; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 * Passes the supplied web app launch intent to the IntentHandler. | 210 * Passes the supplied web app launch intent to the IntentHandler. |
| 179 * @param intent Web app launch intent. | 211 * @param intent Web app launch intent. |
| 180 */ | 212 */ |
| 181 public void createNewStandaloneFrame(Intent intent) { | 213 public void createNewStandaloneFrame(Intent intent) { |
| 182 assert intent != null; | 214 assert intent != null; |
| 183 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 215 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 184 | ApiCompatibilityUtils.getActivityNewDocumentFlag()); | 216 | ApiCompatibilityUtils.getActivityNewDocumentFlag()); |
| 185 IntentHandler.startActivityForTrustedIntent(intent); | 217 IntentHandler.startActivityForTrustedIntent(intent); |
| 186 } | 218 } |
| 187 } | 219 } |
| OLD | NEW |