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

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/plugin_settings/js/chrome_stubs.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 /** 5 /**
6 * @fileoverview Stubs for Chrome extension APIs that aren't available to 6 * @fileoverview Stubs for Chrome extension APIs that aren't available to
7 * regular web pages, to allow tests to run. 7 * regular web pages, to allow tests to run.
8 */ 8 */
9 9
10 chrome = chrome || {}; 10 chrome = chrome || {};
11 chrome.extension = chrome.extension || {}; 11 chrome.extension = chrome.extension || {};
12 chrome.contentSettings = chrome.contentSettings || {}; 12 chrome.contentSettings = chrome.contentSettings || {};
13 13
14 var _rules = {}; 14 var _rules = {};
15 chrome.contentSettings.plugins = { 15 chrome.contentSettings.plugins = {
16 'set': function(details, callback) { 16 'set': function(details, callback) {
17 assertObjectEquals({'id': 'myplugin'}, details.resourceIdentifier); 17 assertObjectEquals({'id': 'myplugin'}, details.resourceIdentifier);
18 var pattern = details.primaryPattern; 18 var pattern = details.primaryPattern;
19 var setting = details.setting; 19 var setting = details.setting;
20 if (pattern == '__invalid_pattern') { 20 if (pattern == '__invalid_pattern') {
21 chrome.extension.lastError = {'message': 'Invalid pattern'}; 21 chrome.runtime.lastError = {'message': 'Invalid pattern'};
22 } else if (setting == '__invalid_setting') { 22 } else if (setting == '__invalid_setting') {
23 throw Error('Invalid setting'); 23 throw Error('Invalid setting');
24 } else { 24 } else {
25 chrome.extension.lastError = undefined; 25 chrome.runtime.lastError = undefined;
26 _rules[pattern] = setting; 26 _rules[pattern] = setting;
27 } 27 }
28 callback(); 28 callback();
29 }, 29 },
30 30
31 'clear': function(details, callback) { 31 'clear': function(details, callback) {
32 assertObjectEquals({}, details); 32 assertObjectEquals({}, details);
33 _rules = {}; 33 _rules = {};
34 callback(); 34 callback();
35 } 35 }
(...skipping 23 matching lines...) Expand all
59 function createSettings(rules) { 59 function createSettings(rules) {
60 var settings = new pluginSettings.Settings('myplugin'); 60 var settings = new pluginSettings.Settings('myplugin');
61 if (rules) { 61 if (rules) {
62 for (var pattern in rules) { 62 for (var pattern in rules) {
63 settings.set(pattern, rules[pattern], function() {}); 63 settings.set(pattern, rules[pattern], function() {});
64 } 64 }
65 } 65 }
66 return settings; 66 return settings;
67 } 67 }
68 68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698