OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.incognito; | 5 package org.chromium.chrome.browser.incognito; |
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.content.Context; | 9 import android.content.Context; |
10 import android.support.v4.app.NotificationCompat; | |
11 | 10 |
12 import org.chromium.base.ContextUtils; | 11 import org.chromium.base.ContextUtils; |
13 import org.chromium.chrome.R; | 12 import org.chromium.chrome.R; |
| 13 import org.chromium.chrome.browser.ChromeApplication; |
| 14 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; |
14 import org.chromium.chrome.browser.notifications.NotificationConstants; | 15 import org.chromium.chrome.browser.notifications.NotificationConstants; |
15 | 16 |
16 /** | 17 /** |
17 * Manages the notification indicating that there are incognito tabs opened in D
ocument mode. | 18 * Manages the notification indicating that there are incognito tabs opened in D
ocument mode. |
18 */ | 19 */ |
19 public class IncognitoNotificationManager { | 20 public class IncognitoNotificationManager { |
20 private static final String INCOGNITO_TABS_OPEN_TAG = "incognito_tabs_open"; | 21 private static final String INCOGNITO_TABS_OPEN_TAG = "incognito_tabs_open"; |
21 private static final int INCOGNITO_TABS_OPEN_ID = 100; | 22 private static final int INCOGNITO_TABS_OPEN_ID = 100; |
22 | 23 |
23 /** | 24 /** |
24 * Shows the close all incognito notification. | 25 * Shows the close all incognito notification. |
25 */ | 26 */ |
26 public static void showIncognitoNotification() { | 27 public static void showIncognitoNotification() { |
27 Context context = ContextUtils.getApplicationContext(); | 28 Context context = ContextUtils.getApplicationContext(); |
28 String actionMessage = | 29 String actionMessage = |
29 context.getResources().getString(R.string.close_all_incognito_no
tification); | 30 context.getResources().getString(R.string.close_all_incognito_no
tification); |
30 String title = context.getResources().getString(R.string.app_name); | 31 String title = context.getResources().getString(R.string.app_name); |
31 | 32 |
32 NotificationCompat.Builder builder = new NotificationCompat.Builder(cont
ext) | 33 ChromeNotificationBuilder builder = |
33 .setContentTitle(title) | 34 ((ChromeApplication) context) |
34 .setContentIntent( | 35 .getChromeNotificationBuilder(true, NotificationConstant
s.TYPE_ID_INCOGNITO, |
35 IncognitoNotificationService.getRemoveAllIncognitoTabsIn
tent(context)) | 36 NotificationConstants.TYPE_NAME_INCOGNITO) |
36 .setContentText(actionMessage) | 37 .setContentTitle(title) |
37 .setOngoing(true) | 38 .setContentIntent( |
38 .setVisibility(Notification.VISIBILITY_SECRET) | 39 IncognitoNotificationService.getRemoveAllIncogni
toTabsIntent( |
39 .setSmallIcon(R.drawable.incognito_statusbar) | 40 context)) |
40 .setShowWhen(false) | 41 .setContentText(actionMessage) |
41 .setLocalOnly(true) | 42 .setOngoing(true) |
42 .setGroup(NotificationConstants.GROUP_INCOGNITO); | 43 .setVisibility(Notification.VISIBILITY_SECRET) |
| 44 .setSmallIcon(R.drawable.incognito_statusbar) |
| 45 .setShowWhen(false) |
| 46 .setLocalOnly(true) |
| 47 .setGroup(NotificationConstants.GROUP_INCOGNITO); |
43 NotificationManager nm = | 48 NotificationManager nm = |
44 (NotificationManager) context.getSystemService(Context.NOTIFICAT
ION_SERVICE); | 49 (NotificationManager) context.getSystemService(Context.NOTIFICAT
ION_SERVICE); |
45 nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build
()); | 50 nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build
()); |
46 } | 51 } |
47 | 52 |
48 /** | 53 /** |
49 * Dismisses the incognito notification. | 54 * Dismisses the incognito notification. |
50 */ | 55 */ |
51 public static void dismissIncognitoNotification() { | 56 public static void dismissIncognitoNotification() { |
52 Context context = ContextUtils.getApplicationContext(); | 57 Context context = ContextUtils.getApplicationContext(); |
53 NotificationManager nm = | 58 NotificationManager nm = |
54 (NotificationManager) context.getSystemService(Context.NOTIFIC
ATION_SERVICE); | 59 (NotificationManager) context.getSystemService(Context.NOTIFIC
ATION_SERVICE); |
55 nm.cancel(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID); | 60 nm.cancel(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID); |
56 } | 61 } |
57 } | 62 } |
OLD | NEW |