Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shell/window_watcher.h" | 5 #include "ash/shell/window_watcher.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | |
| 10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 11 | 12 |
| 12 namespace ash { | 13 namespace ash { |
| 13 namespace shell { | 14 namespace shell { |
| 14 | 15 |
| 15 WindowWatcher::WindowWatcher() | 16 WindowWatcher::WindowWatcher() |
| 16 : window_(ash::Shell::GetInstance()->launcher()->window_container()) { | 17 : window_(ash::Shell::GetInstance()->launcher()->window_container()), |
| 18 panel_container_(ash::Shell::GetInstance()->GetContainer( | |
| 19 ash::internal::kShellWindowId_PanelContainer)) { | |
| 17 window_->AddObserver(this); | 20 window_->AddObserver(this); |
| 21 panel_container_->AddObserver(this); | |
| 18 } | 22 } |
| 19 | 23 |
| 20 WindowWatcher::~WindowWatcher() { | 24 WindowWatcher::~WindowWatcher() { |
| 21 window_->RemoveObserver(this); | 25 window_->RemoveObserver(this); |
| 22 } | 26 } |
| 23 | 27 |
| 24 aura::Window* WindowWatcher::GetWindowByID(ash::LauncherID id) { | 28 aura::Window* WindowWatcher::GetWindowByID(ash::LauncherID id) { |
| 25 IDToWindow::const_iterator i = id_to_window_.find(id); | 29 IDToWindow::const_iterator i = id_to_window_.find(id); |
| 26 return i != id_to_window_.end() ? i->second : NULL; | 30 return i != id_to_window_.end() ? i->second : NULL; |
| 27 } | 31 } |
| 28 | 32 |
| 29 ash::LauncherID WindowWatcher::GetIDByWindow(aura::Window* window) const { | 33 ash::LauncherID WindowWatcher::GetIDByWindow(aura::Window* window) const { |
| 30 for (IDToWindow::const_iterator i = id_to_window_.begin(); | 34 for (IDToWindow::const_iterator i = id_to_window_.begin(); |
| 31 i != id_to_window_.end(); ++i) { | 35 i != id_to_window_.end(); ++i) { |
| 32 if (i->second == window) | 36 if (i->second == window) |
| 33 return i->first; | 37 return i->first; |
| 34 } | 38 } |
| 35 return 0; // TODO: add a constant for this. | 39 return 0; // TODO: add a constant for this. |
| 36 } | 40 } |
| 37 | 41 |
| 38 // aura::WindowObserver overrides: | 42 // aura::WindowObserver overrides: |
| 39 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { | 43 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { |
| 40 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL) | 44 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL |
| 45 && new_window->type() != aura::client::WINDOW_TYPE_PANEL) | |
|
sky
2012/04/03 20:39:37
&& on the previous line.
| |
| 41 return; | 46 return; |
| 42 | 47 |
| 43 static int image_count = 0; | 48 static int image_count = 0; |
| 44 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); | 49 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); |
| 45 ash::LauncherItem item; | 50 ash::LauncherItem item; |
| 46 item.type = ash::TYPE_TABBED; | 51 item.type = ash::TYPE_TABBED; |
| 47 id_to_window_[model->next_id()] = new_window; | 52 id_to_window_[model->next_id()] = new_window; |
| 48 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 53 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); |
| 49 item.image.allocPixels(); | 54 item.image.allocPixels(); |
| 50 item.image.eraseARGB(255, | 55 item.image.eraseARGB(255, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 65 DCHECK_NE(-1, index); | 70 DCHECK_NE(-1, index); |
| 66 model->RemoveItemAt(index); | 71 model->RemoveItemAt(index); |
| 67 id_to_window_.erase(i); | 72 id_to_window_.erase(i); |
| 68 break; | 73 break; |
| 69 } | 74 } |
| 70 } | 75 } |
| 71 } | 76 } |
| 72 | 77 |
| 73 } // namespace shell | 78 } // namespace shell |
| 74 } // namespace ash | 79 } // namespace ash |
| OLD | NEW |