Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NotificationHelper.java

Issue 2586293002: Add helper to open URL in new activity (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | chrome/browser/android/ntp/notification_helper.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | chrome/browser/android/ntp/notification_helper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698