OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser; |
| 6 |
| 7 import android.content.ActivityNotFoundException; |
| 8 import android.content.Context; |
| 9 import android.content.Intent; |
| 10 import android.net.Uri; |
| 11 |
| 12 import org.chromium.base.ApplicationStatus; |
| 13 import org.chromium.base.Log; |
| 14 import org.chromium.base.annotations.CalledByNative; |
| 15 |
| 16 /** |
| 17 * Utility class for providing platform functionalities. |
| 18 */ |
| 19 public class PlatformUtil { |
| 20 private static final String TAG = "cr.PlatformUtil"; |
| 21 |
| 22 @CalledByNative |
| 23 private static void launchExternalProtocol(String url) { |
| 24 Context context = ApplicationStatus.getApplicationContext(); |
| 25 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| 26 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 27 intent.addCategory(Intent.CATEGORY_BROWSABLE); |
| 28 try { |
| 29 context.startActivity(intent); |
| 30 } catch (ActivityNotFoundException e) { |
| 31 Log.e(TAG, "cannot find activity to launch " + url, e); |
| 32 } |
| 33 } |
| 34 } |
OLD | NEW |