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

Side by Side Diff: chrome/browser/chromeos/wm_overview_controller.h

Issue 661237: This adds in the ability for Chrome to generate windows with snapshots of all... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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
« no previous file with comments | « chrome/browser/chromeos/wm_ipc.cc ('k') | chrome/browser/chromeos/wm_overview_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_WM_OVERVIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_WM_OVERVIEW_CONTROLLER_H_
7
8 #include <vector>
9
10 #include "base/linked_ptr.h"
11 #include "base/singleton.h"
12 #include "base/timer.h"
13 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/chromeos/wm_message_listener.h"
15 #include "chrome/common/notification_registrar.h"
16 #include "gfx/rect.h"
17
18 namespace views {
19 class Widget;
20 }
21
22 class Animation;
23 class Browser;
24
25 namespace chromeos {
26
27 class BrowserListener;
28 class WmOverviewSnapshot;
29
30 // WmOverviewController is responsible for managing a list of objects
31 // that listen to the browsers (BrowserListeners, defined in the
32 // source file for this class) for changes, and keep a list of
33 // snapshot images in sync with the browser tab contents.
34 //
35 // As tabs are added/removed from the browsers, the number of snapshot
36 // windows changes to match.
37 //
38 // As obtaining and setting snapshots is expensive we delay setting
39 // the snapshot. The delay is controlled by delay_timer_. Once the
40 // timer fires another timer is started (configure_timer_). This timer
41 // invokes ConfigureNextUnconfiguredCell on the BrowserListener, which
42 // obtains and sets the snapshot of the next uncofigured
43 // cell. ConfigureNextUnconfiguredCell only configures one cell at a
44 // time until they are all configured.
45
46 class WmOverviewController : public BrowserList::Observer,
47 public WmMessageListener::Observer,
48 public NotificationObserver {
49 public:
50 // This class is a singleton.
51 static WmOverviewController* instance();
52
53 // BrowserList::Observer methods
54 // This is called immediately after a browser is added to the list.
55 void OnBrowserAdded(const Browser* browser) {}
56
57 // This is called immediately before a browser is removed from the list.
58 void OnBrowserRemoving(const Browser* browser);
59 // End BrowserList::Observer methods
60
61 // WmMessageListener::Observer methods
62 // This is called immediately after a browser is added to the list.
63 void ProcessWmMessage(const WmIpc::Message& message,
64 GdkWindow* window);
65 // End WmMessageListener::Observer methods
66
67 // NotificationObserver methods
68 void Observe(NotificationType type,
69 const NotificationSource& source,
70 const NotificationDetails& details);
71 // End NotificationObserver methods
72
73 // Used by the BrowserListeners to configure their snapshots.
74 const gfx::Rect& monitor_bounds() const { return monitor_bounds_; }
75
76 // Tells the listeners whether or not they're allowed to show
77 // snapshots yet.
78 bool allow_show_snapshots() const { return allow_show_snapshots_; }
79
80 // Starts the delay timer, and once the delay is over, configures
81 // any unconfigured snapshots one at a time until none are left to
82 // be configured.
83 void StartDelayTimer();
84
85 private:
86 friend struct DefaultSingletonTraits<WmOverviewController>;
87
88 // This class is a singleton.
89 WmOverviewController();
90 ~WmOverviewController();
91
92 // Restores tab selections on all browsers to what they were when
93 // Show was last called. Used when cancelling overview mode.
94 void RestoreTabSelections();
95
96 // Saves the currently selected tabs in the snapshots so that they
97 // can be restored later with RestoreTabSelections.
98 void SaveTabSelections();
99
100 // Show the snapshot windows, saving current tab selections.
101 void Show();
102
103 // Hide the snapshot windows. When |cancelled| is true, then the
104 // tab selections that were saved when the snapshot windows were
105 // shown are restored.
106 void Hide(bool cancelled);
107
108 // Invoked by delay_timer_. Sets allow_show_snapshots_ to true and starts
109 // configure_timer_.
110 void StartConfiguring();
111
112 // Configure the next unconfigured snapshot window owned by any of
113 // the listeners.
114 void ConfigureNextUnconfiguredSnapshot();
115
116 // Add browser listeners for all existing browsers, reusing any that
117 // were already there.
118 void AddAllBrowsers();
119
120 // This is so we can register for notifications.
121 NotificationRegistrar registrar_;
122
123 // This is a vector of listeners that listen to all the browsers.
124 typedef std::vector<linked_ptr<BrowserListener> > BrowserListenerVector;
125 BrowserListenerVector listeners_;
126
127 // This is the bounds of the monitor we're being displayed on. This
128 // is used to adjust the size of snapshots so they'll fit.
129 gfx::Rect monitor_bounds_;
130
131 // This indicates whether we should actually set the snapshots so we
132 // don't do it when we don't need to. It is initially false, then
133 // set to true by StartConfiguring.
134 bool allow_show_snapshots_;
135
136 // See description above class for details.
137 base::OneShotTimer<WmOverviewController> delay_timer_;
138
139 // See description above class for details.
140 base::RepeatingTimer<WmOverviewController> configure_timer_;
141
142 DISALLOW_COPY_AND_ASSIGN(WmOverviewController);
143 };
144
145 } // namespace chromeos
146
147 #endif // CHROME_BROWSER_CHROMEOS_WM_OVERVIEW_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/wm_ipc.cc ('k') | chrome/browser/chromeos/wm_overview_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698