| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fbe8a13a88505feb373317f6c8b2ed301515abcc
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java
|
| @@ -0,0 +1,39 @@
|
| +// 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.
|
| + *
|
| + * Exposes helper functions to native C++ code.
|
| + */
|
| +public class ContentSuggestionsNotificationHelper {
|
| + private ContentSuggestionsNotificationHelper() {} // 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);
|
| + }
|
| +}
|
|
|