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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 PendingIntent pendingSettingsIntent = PendingIntent.getActivity(mAppCont
ext, | 445 PendingIntent pendingSettingsIntent = PendingIntent.getActivity(mAppCont
ext, |
446 PENDING_INTENT_REQUEST_CODE, settingsIntent, PendingIntent.FLAG_
UPDATE_CURRENT); | 446 PENDING_INTENT_REQUEST_CODE, settingsIntent, PendingIntent.FLAG_
UPDATE_CURRENT); |
447 | 447 |
448 PendingIntent clickIntent = makePendingIntent( | 448 PendingIntent clickIntent = makePendingIntent( |
449 NotificationConstants.ACTION_CLICK_NOTIFICATION, persistentNotif
icationId, origin, | 449 NotificationConstants.ACTION_CLICK_NOTIFICATION, persistentNotif
icationId, origin, |
450 profileId, incognito, tag, -1 /* actionIndex */); | 450 profileId, incognito, tag, -1 /* actionIndex */); |
451 PendingIntent closeIntent = makePendingIntent( | 451 PendingIntent closeIntent = makePendingIntent( |
452 NotificationConstants.ACTION_CLOSE_NOTIFICATION, persistentNotif
icationId, origin, | 452 NotificationConstants.ACTION_CLOSE_NOTIFICATION, persistentNotif
icationId, origin, |
453 profileId, incognito, tag, -1 /* actionIndex */); | 453 profileId, incognito, tag, -1 /* actionIndex */); |
454 | 454 |
455 NotificationBuilder notificationBuilder = | 455 NotificationBuilderBase notificationBuilder = |
456 createNotificationBuilder() | 456 createNotificationBuilder() |
457 .setTitle(title) | 457 .setTitle(title) |
458 .setBody(body) | 458 .setBody(body) |
459 .setLargeIcon(ensureNormalizedIcon(icon, origin)) | 459 .setLargeIcon(ensureNormalizedIcon(icon, origin)) |
460 .setSmallIcon(R.drawable.ic_chrome) | 460 .setSmallIcon(R.drawable.ic_chrome) |
461 .setContentIntent(clickIntent) | 461 .setContentIntent(clickIntent) |
462 .setDeleteIntent(closeIntent) | 462 .setDeleteIntent(closeIntent) |
463 .setTicker(createTickerText(title, body)) | 463 .setTicker(createTickerText(title, body)) |
464 .setOrigin(UrlUtilities.formatUrlForSecurityDisplay( | 464 .setOrigin(UrlUtilities.formatUrlForSecurityDisplay( |
465 origin, false /* showScheme */)); | 465 origin, false /* showScheme */)); |
(...skipping 27 matching lines...) Expand all Loading... |
493 // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577
185 | 493 // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577
185 |
494 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); | 494 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
495 StrictMode.allowThreadDiskWrites(); | 495 StrictMode.allowThreadDiskWrites(); |
496 try { | 496 try { |
497 mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBu
ilder.build()); | 497 mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBu
ilder.build()); |
498 } finally { | 498 } finally { |
499 StrictMode.setThreadPolicy(oldPolicy); | 499 StrictMode.setThreadPolicy(oldPolicy); |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 private NotificationBuilder createNotificationBuilder() { | 503 private NotificationBuilderBase createNotificationBuilder() { |
504 if (useCustomLayouts()) { | 504 if (useCustomLayouts()) { |
505 return new CustomNotificationBuilder(mAppContext); | 505 return new CustomNotificationBuilder(mAppContext); |
506 } | 506 } |
507 return new StandardNotificationBuilder(mAppContext); | 507 return new StandardNotificationBuilder(mAppContext); |
508 } | 508 } |
509 | 509 |
510 /** | 510 /** |
511 * Creates the ticker text for a notification having |title| and |body|. The
notification's | 511 * Creates the ticker text for a notification having |title| and |body|. The
notification's |
512 * title will be printed in bold, followed by the text of the body. | 512 * title will be printed in bold, followed by the text of the body. |
513 * | 513 * |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 645 |
646 private static native void nativeInitializeNotificationUIManager(); | 646 private static native void nativeInitializeNotificationUIManager(); |
647 | 647 |
648 private native void nativeOnNotificationClicked(long nativeNotificationUIMan
agerAndroid, | 648 private native void nativeOnNotificationClicked(long nativeNotificationUIMan
agerAndroid, |
649 long persistentNotificationId, String origin, String profileId, bool
ean incognito, | 649 long persistentNotificationId, String origin, String profileId, bool
ean incognito, |
650 String tag, int actionIndex); | 650 String tag, int actionIndex); |
651 private native void nativeOnNotificationClosed(long nativeNotificationUIMana
gerAndroid, | 651 private native void nativeOnNotificationClosed(long nativeNotificationUIMana
gerAndroid, |
652 long persistentNotificationId, String origin, String profileId, bool
ean incognito, | 652 long persistentNotificationId, String origin, String profileId, bool
ean incognito, |
653 String tag, boolean byUser); | 653 String tag, boolean byUser); |
654 } | 654 } |
OLD | NEW |