| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_delegate.h" | 8 #include "ash/launcher/launcher_delegate.h" |
| 9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
| 10 #include "ash/launcher/launcher_types.h" | 10 #include "ash/launcher/launcher_types.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_delegate.h" | 12 #include "ash/shell_delegate.h" |
| 13 #include "ash/shell_factory.h" | 13 #include "ash/shell_factory.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/shell/example_factory.h" | 15 #include "ash/shell/example_factory.h" |
| 16 #include "ash/shell/toplevel_window.h" | 16 #include "ash/shell/toplevel_window.h" |
| 17 #include "ash/shell/shell_main_parts.h" | 17 #include "ash/shell/shell_main_parts.h" |
| 18 #include "ash/wm/partial_screenshot_view.h" | 18 #include "ash/wm/partial_screenshot_view.h" |
| 19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 20 #include "base/at_exit.h" | 20 #include "base/at_exit.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/message_loop.h" | 23 #include "base/message_loop.h" |
| 24 #include "grit/ui_resources.h" | 24 #include "grit/ui_resources.h" |
| 25 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 26 #include "ui/aura/client/window_types.h" |
| 26 #include "ui/aura/root_window.h" | 27 #include "ui/aura/root_window.h" |
| 27 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/base/ui_base_paths.h" | 30 #include "ui/base/ui_base_paths.h" |
| 30 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/compositor/test/compositor_test_support.h" | 32 #include "ui/gfx/compositor/test/compositor_test_support.h" |
| 32 #include "ui/views/test/test_views_delegate.h" | 33 #include "ui/views/test/test_views_delegate.h" |
| 33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 34 #include "ui/views/widget/widget_delegate.h" | 35 #include "ui/views/widget/widget_delegate.h" |
| 35 | 36 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 virtual ~WindowWatcher() { | 67 virtual ~WindowWatcher() { |
| 67 window_->RemoveObserver(this); | 68 window_->RemoveObserver(this); |
| 68 } | 69 } |
| 69 | 70 |
| 70 aura::Window* GetWindowByID(ash::LauncherID id) { | 71 aura::Window* GetWindowByID(ash::LauncherID id) { |
| 71 IDToWindow::const_iterator i = id_to_window_.find(id); | 72 IDToWindow::const_iterator i = id_to_window_.find(id); |
| 72 return i != id_to_window_.end() ? i->second : NULL; | 73 return i != id_to_window_.end() ? i->second : NULL; |
| 73 } | 74 } |
| 74 | 75 |
| 76 ash::LauncherID GetIDByWindow(aura::Window* window) const { |
| 77 for (IDToWindow::const_iterator i = id_to_window_.begin(); |
| 78 i != id_to_window_.end(); ++i) { |
| 79 if (i->second == window) |
| 80 return i->first; |
| 81 } |
| 82 return 0; // TODO: add a constant for this. |
| 83 } |
| 84 |
| 75 // aura::WindowObserver overrides: | 85 // aura::WindowObserver overrides: |
| 76 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { | 86 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { |
| 87 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL) |
| 88 return; |
| 89 |
| 77 static int image_count = 0; | 90 static int image_count = 0; |
| 78 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); | 91 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); |
| 79 ash::LauncherItem item; | 92 ash::LauncherItem item; |
| 80 item.type = ash::TYPE_TABBED; | 93 item.type = ash::TYPE_TABBED; |
| 81 id_to_window_[model->next_id()] = new_window; | 94 id_to_window_[model->next_id()] = new_window; |
| 82 item.num_tabs = image_count + 1; | 95 item.num_tabs = image_count + 1; |
| 83 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 96 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); |
| 84 item.image.allocPixels(); | 97 item.image.allocPixels(); |
| 85 item.image.eraseARGB(255, | 98 item.image.eraseARGB(255, |
| 86 image_count == 0 ? 255 : 0, | 99 image_count == 0 ? 255 : 0, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 158 |
| 146 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE { | 159 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE { |
| 147 return watcher_->GetWindowByID(item.id)->title(); | 160 return watcher_->GetWindowByID(item.id)->title(); |
| 148 } | 161 } |
| 149 | 162 |
| 150 virtual ui::MenuModel* CreateContextMenu( | 163 virtual ui::MenuModel* CreateContextMenu( |
| 151 const ash::LauncherItem& item) OVERRIDE { | 164 const ash::LauncherItem& item) OVERRIDE { |
| 152 return NULL; | 165 return NULL; |
| 153 } | 166 } |
| 154 | 167 |
| 168 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE { |
| 169 return watcher_->GetIDByWindow(window); |
| 170 } |
| 171 |
| 155 private: | 172 private: |
| 156 // Used to update Launcher. Owned by main. | 173 // Used to update Launcher. Owned by main. |
| 157 WindowWatcher* watcher_; | 174 WindowWatcher* watcher_; |
| 158 | 175 |
| 159 DISALLOW_COPY_AND_ASSIGN(LauncherDelegateImpl); | 176 DISALLOW_COPY_AND_ASSIGN(LauncherDelegateImpl); |
| 160 }; | 177 }; |
| 161 | 178 |
| 162 class ShellDelegateImpl : public ash::ShellDelegate { | 179 class ShellDelegateImpl : public ash::ShellDelegate { |
| 163 public: | 180 public: |
| 164 ShellDelegateImpl() : watcher_(NULL), launcher_delegate_(NULL) {} | 181 ShellDelegateImpl() : watcher_(NULL), launcher_delegate_(NULL) {} |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 window_watcher.reset(); | 279 window_watcher.reset(); |
| 263 | 280 |
| 264 ash::Shell::DeleteInstance(); | 281 ash::Shell::DeleteInstance(); |
| 265 | 282 |
| 266 aura::Env::DeleteInstance(); | 283 aura::Env::DeleteInstance(); |
| 267 | 284 |
| 268 ui::CompositorTestSupport::Terminate(); | 285 ui::CompositorTestSupport::Terminate(); |
| 269 | 286 |
| 270 return 0; | 287 return 0; |
| 271 } | 288 } |
| OLD | NEW |