Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java

Issue 2893823004: [Payments] Implement openWindow for service worker based payment handler (Closed)
Patch Set: use CompleteURL Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
104 * Note that this is used by PaymentRequestEvent.openWindow().
105 *
106 * @param requestId The tab launch request ID from the {@link ServiceTabLa uncher}.
107 * @param url The url to open in the new tab.
108 */
109 public boolean createPopupCustomTab(int requestId, String url) {
Yusuf 2017/06/02 20:12:54 I still kind of get stuck to the fact that, this i
gogerald1 2017/06/02 21:46:03 Done.
110 // Do not open the popup custom tab if the chrome activity is not in the forground.
111 Activity lastTrackedActivity = ApplicationStatus.getLastTrackedFocusedAc tivity();
112 if (!(lastTrackedActivity instanceof ChromeActivity)) return false;
113
114 CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
115 builder.setShowTitle(true);
116 builder.setStartAnimations(lastTrackedActivity, R.anim.slide_in_up, 0);
117 builder.setExitAnimations(lastTrackedActivity, 0, R.anim.slide_out_down) ;
118 CustomTabsIntent customTabsIntent = builder.build();
119 customTabsIntent.intent.setPackage(ContextUtils.getApplicationContext(). getPackageName());
120 customTabsIntent.intent.putExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EX TRA, requestId);
121 customTabsIntent.intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_ TAB, mIsIncognito);
122 customTabsIntent.intent.putExtra(Browser.EXTRA_APPLICATION_ID,
123 ContextUtils.getApplicationContext().getPackageName());
124
125 customTabsIntent.launchUrl(lastTrackedActivity, Uri.parse(url));
126
127 return true;
128 }
129
97 @Override 130 @Override
98 public Tab launchUrl(String url, TabLaunchType type) { 131 public Tab launchUrl(String url, TabLaunchType type) {
99 return createNewTab(new LoadUrlParams(url), type, null); 132 return createNewTab(new LoadUrlParams(url), type, null);
100 } 133 }
101 134
102 @Override 135 @Override
103 public Tab createNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent) { 136 public Tab createNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent) {
104 AsyncTabCreationParams asyncParams = new AsyncTabCreationParams(loadUrlP arams); 137 AsyncTabCreationParams asyncParams = new AsyncTabCreationParams(loadUrlP arams);
105 createNewTab(asyncParams, type, parent == null ? Tab.INVALID_TAB_ID : pa rent.getId()); 138 createNewTab(asyncParams, type, parent == null ? Tab.INVALID_TAB_ID : pa rent.getId());
106 return null; 139 return null;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 * Passes the supplied web app launch intent to the IntentHandler. 211 * Passes the supplied web app launch intent to the IntentHandler.
179 * @param intent Web app launch intent. 212 * @param intent Web app launch intent.
180 */ 213 */
181 public void createNewStandaloneFrame(Intent intent) { 214 public void createNewStandaloneFrame(Intent intent) {
182 assert intent != null; 215 assert intent != null;
183 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 216 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
184 | ApiCompatibilityUtils.getActivityNewDocumentFlag()); 217 | ApiCompatibilityUtils.getActivityNewDocumentFlag());
185 IntentHandler.startActivityForTrustedIntent(intent); 218 IntentHandler.startActivityForTrustedIntent(intent);
186 } 219 }
187 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698