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

Unified Diff: chrome/common/extensions/docs/examples/extensions/storage_api_devtools/test/content_scripts/2/script.js

Issue 12760009: Write a devtools extension to inspect chrome.storage data Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: small fixes Created 7 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/extensions/storage_api_devtools/test/content_scripts/2/script.js
===================================================================
--- chrome/common/extensions/docs/examples/extensions/storage_api_devtools/test/content_scripts/2/script.js (revision 0)
+++ chrome/common/extensions/docs/examples/extensions/storage_api_devtools/test/content_scripts/2/script.js (revision 0)
@@ -0,0 +1,36 @@
+chrome.storage.sync.set({test_2:
+ 'the quick brown fox jumps over the lazy dog.'});
+
+chrome.storage.sync.get('href_2', function(items) {
+ console.log(items);
+ chrome.storage.sync.set({'href_2': location.href});
+});
+
+var lastX, lastY;
+var handling = false;
+
+window.addEventListener('mousemove', function(e) {
+ if(handling)
+ return;
+ if(lastX == undefined) {
+ lastX = e.x;
+ lastY = e.y;
+ } else {
+ handling = true;
+ chrome.storage.local.set({x: e.x, y: e.y, lastX: lastX, lastY: lastY});
+ chrome.storage.local.get('distance', function(items) {
+ if(!items['distance'])
+ items['distance'] = 0;
+ var deltaX = e.x - lastX;
+ var deltaY = e.y - lastY;
+ var delta = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ items['distance'] += delta;
+ chrome.storage.local.set(items, function() {
+ lastX = e.x;
+ lastY = e.y;
+ handling = false;
+ });
+ });
+ }
+});
+
Property changes on: chrome/common/extensions/docs/examples/extensions/storage_api_devtools/test/content_scripts/2/script.js
___________________________________________________________________
Added: svn:mime-type
+ text/javascript
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698