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

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

Issue 10134040: Add keybindings and webRequest examples to the transient background page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
index 6c65ba0b2a6b36f105df5a05fee3fa2b522c5992..48c5e0161145059e5dffcbadd1e3c5a238211602 100644
--- a/chrome/common/extensions/docs/examples/api/transientPage/basic/background.js
+++ b/chrome/common/extensions/docs/examples/api/transientPage/basic/background.js
@@ -19,10 +19,19 @@ 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;
- console.log("Installed.");
+
+ // 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) {
@@ -41,6 +50,10 @@ chrome.browserAction.onClicked.addListener(function() {
});
});
+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});

Powered by Google App Engine
This is Rietveld 408576698