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

Unified Diff: chrome/common/extensions/docs/examples/apps/calculator/app/controller.js

Issue 11316346: Make calculator app handle onRestarted events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update variable names Created 8 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/apps/calculator/app/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/apps/calculator/app/controller.js
diff --git a/chrome/common/extensions/docs/examples/apps/calculator/app/controller.js b/chrome/common/extensions/docs/examples/apps/calculator/app/controller.js
index 52d6458761bd9ed3c5119d864383db45f2f0c913..a3998d7b12b0a897f57e02b9944ed07831be6c73 100644
--- a/chrome/common/extensions/docs/examples/apps/calculator/app/controller.js
+++ b/chrome/common/extensions/docs/examples/apps/calculator/app/controller.js
@@ -10,7 +10,7 @@
// in non-Chrome browsers, which is useful for example to test touch support
// with a non-Chrome touch device.
if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
- chrome.app.runtime.onLaunched.addListener(function() {
+ var showCalculatorWindow = function () {
chrome.app.window.create('calculator.html', {
defaultWidth: 243, minWidth: 243, maxWidth: 243,
defaultHeight: 380, minHeight: 380, maxHeight: 380,
@@ -19,6 +19,19 @@ if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
appWindow.contentWindow.onload = function() {
new Controller(new Model(9), new View(appWindow.contentWindow));
};
+
+ chrome.storage.local.set({windowVisible: true});
+ appWindow.onClosed.addListener(function() {
+ chrome.storage.local.set({windowVisible: false});
+ });
+ });
+ }
+
+ chrome.app.runtime.onLaunched.addListener(showCalculatorWindow);
+ chrome.app.runtime.onRestarted.addListener(function() {
+ chrome.storage.local.get('windowVisible', function(data) {
+ if (data.windowVisible)
+ showCalculatorWindow();
});
});
}
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/apps/calculator/app/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698