Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/test/data/extensions/background_app/background.js

Issue 1018643003: Removing chrome.pushMessaging API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to documentation per kalman's comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This is a minimal sample of a Apps V2 app with background permission. 5 // This is a minimal sample of a Apps V2 app with background permission.
6 // 6 //
7 // This function gets called in the packaged app model on launch. 7 // This function gets called in the packaged app model on launch.
8 chrome.app.runtime.onLaunched.addListener(function() { 8 chrome.app.runtime.onLaunched.addListener(function() {
9 console.log("Background App Launched!"); 9 console.log("Background App Launched!");
10 10
11 // We'll set up push messaging so we have something to keep the background 11 // We'll set up push messaging so we have something to keep the background
12 // app registered. 12 // app registered.
13 setupPush(); 13 setupPush();
14 }); 14 });
15 15
16 // This function gets called in the packaged app model on install. 16 // This function gets called in the packaged app model on install.
17 chrome.runtime.onInstalled.addListener(function() { 17 chrome.runtime.onInstalled.addListener(function() {
18 console.log("Background App installed!"); 18 console.log("Background App installed!");
19 }); 19 });
20 20
21 // This function gets called in the packaged app model on shutdown. 21 // This function gets called in the packaged app model on shutdown.
22 chrome.runtime.onSuspend.addListener(function() { 22 chrome.runtime.onSuspend.addListener(function() {
23 console.log("Background App shutting down"); 23 console.log("Background App shutting down");
24 }); 24 });
25
26 // Register for push messages.
27 // This should be called every time the Push Messaging App starts up.
28 function setupPush() {
29 chrome.pushMessaging.onMessage.addListener(messageCallback);
30
31 // Ensure that adding the listener took effect.
32 var listeners = chrome.pushMessaging.onMessage.hasListeners();
33 console.log('registered listener for push messages ' + listeners);
34 }
35
36 // This callback receives the pushed message from the push server.
37 function messageCallback(message) {
38 console.log("push messaging callback seen");
39 }
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/stubs_app/manifest.json ('k') | chrome/test/ext_auto/auto_provider/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698