| OLD | NEW |
| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 const base::string16& title, | 46 const base::string16& title, |
| 47 const base::string16& text, | 47 const base::string16& text, |
| 48 const gfx::Image& image, | 48 const gfx::Image& image, |
| 49 base::Time timeout_at) { | 49 base::Time timeout_at) { |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 50 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 SkBitmap skimage = image.AsImageSkia().GetRepresentation(1.0f).sk_bitmap(); | 51 SkBitmap skimage = image.AsImageSkia().GetRepresentation(1.0f).sk_bitmap(); |
| 52 if (skimage.empty()) | 52 if (skimage.empty()) |
| 53 return false; | 53 return false; |
| 54 | 54 |
| 55 jint timeout_at_millis = timeout_at.ToJavaTime(); | 55 jlong timeout_at_millis = timeout_at.ToJavaTime(); |
| 56 if (timeout_at == base::Time::Max()) { | 56 if (timeout_at == base::Time::Max()) { |
| 57 timeout_at_millis = std::numeric_limits<jint>::max(); | 57 timeout_at_millis = std::numeric_limits<jlong>::max(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (Java_ContentSuggestionsNotificationHelper_showNotification( | 60 if (Java_ContentSuggestionsNotificationHelper_showNotification( |
| 61 env, id.category().id(), | 61 env, id.category().id(), |
| 62 base::android::ConvertUTF8ToJavaString(env, id.id_within_category()), | 62 base::android::ConvertUTF8ToJavaString(env, id.id_within_category()), |
| 63 base::android::ConvertUTF8ToJavaString(env, url.spec()), | 63 base::android::ConvertUTF8ToJavaString(env, url.spec()), |
| 64 base::android::ConvertUTF16ToJavaString(env, title), | 64 base::android::ConvertUTF16ToJavaString(env, title), |
| 65 base::android::ConvertUTF16ToJavaString(env, text), | 65 base::android::ConvertUTF16ToJavaString(env, text), |
| 66 gfx::ConvertToJavaBitmap(&skimage), timeout_at_millis)) { | 66 gfx::ConvertToJavaBitmap(&skimage), timeout_at_millis)) { |
| 67 DVLOG(1) << "Displayed notification for " << id; | 67 DVLOG(1) << "Displayed notification for " << id; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 prefs->SetInteger(prefs::kContentSuggestionsConsecutiveIgnoredPrefName, | 161 prefs->SetInteger(prefs::kContentSuggestionsConsecutiveIgnoredPrefName, |
| 162 consecutive_ignored); | 162 consecutive_ignored); |
| 163 const bool is_disabled = IsDisabledForProfile(profile); | 163 const bool is_disabled = IsDisabledForProfile(profile); |
| 164 if (!was_disabled && is_disabled) { | 164 if (!was_disabled && is_disabled) { |
| 165 RecordContentSuggestionsNotificationOptOut(CONTENT_SUGGESTIONS_IMPLICIT); | 165 RecordContentSuggestionsNotificationOptOut(CONTENT_SUGGESTIONS_IMPLICIT); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace ntp_snippets | 169 } // namespace ntp_snippets |
| OLD | NEW |