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

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

Issue 10698099: Implement the new wallpaper manager launcher window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk 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/window_state_manager.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/window_state_manager.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/window_state_manager.js
new file mode 100644
index 0000000000000000000000000000000000000000..02853c5207d608984de2ee6ff84472dd0011d94b
--- /dev/null
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/window_state_manager.js
@@ -0,0 +1,55 @@
+// 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;
+ });
+ var self = this;
+ chrome.windows.getAll(null, function(windows) {
+ for (var i in windows) {
+ if (windows[i].state != 'minimized')
flackr 2012/07/09 21:29:58 You should probably add this to the following cond
bshe 2012/07/10 01:39:22 Done.
+ 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() {
+ for (var i in this.savedWindow) {
+ var state = this.savedWindow[i].state;
+ chrome.windows.update(this.savedWindow[i].id, {'state': state},
+ function() {});
+ }
+};
+
+/**
+ * Remove the saved state of the current focused window.
+ */
+WindowStateManager.prototype.removeSavedState = function(windowId) {
+ for (var i in this.savedWindow) {
+ if (windowId == this.savedWindow[i].id)
+ this.savedWindow.splice(i, 1);
+ }
+};
+
+var windowStateManager = new WindowStateManager();
+
+// If a window gets focused before wallpaper manager close. The saved state
+// is no longer correct.
+chrome.windows.onFocusChanged.addListener(
+ windowStateManager.removeSavedState.bind(windowStateManager));

Powered by Google App Engine
This is Rietveld 408576698