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

Side by Side Diff: chrome/browser/notifications/notification_ui_manager_android.cc

Issue 1054573002: Implement support for notification.vibrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/notification_ui_manager_android.h" 5 #include "chrome/browser/notifications/notification_ui_manager_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/android/jni_array.h" 9 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 env, notification.title()); 111 env, notification.title());
112 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString( 112 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString(
113 env, notification.message()); 113 env, notification.message());
114 114
115 ScopedJavaLocalRef<jobject> icon; 115 ScopedJavaLocalRef<jobject> icon;
116 116
117 SkBitmap icon_bitmap = notification.icon().AsBitmap(); 117 SkBitmap icon_bitmap = notification.icon().AsBitmap();
118 if (!icon_bitmap.isNull()) 118 if (!icon_bitmap.isNull())
119 icon = gfx::ConvertToJavaBitmap(&icon_bitmap); 119 icon = gfx::ConvertToJavaBitmap(&icon_bitmap);
120 120
121 std::vector<int64> pattern;
Peter Beverloo 2015/04/21 17:58:22 nit: Please use int64_t everywhere. int64 is depre
Sanghyun Park 2015/04/23 11:08:26 Done.
122 if (!notification.vibrate().empty()) {
Peter Beverloo 2015/04/21 17:58:22 We can simplify this block by using: ScopedJavaLo
Sanghyun Park 2015/04/23 11:08:25 We couldn't use ToJavaLongArray function directly.
Peter Beverloo 2015/04/26 23:26:40 Yes - having this in Java SGTM. (It changes common
123 // In Android platform, the first value indicates the number of
124 // milliseconds to wait before turning the vibrator on unlike Blink.
125 // So, we need to insert any value at the beginning of vibrate value.
126 pattern.reserve(notification.vibrate().size() + 1);
127 pattern.push_back(0);
128 for (size_t i = 0; i < notification.vibrate().size(); ++i)
129 pattern.push_back(notification.vibrate()[i]);
130 }
131 ScopedJavaLocalRef<jlongArray> vibrate =
132 base::android::ToJavaLongArray(env, pattern.begin(), pattern.size());
133
121 Java_NotificationUIManager_displayNotification( 134 Java_NotificationUIManager_displayNotification(
122 env, 135 env,
123 java_object_.obj(), 136 java_object_.obj(),
124 persistent_notification_id, 137 persistent_notification_id,
125 origin.obj(), 138 origin.obj(),
126 tag.obj(), 139 tag.obj(),
127 title.obj(), 140 title.obj(),
128 body.obj(), 141 body.obj(),
129 icon.obj(), 142 icon.obj(),
143 vibrate.obj(),
130 notification.silent()); 144 notification.silent());
131 145
132 regenerated_notification_infos_[persistent_notification_id] = 146 regenerated_notification_infos_[persistent_notification_id] =
133 std::make_pair(origin_url.spec(), notification.tag()); 147 std::make_pair(origin_url.spec(), notification.tag());
134 148
135 notification.delegate()->Display(); 149 notification.delegate()->Display();
136 } 150 }
137 151
138 bool NotificationUIManagerAndroid::Update(const Notification& notification, 152 bool NotificationUIManagerAndroid::Update(const Notification& notification,
139 Profile* profile) { 153 Profile* profile) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return false; 214 return false;
201 } 215 }
202 216
203 void NotificationUIManagerAndroid::CancelAll() { 217 void NotificationUIManagerAndroid::CancelAll() {
204 NOTREACHED(); 218 NOTREACHED();
205 } 219 }
206 220
207 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { 221 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) {
208 return RegisterNativesImpl(env); 222 return RegisterNativesImpl(env);
209 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698