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

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/catifier/event_page.js

Issue 11745015: Update references to the extension messaging APIs to point to the "runtime" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Sample extension to replace all JPEG images (but no PNG/GIF/... images) with 5 // Sample extension to replace all JPEG images (but no PNG/GIF/... images) with
6 // lolcat images from http://icanhascheezburger.com/ - except for images on 6 // lolcat images from http://icanhascheezburger.com/ - except for images on
7 // Google. 7 // Google.
8 8
9 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher; 9 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
10 var IgnoreRules = chrome.declarativeWebRequest.IgnoreRules; 10 var IgnoreRules = chrome.declarativeWebRequest.IgnoreRules;
(...skipping 29 matching lines...) Expand all
40 conditions: [ 40 conditions: [
41 // We use hostContains to compensate for various top-level domains. 41 // We use hostContains to compensate for various top-level domains.
42 new RequestMatcher({url: {hostContains: '.google.'}}) 42 new RequestMatcher({url: {hostContains: '.google.'}})
43 ], 43 ],
44 actions: [ 44 actions: [
45 new IgnoreRules({lowerPriorityThan: 1000}) 45 new IgnoreRules({lowerPriorityThan: 1000})
46 ] 46 ]
47 }; 47 };
48 48
49 var callback = function() { 49 var callback = function() {
50 if (chrome.extension.lastError) { 50 if (chrome.runtime.lastError) {
51 console.error('Error adding rules: ' + chrome.extension.lastError); 51 console.error('Error adding rules: ' + chrome.runtime.lastError);
52 } else { 52 } else {
53 console.info('Rules successfully installed'); 53 console.info('Rules successfully installed');
54 chrome.declarativeWebRequest.onRequest.getRules(null, 54 chrome.declarativeWebRequest.onRequest.getRules(null,
55 function(rules) { 55 function(rules) {
56 console.info('Now the following rules are registered: ' + 56 console.info('Now the following rules are registered: ' +
57 JSON.stringify(rules, null, 2)); 57 JSON.stringify(rules, null, 2));
58 }); 58 });
59 } 59 }
60 }; 60 };
61 61
62 chrome.declarativeWebRequest.onRequest.addRules( 62 chrome.declarativeWebRequest.onRequest.addRules(
63 [redirectRule, exceptionRule], callback); 63 [redirectRule, exceptionRule], callback);
64 } 64 }
65 65
66 function setup() { 66 function setup() {
67 // This function is also called when the extension has been updated. Because 67 // This function is also called when the extension has been updated. Because
68 // registered rules are persisted beyond browser restarts, we remove 68 // registered rules are persisted beyond browser restarts, we remove
69 // previously registered rules before registering new ones. 69 // previously registered rules before registering new ones.
70 chrome.declarativeWebRequest.onRequest.removeRules( 70 chrome.declarativeWebRequest.onRequest.removeRules(
71 null, 71 null,
72 function() { 72 function() {
73 if (chrome.extension.lastError) { 73 if (chrome.runtime.lastError) {
74 console.error('Error clearing rules: ' + chrome.extension.lastError); 74 console.error('Error clearing rules: ' + chrome.runtime.lastError);
75 } else { 75 } else {
76 registerRules(); 76 registerRules();
77 } 77 }
78 }); 78 });
79 } 79 }
80 80
81 // This is triggered when the extension is installed or updated. 81 // This is triggered when the extension is installed or updated.
82 chrome.runtime.onInstalled.addListener(setup); 82 chrome.runtime.onInstalled.addListener(setup);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698