Index: chrome/common/extensions/docs/examples/api/screenlockPrivate/weblocker/bg.js |
diff --git a/chrome/common/extensions/docs/examples/api/screenlockPrivate/weblocker/bg.js b/chrome/common/extensions/docs/examples/api/screenlockPrivate/weblocker/bg.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..17abfffd4f4f0a1c5373d373b6f609c2f3d47a36 |
--- /dev/null |
+++ b/chrome/common/extensions/docs/examples/api/screenlockPrivate/weblocker/bg.js |
@@ -0,0 +1,22 @@ |
+function webunlock() { |
+ var xhr = new XMLHttpRequest(); |
+ xhr.onreadystatechange = function() { |
+ if (xhr.readyState != 4) return; |
+ window.setTimeout(webunlock, 2000); |
+ if (xhr.status != 200) return; |
+ var should_be_locked = (xhr.responseText == 'LOCK'); |
+ chrome.screenlockPrivate.getLocked(function(is_locked) { |
+ console.log('should=' + should_be_locked + ' is=' + is_locked); |
+ if (is_locked != should_be_locked) { |
+ chrome.screenlockPrivate.setLocked(should_be_locked); |
+ } |
+ }); |
+ } |
+ xhr.open('get', 'http://scrap.mtv.corp.google.com:54329/value', true); |
Matt Perry
2013/11/13 01:01:14
I wouldn't check this in with a reference to a cor
Matt Perry
2013/11/13 01:01:14
Do you need this example now that there's an API t
benjhayden
2013/11/13 17:17:51
Done.
benjhayden
2013/11/13 17:17:51
Done.
|
+ xhr.send(); |
+} |
+webunlock(); |
+ |
+chrome.screenlockPrivate.onChanged.addListener(function(locked) { |
+ console.log('The screen is now ' + (locked ? '' : 'un') + 'locked.'); |
+}); |