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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h" 5 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/strings/utf_string_conversions.h"
9 #include "jni/ContentSuggestionsNotificationHelper_jni.h" 10 #include "jni/ContentSuggestionsNotificationHelper_jni.h"
11 #include "ui/gfx/android/java_bitmap.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/gfx/image/image_skia.h"
10 14
11 namespace ntp_snippets { 15 namespace ntp_snippets {
12 16
13 void ContentSuggestionsNotificationHelper::OpenURL(const GURL& url) { 17 void ContentSuggestionsNotificationHelper::OpenURL(const GURL& url) {
14 JNIEnv* env = base::android::AttachCurrentThread(); 18 JNIEnv* env = base::android::AttachCurrentThread();
15 Java_ContentSuggestionsNotificationHelper_openUrl( 19 Java_ContentSuggestionsNotificationHelper_openUrl(
16 env, base::android::ConvertUTF8ToJavaString(env, url.spec())); 20 env, base::android::ConvertUTF8ToJavaString(env, url.spec()));
17 } 21 }
18 22
23 void ContentSuggestionsNotificationHelper::SendNotification(
24 const GURL& url,
25 const base::string16& title,
26 const base::string16& text,
27 const gfx::Image& image) {
28 JNIEnv* env = base::android::AttachCurrentThread();
29 SkBitmap skimage = image.AsImageSkia().GetRepresentation(1.0f).sk_bitmap();
30 if (skimage.empty())
31 return;
32
33 Java_ContentSuggestionsNotificationHelper_showNotification(
34 env, base::android::ConvertUTF8ToJavaString(env, url.spec()),
35 base::android::ConvertUTF16ToJavaString(env, title),
36 base::android::ConvertUTF16ToJavaString(env, text),
37 gfx::ConvertToJavaBitmap(&skimage));
38 }
39
40 void ContentSuggestionsNotificationHelper::HideNotification() {
41 JNIEnv* env = base::android::AttachCurrentThread();
42 Java_ContentSuggestionsNotificationHelper_hideNotification(env);
43 }
44
19 } // namespace ntp_snippets 45 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698