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

Unified Diff: ui/aura_shell/launcher/launcher.cc

Issue 8289022: Wires keeping the launcher up to date with the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 years, 2 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
« no previous file with comments | « ui/aura_shell/launcher/launcher.h ('k') | ui/aura_shell/launcher/launcher_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/launcher/launcher.cc
diff --git a/ui/aura_shell/launcher/launcher.cc b/ui/aura_shell/launcher/launcher.cc
index 5cb6a131c4b40c34775e9a5e31e5ac32747db8d1..d2551cd6e10e2af08dbac0063b776cb62d3836bf 100644
--- a/ui/aura_shell/launcher/launcher.cc
+++ b/ui/aura_shell/launcher/launcher.cc
@@ -43,25 +43,44 @@ Launcher::~Launcher() {
window_container_->RemoveObserver(this);
}
-void Launcher::OnWindowAdded(aura::Window* new_window) {
+void Launcher::MaybeAdd(aura::Window* window) {
+ if (known_windows_[window] == true)
+ return; // We already tried to add this window.
+
+ known_windows_[window] = true;
ShellDelegate* delegate = Shell::GetInstance()->delegate();
if (!delegate)
return;
LauncherItem item;
- item.window = new_window;
+ item.window = window;
if (!delegate->ConfigureLauncherItem(&item))
return; // The delegate doesn't want to show this item in the launcher.
model_->Add(model_->items().size(), item);
}
+void Launcher::OnWindowAdded(aura::Window* new_window) {
+ DCHECK(known_windows_.find(new_window) == known_windows_.end());
+ known_windows_[new_window] = false;
+ new_window->AddObserver(this);
+ // Windows are created initially invisible. Wait until the window is made
+ // visible before asking, as othewise the delegate likely doesn't know about
+ // window (it's still creating it).
+ if (new_window->IsVisible())
+ MaybeAdd(new_window);
+}
+
void Launcher::OnWillRemoveWindow(aura::Window* window) {
- const LauncherItems& items(model_->items());
- for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) {
- if (i->window == window) {
- model_->RemoveItemAt(i - items.begin());
- break;
- }
- }
+ window->RemoveObserver(this);
+ known_windows_.erase(window);
+ LauncherItems::const_iterator i = model_->ItemByWindow(window);
+ if (i != model_->items().end())
+ model_->RemoveItemAt(i - model_->items().begin());
+}
+
+void Launcher::OnWindowVisibilityChanged(aura::Window* window,
+ bool visibile) {
+ if (visibile && !known_windows_[window])
+ MaybeAdd(window);
}
} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/launcher/launcher.h ('k') | ui/aura_shell/launcher/launcher_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698