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

Unified Diff: chrome/browser/android/ntp/content_suggestions_notification_helper.cc

Issue 2606753002: Post notification after fetching articles (Closed)
Patch Set: Add TODO. Created 3 years, 11 months 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
Index: chrome/browser/android/ntp/content_suggestions_notification_helper.cc
diff --git a/chrome/browser/android/ntp/content_suggestions_notification_helper.cc b/chrome/browser/android/ntp/content_suggestions_notification_helper.cc
index 6e05fdbef276a3ccc36df27455249ee59fce40bd..03f45739f93dc93a3011db78ca608e266a0a46ef 100644
--- a/chrome/browser/android/ntp/content_suggestions_notification_helper.cc
+++ b/chrome/browser/android/ntp/content_suggestions_notification_helper.cc
@@ -6,7 +6,11 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
+#include "base/strings/utf_string_conversions.h"
#include "jni/ContentSuggestionsNotificationHelper_jni.h"
+#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia.h"
namespace ntp_snippets {
@@ -16,4 +20,26 @@ void ContentSuggestionsNotificationHelper::OpenURL(const GURL& url) {
env, base::android::ConvertUTF8ToJavaString(env, url.spec()));
}
+void ContentSuggestionsNotificationHelper::SendNotification(
+ const GURL& url,
+ const base::string16& title,
+ const base::string16& text,
+ const gfx::Image& image) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ SkBitmap skimage = image.AsImageSkia().GetRepresentation(1.0f).sk_bitmap();
+ if (skimage.empty())
+ return;
+
+ Java_ContentSuggestionsNotificationHelper_showNotification(
+ env, base::android::ConvertUTF8ToJavaString(env, url.spec()),
+ base::android::ConvertUTF16ToJavaString(env, title),
+ base::android::ConvertUTF16ToJavaString(env, text),
+ gfx::ConvertToJavaBitmap(&skimage));
+}
+
+void ContentSuggestionsNotificationHelper::HideNotification() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_ContentSuggestionsNotificationHelper_hideNotification(env);
+}
+
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698