Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 Google Inc. All Rights Reserved. | 1 // Copyright 2015 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 * | 45 * |
| 46 * @param activity The host activity. | 46 * @param activity The host activity. |
| 47 * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is a vailable. | 47 * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is a vailable. |
| 48 * @param uri the Uri to be opened. | 48 * @param uri the Uri to be opened. |
| 49 * @param fallback a CustomTabFallback to be used if Custom Tabs is not avai lable. | 49 * @param fallback a CustomTabFallback to be used if Custom Tabs is not avai lable. |
| 50 */ | 50 */ |
| 51 public static void openCustomTab(Activity activity, | 51 public static void openCustomTab(Activity activity, |
| 52 CustomTabsIntent customTabsIntent, | 52 CustomTabsIntent customTabsIntent, |
| 53 Uri uri, | 53 Uri uri, |
| 54 CustomTabFallback fallback) { | 54 CustomTabFallback fallback) { |
| 55 String packageName = CustomTabsHelper.getPackageNameToUse(activity); | 55 openCustomTab(activity, customTabsIntent, uri, fallback, null); |
| 56 } | |
| 56 | 57 |
| 57 //If we cant find a package name, it means theres no browser that suppor ts | 58 public static void openCustomTab(Activity activity, |
| 58 //Chrome Custom Tabs installed. So, we fallback to the webview | 59 CustomTabsIntent customTabsIntent, |
|
Ian Wen
2016/03/16 01:35:30
Public methods should have javadocs
BigBossZhiling
2016/03/18 00:59:07
Done.
| |
| 60 Uri uri, | |
| 61 CustomTabFallback fallback, | |
| 62 String packageName) { | |
| 59 if (packageName == null) { | 63 if (packageName == null) { |
| 60 if (fallback != null) { | 64 packageName = CustomTabsHelper.getPackageNameToUse(activity); |
| 61 fallback.openUri(activity, uri); | 65 //If we cant find a package name, it means theres no browser that su pports |
| 66 //Chrome Custom Tabs installed. So, we fallback to the webview | |
| 67 if (packageName == null) { | |
| 68 if (fallback != null) { | |
| 69 fallback.openUri(activity, uri); | |
| 70 } | |
| 62 } | 71 } |
| 63 } else { | 72 } else { |
| 64 customTabsIntent.intent.setPackage(packageName); | 73 customTabsIntent.intent.setPackage(packageName); |
| 65 customTabsIntent.launchUrl(activity, uri); | 74 customTabsIntent.launchUrl(activity, uri); |
| 66 } | 75 } |
| 67 } | 76 } |
| 68 | 77 |
| 69 /** | 78 /** |
| 70 * Unbinds the Activity from the Custom Tabs Service. | 79 * Unbinds the Activity from the Custom Tabs Service. |
| 71 * @param activity the activity that is connected to the service. | 80 * @param activity the activity that is connected to the service. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 public interface CustomTabFallback { | 172 public interface CustomTabFallback { |
| 164 /** | 173 /** |
| 165 * | 174 * |
| 166 * @param activity The Activity that wants to open the Uri. | 175 * @param activity The Activity that wants to open the Uri. |
| 167 * @param uri The uri to be opened by the fallback. | 176 * @param uri The uri to be opened by the fallback. |
| 168 */ | 177 */ |
| 169 void openUri(Activity activity, Uri uri); | 178 void openUri(Activity activity, Uri uri); |
| 170 } | 179 } |
| 171 | 180 |
| 172 } | 181 } |
| OLD | NEW |