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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java

Issue 2480153003: Add a TLD whitelist for Google Search URLs. (Closed)
Patch Set: Disable intent:// links to instant apps from non-SERP pages. Created 4 years, 1 month 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.externalnav; 5 package org.chromium.chrome.browser.externalnav;
6 6
7 import android.content.ActivityNotFoundException; 7 import android.content.ActivityNotFoundException;
8 import android.content.ComponentName; 8 import android.content.ComponentName;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.pm.ResolveInfo; 10 import android.content.pm.ResolveInfo;
11 import android.net.Uri; 11 import android.net.Uri;
12 import android.os.SystemClock; 12 import android.os.SystemClock;
13 import android.provider.Browser; 13 import android.provider.Browser;
14 import android.text.TextUtils; 14 import android.text.TextUtils;
15 import android.webkit.WebView; 15 import android.webkit.WebView;
16 16
17 import org.chromium.base.CommandLine; 17 import org.chromium.base.CommandLine;
18 import org.chromium.base.Log; 18 import org.chromium.base.Log;
19 import org.chromium.base.VisibleForTesting; 19 import org.chromium.base.VisibleForTesting;
20 import org.chromium.base.metrics.RecordHistogram; 20 import org.chromium.base.metrics.RecordHistogram;
21 import org.chromium.chrome.browser.ChromeSwitches; 21 import org.chromium.chrome.browser.ChromeSwitches;
22 import org.chromium.chrome.browser.IntentHandler; 22 import org.chromium.chrome.browser.IntentHandler;
23 import org.chromium.chrome.browser.UrlConstants; 23 import org.chromium.chrome.browser.UrlConstants;
24 import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
24 import org.chromium.chrome.browser.tab.Tab; 25 import org.chromium.chrome.browser.tab.Tab;
25 import org.chromium.chrome.browser.tab.TabRedirectHandler; 26 import org.chromium.chrome.browser.tab.TabRedirectHandler;
26 import org.chromium.chrome.browser.util.IntentUtils; 27 import org.chromium.chrome.browser.util.IntentUtils;
27 import org.chromium.chrome.browser.util.UrlUtilities; 28 import org.chromium.chrome.browser.util.UrlUtilities;
28 import org.chromium.chrome.browser.webapps.ChromeWebApkHost; 29 import org.chromium.chrome.browser.webapps.ChromeWebApkHost;
29 import org.chromium.ui.base.PageTransition; 30 import org.chromium.ui.base.PageTransition;
30 31
31 import java.net.URI; 32 import java.net.URI;
32 import java.util.HashSet; 33 import java.util.HashSet;
33 import java.util.List; 34 import java.util.List;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 437
437 if (previousIntent != null 438 if (previousIntent != null
438 && resolversSubsetOf(resolvingInfos, 439 && resolversSubsetOf(resolvingInfos,
439 mDelegate.queryIntentActivities(previousInte nt))) { 440 mDelegate.queryIntentActivities(previousInte nt))) {
440 return OverrideUrlLoadingResult.NO_OVERRIDE; 441 return OverrideUrlLoadingResult.NO_OVERRIDE;
441 } 442 }
442 } 443 }
443 } 444 }
444 } 445 }
445 446
446 boolean shouldProxyForInstantApps = isExternalProtocol 447 boolean isDirectInstantAppsIntent = isExternalProtocol
447 && SUPERVISOR_PKG.equals(intent.getPackage()) 448 && SUPERVISOR_PKG.equals(intent.getPackage());
449 boolean shouldProxyForInstantApps = isDirectInstantAppsIntent
448 && mDelegate.isSerpReferrer(params.getReferrerUrl(), params.getT ab()); 450 && mDelegate.isSerpReferrer(params.getReferrerUrl(), params.getT ab());
451 if (shouldProxyForInstantApps) {
452 intent.putExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER, true);
453 } else if (isDirectInstantAppsIntent) {
454 // For security reasons, we disable all intent:// URLs to Instant Ap ps that are
455 // not coming from SERP.
456 return OverrideUrlLoadingResult.NO_OVERRIDE;
457 } else {
458 // Make sure this extra is not sent unless we've done the verificati on.
459 intent.removeExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER);
460 }
449 461
450 try { 462 try {
451 if (params.isIncognito() && !mDelegate.willChromeHandleIntent(intent )) { 463 if (params.isIncognito() && !mDelegate.willChromeHandleIntent(intent )) {
452 // This intent may leave Chrome. Warn the user that incognito d oes not carry over 464 // This intent may leave Chrome. Warn the user that incognito d oes not carry over
453 // to apps out side of Chrome. 465 // to apps out side of Chrome.
454 mDelegate.startIncognitoIntent(intent, params.getReferrerUrl(), 466 mDelegate.startIncognitoIntent(intent, params.getReferrerUrl(),
455 hasBrowserFallbackUrl ? browserFallbackUrl : null, param s.getTab(), 467 hasBrowserFallbackUrl ? browserFallbackUrl : null, param s.getTab(),
456 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchI ntent(), 468 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchI ntent(),
457 shouldProxyForInstantApps); 469 shouldProxyForInstantApps);
458 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION; 470 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 if (defaultSmsPackageName == null) return null; 579 if (defaultSmsPackageName == null) return null;
568 // Makes sure that the default SMS app actually resolves the intent. 580 // Makes sure that the default SMS app actually resolves the intent.
569 for (ResolveInfo resolveInfo : resolvingComponentNames) { 581 for (ResolveInfo resolveInfo : resolvingComponentNames) {
570 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam e)) { 582 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam e)) {
571 return defaultSmsPackageName; 583 return defaultSmsPackageName;
572 } 584 }
573 } 585 }
574 return null; 586 return null;
575 } 587 }
576 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698