Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / examples / api / notifications / background.js
index 646063e..cbe9d53 100644 (file)
@@ -5,18 +5,16 @@
 /*
   Displays a notification with the current time. Requires "notifications"
   permission in the manifest file (or calling
-  "webkitNotifications.requestPermission" beforehand).
+  "Notification.requestPermission" beforehand).
 */
 function show() {
   var time = /(..)(:..)/.exec(new Date());     // The prettyprinted time.
   var hour = time[1] % 12 || 12;               // The prettyprinted hour.
   var period = time[1] < 12 ? 'a.m.' : 'p.m.'; // The period of the day.
-  var notification = window.webkitNotifications.createNotification(
-    '48.png',                      // The image.
-    hour + time[2] + ' ' + period, // The title.
-    'Time to make the toast.'      // The body.
-  );
-  notification.show();
+  new Notification(hour + time[2] + ' ' + period, {
+    icon: '48.png',
+    body: 'Time to make the toast.'
+  });
 }
 
 // Conditionally initialize the options.
@@ -27,7 +25,7 @@ if (!localStorage.isInitialized) {
 }
 
 // Test for notification support.
-if (window.webkitNotifications) {
+if (window.Notification) {
   // While activated, show notifications at the display frequency.
   if (JSON.parse(localStorage.isActivated)) { show(); }