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 "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" |
6 | 6 |
7 #include "apps/shell_window.h" | 7 #include "apps/shell_window.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 window->RemoveObserver(this); | 128 window->RemoveObserver(this); |
129 | 129 |
130 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); | 130 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); |
131 DCHECK(iter2 != app_controller_map_.end()); | 131 DCHECK(iter2 != app_controller_map_.end()); |
132 ShellWindowLauncherItemController* controller = iter2->second; | 132 ShellWindowLauncherItemController* controller = iter2->second; |
133 controller->RemoveShellWindowForWindow(window); | 133 controller->RemoveShellWindowForWindow(window); |
134 if (controller->shell_window_count() == 0) { | 134 if (controller->shell_window_count() == 0) { |
135 // If this is the last window associated with the app launcher id, close the | 135 // If this is the last window associated with the app launcher id, close the |
136 // launcher item. | 136 // launcher item. |
137 ash::LauncherID launcher_id = controller->launcher_id(); | 137 ash::LauncherID launcher_id = controller->launcher_id(); |
| 138 // |owner_| destroys |controller|. |
138 owner_->CloseLauncherItem(launcher_id); | 139 owner_->CloseLauncherItem(launcher_id); |
139 app_controller_map_.erase(iter2); | 140 app_controller_map_.erase(iter2); |
140 delete controller; | |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 void ShellWindowLauncherController::OnWindowActivated( | 144 void ShellWindowLauncherController::OnWindowActivated( |
145 aura::Window* new_active, | 145 aura::Window* new_active, |
146 aura::Window* old_active) { | 146 aura::Window* old_active) { |
147 // Make the newly active window the active (first) entry in the controller. | 147 // Make the newly active window the active (first) entry in the controller. |
148 ShellWindowLauncherItemController* new_controller = | 148 ShellWindowLauncherItemController* new_controller = |
149 ControllerForWindow(new_active); | 149 ControllerForWindow(new_active); |
150 if (new_controller) { | 150 if (new_controller) { |
(...skipping 16 matching lines...) Expand all Loading... |
167 WindowToAppLauncherIdMap::iterator iter1 = | 167 WindowToAppLauncherIdMap::iterator iter1 = |
168 window_to_app_launcher_id_map_.find(window); | 168 window_to_app_launcher_id_map_.find(window); |
169 if (iter1 == window_to_app_launcher_id_map_.end()) | 169 if (iter1 == window_to_app_launcher_id_map_.end()) |
170 return NULL; | 170 return NULL; |
171 std::string app_launcher_id = iter1->second; | 171 std::string app_launcher_id = iter1->second; |
172 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); | 172 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); |
173 if (iter2 == app_controller_map_.end()) | 173 if (iter2 == app_controller_map_.end()) |
174 return NULL; | 174 return NULL; |
175 return iter2->second; | 175 return iter2->second; |
176 } | 176 } |
OLD | NEW |