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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function WindowStateManager() {
6 this.savedWindow = [];
7 }
8
9 /**
10 * Minimize all opening windows and save their states.
11 */
12 WindowStateManager.prototype.saveStates = function() {
13 var focusedWindowId;
14 chrome.windows.getLastFocused(function(focusedWindow) {
15 focusedWindowId = focusedWindow.id;
16 });
17 var self = this;
18 chrome.windows.getAll(null, function(windows) {
19 for (var i in windows) {
20 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.
21 self.savedWindow.push(windows[i]);
22 if (windows[i].id != focusedWindowId)
23 chrome.windows.update(windows[i].id, {'state': 'minimized'},
24 function() {});
25 }
26 });
27 };
28
29 /**
30 * Restore the states of all windows.
31 */
32 WindowStateManager.prototype.restoreStates = function() {
33 for (var i in this.savedWindow) {
34 var state = this.savedWindow[i].state;
35 chrome.windows.update(this.savedWindow[i].id, {'state': state},
36 function() {});
37 }
38 };
39
40 /**
41 * Remove the saved state of the current focused window.
42 */
43 WindowStateManager.prototype.removeSavedState = function(windowId) {
44 for (var i in this.savedWindow) {
45 if (windowId == this.savedWindow[i].id)
46 this.savedWindow.splice(i, 1);
47 }
48 };
49
50 var windowStateManager = new WindowStateManager();
51
52 // If a window gets focused before wallpaper manager close. The saved state
53 // is no longer correct.
54 chrome.windows.onFocusChanged.addListener(
55 windowStateManager.removeSavedState.bind(windowStateManager));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698