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

Side by Side Diff: chrome/common/extensions/docs/examples/api/storage/stylizr/popup.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 // Store CSS data in the "local" storage area. 5 // Store CSS data in the "local" storage area.
6 // 6 //
7 // See note in options.js for rationale on why not to use "sync". 7 // See note in options.js for rationale on why not to use "sync".
8 var storage = chrome.storage.local; 8 var storage = chrome.storage.local;
9 9
10 var message = document.querySelector('#message'); 10 var message = document.querySelector('#message');
11 11
12 // Check if there is CSS specified. 12 // Check if there is CSS specified.
13 storage.get('css', function(items) { 13 storage.get('css', function(items) {
14 console.log(items); 14 console.log(items);
15 // If there is CSS specified, inject it into the page. 15 // If there is CSS specified, inject it into the page.
16 if (items.css) { 16 if (items.css) {
17 chrome.tabs.insertCSS(null, {code: items.css}, function() { 17 chrome.tabs.insertCSS(null, {code: items.css}, function() {
18 if (chrome.extension.lastError) { 18 if (chrome.runtime.lastError) {
19 message.innerText = 'Not allowed to inject CSS into special page.'; 19 message.innerText = 'Not allowed to inject CSS into special page.';
20 } else { 20 } else {
21 message.innerText = 'Injected style!'; 21 message.innerText = 'Injected style!';
22 } 22 }
23 }); 23 });
24 } else { 24 } else {
25 var optionsUrl = chrome.extension.getURL('options.html'); 25 var optionsUrl = chrome.extension.getURL('options.html');
26 message.innerHTML = 'Set a style in the <a target="_blank" href="' + 26 message.innerHTML = 'Set a style in the <a target="_blank" href="' +
27 optionsUrl + '">options page</a> first.'; 27 optionsUrl + '">options page</a> first.';
28 } 28 }
29 }); 29 });
30 30
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698