Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NotificationHelper.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NotificationHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NotificationHelper.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..da0b3a806961329fdcdd49d5946f8c8c073ec0ad |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NotificationHelper.java |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.ntp; |
| + |
| +import android.content.Context; |
| +import android.content.Intent; |
| +import android.net.Uri; |
| +import android.provider.Browser; |
| + |
| +import org.chromium.base.ContextUtils; |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.chrome.browser.IntentHandler; |
| +import org.chromium.chrome.browser.ShortcutHelper; |
| +import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| + |
| +/** |
| + * Provides functionality needed for content suggestion notifications. |
|
Bernhard Bauer
2016/12/19 17:04:10
Maybe add a comment that the class is meant to be
sfiera
2016/12/19 18:21:24
Done.
|
| + */ |
| +public class NotificationHelper { |
| + private NotificationHelper() {} // Prevent instantiation |
| + |
| + @CalledByNative |
| + private static void openUrl(String url) { |
| + Context context = ContextUtils.getApplicationContext(); |
| + Intent intent = new Intent(); |
| + intent.setAction(Intent.ACTION_VIEW); |
| + intent.setData(Uri.parse(url)); |
| + intent.setClass(context, ChromeLauncherActivity.class); |
| + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| + intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); |
| + intent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); |
| + IntentHandler.addTrustedIntentExtras(intent, context); |
| + context.startActivity(intent); |
| + } |
| +} |