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

Unified Diff: chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js

Issue 8916013: Added storage sample. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Storage sample and built devtools docs changes. Created 9 years 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/storage/stylizr/popup.js
diff --git a/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js b/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js
new file mode 100644
index 0000000000000000000000000000000000000000..4877eb9b550c19d177540765f4c54c8278fad7e6
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 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.
+
+// Store settings in the local, un-synchronized repository.
not at google - send to devlin 2011/12/14 23:04:13 Why not use the synced storage? An interesting fe
not at google - send to devlin 2011/12/14 23:16:07 Or just always use sync, local should be an except
Boris Smus 2011/12/14 23:29:35 Switched to sync for now. Option could be interest
+var storage = chrome.experimental.storage.local;
+var message = document.querySelector('#message');
+
+// Check if there is CSS specified.
+storage.get('css', function(items) {
+ console.log(items);
+ // If there is CSS specified, inject it into the page.
+ if (items.css) {
+ chrome.tabs.insertCSS(null, {code: items.css}, function() {
+ if (chrome.extension.lastError) {
+ message.innerText = 'Not allowed to inject CSS into special page.';
+ }
+ message.innerText = 'Injected style!';
not at google - send to devlin 2011/12/14 23:04:13 shouldn't this be in an else, or a "return" after
Boris Smus 2011/12/14 23:29:35 Done.
+ });
+ } else {
+ var optionsUrl = chrome.extension.getURL('options.html');
+ message.innerHTML = 'Set a style in the <a target="_blank" href="' +
+ optionsUrl + '">options page</a> first.';
+ }
+});
+

Powered by Google App Engine
This is Rietveld 408576698