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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java

Issue 2829943002: Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: Merge Created 3 years, 7 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 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.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.net.Uri; 9 import android.net.Uri;
10 import android.os.Build; 10 import android.os.Build;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 Intent launchIntent = new Intent(); 159 Intent launchIntent = new Intent();
160 launchIntent.setClassName(this, activityName); 160 launchIntent.setClassName(this, activityName);
161 info.setWebappIntentExtras(launchIntent); 161 info.setWebappIntentExtras(launchIntent);
162 162
163 // On L+, firing intents with the exact same data should relaunch a part icular 163 // On L+, firing intents with the exact same data should relaunch a part icular
164 // Activity. 164 // Activity.
165 launchIntent.setAction(Intent.ACTION_VIEW); 165 launchIntent.setAction(Intent.ACTION_VIEW);
166 launchIntent.setData(Uri.parse(WebappActivity.WEBAPP_SCHEME + "://" + in fo.id())); 166 launchIntent.setData(Uri.parse(WebappActivity.WEBAPP_SCHEME + "://" + in fo.id()));
167 launchIntent.setFlags( 167 launchIntent.setFlags(
168 Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivit yNewDocumentFlag()); 168 Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivit yNewDocumentFlag());
169 169 // Setting FLAG_ACTIVITY_CLEAR_TOP handles 2 edge cases:
170 if (!isWebApk) { 170 // - If a plain PWA is launching from a notification, we want to ensure that the URL being
dominickn 2017/05/23 03:20:13 Nit: "legacy" PWA, not "plain" PWA.
piotrs 2017/05/23 04:11:11 Done.
171 // If this is launching from a notification, we want to ensure that the URL being 171 // launched is the URL in the intent. If a paused WebappActivity exists for this id,
172 // launched is the URL in the intent. If a paused WebappActivity exi sts for this id, 172 // then by default it will be focused and we have no way of sending the desired URL to
173 // then by default it will be focused and we have no way of sending the desired URL to 173 // it (the intent is swallowed). As a workaround, set the CLEAR_TOP flag to ensure that
174 // it (the intent is swallowed). As a workaround, set the CLEAR_TOP flag to ensure that 174 // the existing Activity is cleared and relaunched with this intent.
175 // the existing Activity is cleared and relaunched with this intent. 175 // - If a WebAPK is having a CustomTabActivity on top of it in the same Task, and user
176 // TODO(dominickn): ideally, we want be able to route an intent to 176 // clicks a link to takes them back to the scope of a WebAPK, we want to destroy the
177 // WebappActivity.onNewIntent instead of restarting the Activity. 177 // CustomTabActivity activity and go back to the WebAPK activity. It is intentional that
178 if (source == ShortcutSource.NOTIFICATION) { 178 // Custom Tab will not be reachable with a back button.
179 launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 179 // TODO(dominickn): ideally, we want be able to route an intent to onNew Intent() instead of
180 } 180 // restarting the Activity.
181 } 181 launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
182 return launchIntent; 182 return launchIntent;
183 } 183 }
184 184
185 /** 185 /**
186 * Brings a live WebappActivity back to the foreground if one exists for the given tab ID. 186 * Brings a live WebappActivity back to the foreground if one exists for the given tab ID.
187 * @param tabId ID of the Tab to bring back to the foreground. 187 * @param tabId ID of the Tab to bring back to the foreground.
188 * @return True if a live WebappActivity was found, false otherwise. 188 * @return True if a live WebappActivity was found, false otherwise.
189 */ 189 */
190 public static boolean bringWebappToFront(int tabId) { 190 public static boolean bringWebappToFront(int tabId) {
191 if (tabId == Tab.INVALID_TAB_ID) return false; 191 if (tabId == Tab.INVALID_TAB_ID) return false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA _URL); 223 String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA _URL);
224 if (TextUtils.isEmpty(url)) return false; 224 if (TextUtils.isEmpty(url)) return false;
225 225
226 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url)) ) { 226 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url)) ) {
227 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage ); 227 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage );
228 return false; 228 return false;
229 } 229 }
230 return true; 230 return true;
231 } 231 }
232 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698