OLD | NEW |
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 package org.chromium.chrome.browser.notifications; | 5 package org.chromium.chrome.browser.notifications; |
6 | 6 |
7 import android.app.Notification; | 7 import android.app.Notification; |
8 import android.app.NotificationManager; | 8 import android.app.NotificationManager; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 /** | 89 /** |
90 * Creates a new instance of the NotificationUIManager. | 90 * Creates a new instance of the NotificationUIManager. |
91 * | 91 * |
92 * @param nativeNotificationManager Instance of the NotificationUIManagerAnd
roid class. | 92 * @param nativeNotificationManager Instance of the NotificationUIManagerAnd
roid class. |
93 * @param context Application context for this instance of Chrome. | 93 * @param context Application context for this instance of Chrome. |
94 */ | 94 */ |
95 @CalledByNative | 95 @CalledByNative |
96 private static NotificationUIManager create(long nativeNotificationManager,
Context context) { | 96 private static NotificationUIManager create(long nativeNotificationManager,
Context context) { |
97 if (sInstance != null) { | 97 if (sInstance != null) { |
98 throw new IllegalStateException("There must only be a single Notific
ationUIManager."); | 98 throw new IllegalStateException( |
| 99 "There must only be a single NotificationPlatformBridge."); |
99 } | 100 } |
100 | 101 |
101 sInstance = new NotificationUIManager(nativeNotificationManager, context
); | 102 sInstance = new NotificationUIManager(nativeNotificationManager, context
); |
102 return sInstance; | 103 return sInstance; |
103 } | 104 } |
104 | 105 |
105 /** | 106 /** |
106 * Returns the current instance of the NotificationUIManager. | 107 * Returns the current instance of the NotificationUIManager. |
107 * | 108 * |
108 * @return The instance of the NotificationUIManager, if any. | 109 * @return The instance of the NotificationUIManager, if any. |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 */ | 634 */ |
634 public static boolean wasNotificationRecentlyClicked() { | 635 public static boolean wasNotificationRecentlyClicked() { |
635 if (sInstance == null) return false; | 636 if (sInstance == null) return false; |
636 long now = System.currentTimeMillis(); | 637 long now = System.currentTimeMillis(); |
637 return now - sInstance.mLastNotificationClickMs < 5 * 1000; | 638 return now - sInstance.mLastNotificationClickMs < 5 * 1000; |
638 } | 639 } |
639 | 640 |
640 /** | 641 /** |
641 * Closes the notification associated with the given parameters. | 642 * Closes the notification associated with the given parameters. |
642 * | 643 * |
| 644 * @param profileId of the profile whose notification this is for. |
643 * @param persistentNotificationId The persistent id of the notification. | 645 * @param persistentNotificationId The persistent id of the notification. |
644 * @param origin The origin to which the notification belongs. | 646 * @param origin The origin to which the notification belongs. |
645 * @param tag The tag of the notification. May be NULL. | 647 * @param tag The tag of the notification. May be NULL. |
646 */ | 648 */ |
647 @CalledByNative | 649 @CalledByNative |
648 private void closeNotification(long persistentNotificationId, String origin,
String tag) { | 650 private void closeNotification( |
| 651 String profileId, long persistentNotificationId, String origin, Stri
ng tag) { |
| 652 // TODO(miguelg) make profile_id part of the tag. |
649 String platformTag = makePlatformTag(persistentNotificationId, origin, t
ag); | 653 String platformTag = makePlatformTag(persistentNotificationId, origin, t
ag); |
650 mNotificationManager.cancel(platformTag, PLATFORM_ID); | 654 mNotificationManager.cancel(platformTag, PLATFORM_ID); |
651 } | 655 } |
652 | 656 |
653 /** | 657 /** |
654 * Calls NotificationUIManagerAndroid::OnNotificationClicked in native code
to indicate that | 658 * Calls NotificationUIManagerAndroid::OnNotificationClicked in native code
to indicate that |
655 * the notification with the given parameters has been clicked on. | 659 * the notification with the given parameters has been clicked on. |
656 * | 660 * |
657 * @param persistentNotificationId The persistent id of the notification. | 661 * @param persistentNotificationId The persistent id of the notification. |
658 * @param origin The origin of the notification. | 662 * @param origin The origin of the notification. |
(...skipping 27 matching lines...) Expand all Loading... |
686 | 690 |
687 private static native void nativeInitializeNotificationUIManager(); | 691 private static native void nativeInitializeNotificationUIManager(); |
688 | 692 |
689 private native void nativeOnNotificationClicked(long nativeNotificationUIMan
agerAndroid, | 693 private native void nativeOnNotificationClicked(long nativeNotificationUIMan
agerAndroid, |
690 long persistentNotificationId, String origin, String profileId, bool
ean incognito, | 694 long persistentNotificationId, String origin, String profileId, bool
ean incognito, |
691 String tag, int actionIndex); | 695 String tag, int actionIndex); |
692 private native void nativeOnNotificationClosed(long nativeNotificationUIMana
gerAndroid, | 696 private native void nativeOnNotificationClosed(long nativeNotificationUIMana
gerAndroid, |
693 long persistentNotificationId, String origin, String profileId, bool
ean incognito, | 697 long persistentNotificationId, String origin, String profileId, bool
ean incognito, |
694 String tag, boolean byUser); | 698 String tag, boolean byUser); |
695 } | 699 } |
OLD | NEW |