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

Unified Diff: chrome/common/extensions/docs/examples/api/transientPage/basic/background.js

Issue 10280005: Fix the event page sample extension to say "event page". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: docgen Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/api/transientPage/basic/background.js
diff --git a/chrome/common/extensions/docs/examples/api/transientPage/basic/background.js b/chrome/common/extensions/docs/examples/api/transientPage/basic/background.js
deleted file mode 100644
index 48c5e0161145059e5dffcbadd1e3c5a238211602..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/docs/examples/api/transientPage/basic/background.js
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Global variables only exist for the life of the page, so they get reset
-// each time the page is unloaded.
-var counter = 1;
-
-var lastTabId = -1;
-function sendMessage() {
- chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
- lastTabId = tabs[0].id;
- chrome.tabs.sendMessage(lastTabId, "Background page started.");
- });
-}
-
-sendMessage();
-chrome.browserAction.setBadgeText({text: "ON"});
-console.log("Loaded.");
-
-chrome.experimental.runtime.onInstalled.addListener(function() {
- console.log("Installed.");
-
- // localStorage is persisted, so it's a good place to keep state that you
- // need to persist across page reloads.
- localStorage.counter = 1;
-
- // Register a webRequest rule to redirect bing to google.
- var wr = chrome.experimental.webRequest;
- chrome.experimental.webRequest.onRequest.addRules([{
- id: "0",
- conditions: [new wr.RequestMatcher({url: {hostSuffix: "bing.com"}})],
- actions: [new wr.RedirectRequest({redirectUrl: "http://google.com"})]
- }]);
-});
-
-chrome.bookmarks.onRemoved.addListener(function(id, info) {
- alert("I never liked that site anyway.");
-});
-
-chrome.browserAction.onClicked.addListener(function() {
- // The transient page will unload after handling this event (assuming nothing
- // else is keeping it awake). The content script will become the main way to
- // interact with us.
- chrome.tabs.executeScript({file: "content.js"}, function() {
- // Note: we also sent a message above, upon loading the transient page,
- // but the content script will not be loaded at that point, so we send
- // another here.
- sendMessage();
- });
-});
-
-chrome.experimental.keybinding.onCommand.addListener(function(command) {
- chrome.tabs.create({url: "http://www.google.com/"});
-});
-
-chrome.extension.onMessage.addListener(function(msg, _, sendResponse) {
- if (msg.setAlarm) {
- chrome.experimental.alarms.create({delayInSeconds: 5});
- } else if (msg.delayedResponse) {
- // Note: setTimeout itself does NOT keep the page awake. We return true
- // from the onMessage event handler, which keeps the message channel open -
- // in turn keeping the transient page awake - until we call sendResponse.
- setTimeout(function() {
- sendResponse("Got your message.");
- }, 5000);
- return true;
- } else if (msg.getCounters) {
- sendResponse({counter: counter++,
- persistentCounter: localStorage.counter++});
- }
- // If we don't return anything, the message channel will close, regardless
- // of whether we called sendResponse.
-});
-
-chrome.experimental.alarms.onAlarm.addListener(function() {
- alert("Time's up!");
-});
-
-chrome.experimental.runtime.onBackgroundPageUnloadingSoon.addListener(
- function() {
- chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
- // After the unload event listener runs, the page will unload, so any
- // asynchronous callbacks will not fire.
- alert("This does not show up.");
- });
- console.log("Unloading.");
- chrome.browserAction.setBadgeText({text: ""});
- chrome.tabs.sendMessage(lastTabId, "Background page unloaded.");
-});

Powered by Google App Engine
This is Rietveld 408576698