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 18 matching lines...) Expand all Loading... |
29 import org.chromium.base.metrics.RecordUserAction; | 29 import org.chromium.base.metrics.RecordUserAction; |
30 import org.chromium.chrome.R; | 30 import org.chromium.chrome.R; |
31 import org.chromium.chrome.browser.ChromeSwitches; | 31 import org.chromium.chrome.browser.ChromeSwitches; |
32 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; | 32 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
33 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 33 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
34 import org.chromium.chrome.browser.preferences.Preferences; | 34 import org.chromium.chrome.browser.preferences.Preferences; |
35 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 35 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
36 import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences
; | 36 import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences
; |
37 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; | 37 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; |
38 import org.chromium.chrome.browser.preferences.website.SiteSettingsCategory; | 38 import org.chromium.chrome.browser.preferences.website.SiteSettingsCategory; |
39 import org.chromium.chrome.browser.util.UrlUtilities; | |
40 import org.chromium.chrome.browser.webapps.ChromeWebApkHost; | 39 import org.chromium.chrome.browser.webapps.ChromeWebApkHost; |
41 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 40 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 41 import org.chromium.components.url_formatter.UrlFormatter; |
42 import org.chromium.webapk.lib.client.WebApkValidator; | 42 import org.chromium.webapk.lib.client.WebApkValidator; |
43 | 43 |
44 import java.net.URI; | 44 import java.net.URI; |
45 import java.net.URISyntaxException; | 45 import java.net.URISyntaxException; |
46 | 46 |
47 import javax.annotation.Nullable; | 47 import javax.annotation.Nullable; |
48 | 48 |
49 /** | 49 /** |
50 * Provides the ability for the NotificationPlatformBridgeAndroid to talk to the
Android platform | 50 * Provides the ability for the NotificationPlatformBridgeAndroid to talk to the
Android platform |
51 * notification system. | 51 * notification system. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 * screen. | 238 * screen. |
239 * | 239 * |
240 * @param context The context that received the intent. | 240 * @param context The context that received the intent. |
241 * @param incomingIntent The received intent. | 241 * @param incomingIntent The received intent. |
242 */ | 242 */ |
243 public static void launchNotificationPreferences(Context context, Intent inc
omingIntent) { | 243 public static void launchNotificationPreferences(Context context, Intent inc
omingIntent) { |
244 // This method handles an intent fired by the Android system. There is n
o guarantee that the | 244 // This method handles an intent fired by the Android system. There is n
o guarantee that the |
245 // native library is loaded at this point. The native library is needed
for the preferences | 245 // native library is loaded at this point. The native library is needed
for the preferences |
246 // activity, and it loads the library, but there are some native calls e
ven before that | 246 // activity, and it loads the library, but there are some native calls e
ven before that |
247 // activity is started: from RecordUserAction.record and (indirectly) fr
om | 247 // activity is started: from RecordUserAction.record and (indirectly) fr
om |
248 // UrlUtilities.formatUrlForSecurityDisplay. | 248 // UrlFormatter.formatUrlForSecurityDisplay. |
249 try { | 249 try { |
250 ChromeBrowserInitializer.getInstance(context).handleSynchronousStart
up(); | 250 ChromeBrowserInitializer.getInstance(context).handleSynchronousStart
up(); |
251 } catch (ProcessInitException e) { | 251 } catch (ProcessInitException e) { |
252 Log.e(TAG, "Failed to start browser process.", e); | 252 Log.e(TAG, "Failed to start browser process.", e); |
253 // The library failed to initialize and nothing in the application c
an work, so kill | 253 // The library failed to initialize and nothing in the application c
an work, so kill |
254 // the whole application. | 254 // the whole application. |
255 System.exit(-1); | 255 System.exit(-1); |
256 return; | 256 return; |
257 } | 257 } |
258 | 258 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 .setTitle(title) | 523 .setTitle(title) |
524 .setBody(body) | 524 .setBody(body) |
525 .setLargeIcon(ensureNormalizedIcon(icon, origin)) | 525 .setLargeIcon(ensureNormalizedIcon(icon, origin)) |
526 .setSmallIcon(R.drawable.ic_chrome) | 526 .setSmallIcon(R.drawable.ic_chrome) |
527 .setSmallIcon(badge) | 527 .setSmallIcon(badge) |
528 .setContentIntent(clickIntent) | 528 .setContentIntent(clickIntent) |
529 .setDeleteIntent(closeIntent) | 529 .setDeleteIntent(closeIntent) |
530 .setTicker(createTickerText(title, body)) | 530 .setTicker(createTickerText(title, body)) |
531 .setTimestamp(timestamp) | 531 .setTimestamp(timestamp) |
532 .setRenotify(renotify) | 532 .setRenotify(renotify) |
533 .setOrigin(UrlUtilities.formatUrlForSecurityDisplay( | 533 .setOrigin(UrlFormatter.formatUrlForSecurityDisplay( |
534 origin, false /* showScheme */)); | 534 origin, false /* showScheme */)); |
535 | 535 |
536 for (int actionIndex = 0; actionIndex < actionTitles.length; actionIndex
++) { | 536 for (int actionIndex = 0; actionIndex < actionTitles.length; actionIndex
++) { |
537 notificationBuilder.addAction(actionIcons[actionIndex], actionTitles
[actionIndex], | 537 notificationBuilder.addAction(actionIcons[actionIndex], actionTitles
[actionIndex], |
538 makePendingIntent(NotificationConstants.ACTION_CLICK_NOTIFIC
ATION, | 538 makePendingIntent(NotificationConstants.ACTION_CLICK_NOTIFIC
ATION, |
539 notificationId, origin, profil
eId, incognito, tag, | 539 notificationId, origin, profil
eId, incognito, tag, |
540 webApkPackage, actionIndex)); | 540 webApkPackage, actionIndex)); |
541 } | 541 } |
542 | 542 |
543 // If action buttons are displayed, there isn't room for the full Site S
ettings button | 543 // If action buttons are displayed, there isn't room for the full Site S
ettings button |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 731 |
732 private static native void nativeInitializeNotificationPlatformBridge(); | 732 private static native void nativeInitializeNotificationPlatformBridge(); |
733 | 733 |
734 private native void nativeOnNotificationClicked(long nativeNotificationPlatf
ormBridgeAndroid, | 734 private native void nativeOnNotificationClicked(long nativeNotificationPlatf
ormBridgeAndroid, |
735 String notificationId, String origin, String profileId, boolean inco
gnito, String tag, | 735 String notificationId, String origin, String profileId, boolean inco
gnito, String tag, |
736 String webApkPackage, int actionIndex); | 736 String webApkPackage, int actionIndex); |
737 private native void nativeOnNotificationClosed(long nativeNotificationPlatfo
rmBridgeAndroid, | 737 private native void nativeOnNotificationClosed(long nativeNotificationPlatfo
rmBridgeAndroid, |
738 String notificationId, String origin, String profileId, boolean inco
gnito, String tag, | 738 String notificationId, String origin, String profileId, boolean inco
gnito, String tag, |
739 boolean byUser); | 739 boolean byUser); |
740 } | 740 } |
OLD | NEW |