| 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.externalnav; | 5 package org.chromium.chrome.browser.externalnav; |
| 6 | 6 |
| 7 import android.Manifest.permission; | 7 import android.Manifest.permission; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 @Override | 214 @Override |
| 215 public boolean willChromeHandleIntent(Intent intent) { | 215 public boolean willChromeHandleIntent(Intent intent) { |
| 216 return willChromeHandleIntent(mApplicationContext, intent, false); | 216 return willChromeHandleIntent(mApplicationContext, intent, false); |
| 217 } | 217 } |
| 218 | 218 |
| 219 @Override | 219 @Override |
| 220 public boolean isSpecializedHandlerAvailable(List<ResolveInfo> infos) { | 220 public boolean isSpecializedHandlerAvailable(List<ResolveInfo> infos) { |
| 221 return isPackageSpecializedHandler(infos, null); | 221 return isPackageSpecializedHandler(infos, null); |
| 222 } | 222 } |
| 223 | 223 |
| 224 private static boolean isPackageSpecializedHandler(List<ResolveInfo> handler
s, | 224 static boolean isPackageSpecializedHandler(List<ResolveInfo> handlers, |
| 225 String packageName) { | 225 String packageName) { |
| 226 if (handlers == null || handlers.size() == 0) return false; | 226 if (handlers == null || handlers.size() == 0) return false; |
| 227 for (ResolveInfo resolveInfo : handlers) { | 227 for (ResolveInfo resolveInfo : handlers) { |
| 228 IntentFilter filter = resolveInfo.filter; | 228 IntentFilter filter = resolveInfo.filter; |
| 229 if (filter == null) { | 229 if (filter == null) { |
| 230 // No intent filter matches this intent? | 230 // No intent filter matches this intent? |
| 231 // Error on the side of staying in the browser, ignore | 231 // Error on the side of staying in the browser, ignore |
| 232 continue; | 232 continue; |
| 233 } | 233 } |
| 234 if (filter.countDataAuthorities() == 0 || filter.countDataPaths() ==
0) { | 234 if (filter.countDataAuthorities() == 0 && filter.countDataPaths() ==
0) { |
| 235 // Generic handler, skip | 235 // Generic handler, skip |
| 236 continue; | 236 continue; |
| 237 } | 237 } |
| 238 if (TextUtils.isEmpty(packageName)) return true; | 238 if (TextUtils.isEmpty(packageName)) return true; |
| 239 ActivityInfo activityInfo = resolveInfo.activityInfo; | 239 ActivityInfo activityInfo = resolveInfo.activityInfo; |
| 240 if (activityInfo == null) continue; | 240 if (activityInfo == null) continue; |
| 241 if (!activityInfo.packageName.equals(packageName)) continue; | 241 if (!activityInfo.packageName.equals(packageName)) continue; |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 | 244 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 private void closeTab(Tab tab) { | 463 private void closeTab(Tab tab) { |
| 464 Context context = tab.getWindowAndroid().getContext().get(); | 464 Context context = tab.getWindowAndroid().getContext().get(); |
| 465 if (context instanceof ChromeActivity) { | 465 if (context instanceof ChromeActivity) { |
| 466 ((ChromeActivity) context).getTabModelSelector().closeTab(tab); | 466 ((ChromeActivity) context).getTabModelSelector().closeTab(tab); |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 } | 469 } |
| OLD | NEW |