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

Unified Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/background.js

Issue 10698099: Implement the new wallpaper manager launcher window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flackr's review Created 8 years, 5 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/browser/resources/chromeos/wallpaper_manager/js/background.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/background.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..310f5f5fa89e0a9608efb77f4143fd1ee7f86118
--- /dev/null
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/background.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 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.
+
+function WindowStateManager() {
+ this.savedWindow = [];
+}
+
+/**
+ * Minimize all opening windows and save their states.
+ */
+WindowStateManager.prototype.saveStates = function() {
+ var focusedWindowId;
+ chrome.windows.getLastFocused(function(focusedWindow) {
+ focusedWindowId = focusedWindow.id;
+ });
+ this.savedWindow = [];
+ var self = this;
+ chrome.windows.getAll(null, function(windows) {
+ for (var i in windows) {
+ if (windows[i].state != 'minimized')
+ self.savedWindow.push(windows[i]);
+ if (windows[i].id != focusedWindowId)
+ chrome.windows.update(windows[i].id, {'state': 'minimized'},
+ function() {});
+ }
+ });
+};
+
+/**
+ * Restore the states of all windows.
+ */
+WindowStateManager.prototype.restoreStates = function() {
+ var self = this;
+ chrome.windows.getAll(null, function(windows) {
+ for (var i in windows) {
+ for (var j in self.savedWindow) {
flackr 2012/07/06 12:28:53 You can probably avoid the need for a background p
bshe 2012/07/06 18:58:06 Done. Also added a focus event listener. So when t
+ if (windows[i].id == self.savedWindow[j].id) {
+ var state = self.savedWindow[j].state;
+ chrome.windows.update(windows[i].id, {'state': state},
+ function() {});
+ }
+ }
+ }
+ });
+};
+
+var windowStateManager = new WindowStateManager();

Powered by Google App Engine
This is Rietveld 408576698