| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.document; | |
| 6 | |
| 7 import android.app.Notification; | |
| 8 import android.app.NotificationManager; | |
| 9 import android.app.PendingIntent; | |
| 10 import android.content.Context; | |
| 11 import android.support.v4.app.NotificationCompat; | |
| 12 | |
| 13 import org.chromium.base.ApplicationStatus; | |
| 14 import org.chromium.chrome.R; | |
| 15 | |
| 16 /** | |
| 17 * Manages the notification indicating that there are incognito tabs opened in D
ocument mode. | |
| 18 */ | |
| 19 public class IncognitoNotificationManager { | |
| 20 private static final String INCOGNITO_TABS_OPEN_TAG = "incognito_tabs_open"; | |
| 21 private static final int INCOGNITO_TABS_OPEN_ID = 100; | |
| 22 | |
| 23 /** | |
| 24 * Updates the notification being displayed. | |
| 25 * @param intent Intent to fire if the notification is selected. | |
| 26 */ | |
| 27 public static void updateIncognitoNotification(PendingIntent intent) { | |
| 28 Context context = ApplicationStatus.getApplicationContext(); | |
| 29 String actionMessage = | |
| 30 context.getResources().getString(R.string.close_all_incognito_no
tification); | |
| 31 String title = context.getResources().getString(R.string.app_name); | |
| 32 | |
| 33 NotificationCompat.Builder builder = new NotificationCompat.Builder(cont
ext) | |
| 34 .setContentTitle(title) | |
| 35 .setContentIntent(intent) | |
| 36 .setContentText(actionMessage) | |
| 37 .setOngoing(true) | |
| 38 .setVisibility(Notification.VISIBILITY_SECRET) | |
| 39 .setSmallIcon(R.drawable.incognito_statusbar) | |
| 40 .setShowWhen(false) | |
| 41 .setLocalOnly(true); | |
| 42 NotificationManager nm = | |
| 43 (NotificationManager) context.getSystemService(Context.NOTIFICAT
ION_SERVICE); | |
| 44 nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build
()); | |
| 45 } | |
| 46 | |
| 47 /** | |
| 48 * Dismisses the incognito notification. | |
| 49 */ | |
| 50 public static void dismissIncognitoNotification() { | |
| 51 Context context = ApplicationStatus.getApplicationContext(); | |
| 52 NotificationManager nm = | |
| 53 (NotificationManager) context.getSystemService(Context.NOTIFIC
ATION_SERVICE); | |
| 54 nm.cancel(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID); | |
| 55 } | |
| 56 } | |
| OLD | NEW |