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_item_controller.h
" | 5 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" |
6 | 6 |
7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { | 137 void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { |
138 if (shell_windows_.empty()) | 138 if (shell_windows_.empty()) |
139 return; | 139 return; |
140 if (type() == TYPE_APP_PANEL) { | 140 if (type() == TYPE_APP_PANEL) { |
141 DCHECK(shell_windows_.size() == 1); | 141 DCHECK(shell_windows_.size() == 1); |
142 ShellWindow* panel = shell_windows_.front(); | 142 ShellWindow* panel = shell_windows_.front(); |
143 // If the panel is on another display, move it to the current display and | 143 // If the panel is on another display, move it to the current display and |
144 // activate it. | 144 // activate it. |
145 if (ash::wm::MoveWindowToEventRoot(panel->GetNativeWindow(), event)) { | 145 if (ash::wm::MoveWindowToEventRoot(panel->GetNativeWindow(), event)) { |
146 if (!panel->GetBaseWindow()->IsActive()) | 146 if (!panel->GetBaseWindow()->IsActive()) |
147 ShowAndActivate(panel); | 147 ShowAndActivateOrMinimize(panel); |
148 } else { | 148 } else { |
149 if (panel->GetBaseWindow()->IsActive()) | 149 if (panel->GetBaseWindow()->IsActive()) |
150 panel->GetBaseWindow()->Minimize(); | 150 panel->GetBaseWindow()->Minimize(); |
151 else | 151 else |
152 ShowAndActivate(panel); | 152 ShowAndActivateOrMinimize(panel); |
153 } | 153 } |
154 } else if (launcher_controller()->GetPerAppInterface() || | 154 } else if (launcher_controller()->GetPerAppInterface() || |
155 shell_windows_.size() == 1) { | 155 shell_windows_.size() == 1) { |
156 ShellWindow* window_to_show = last_active_shell_window_ ? | 156 ShellWindow* window_to_show = last_active_shell_window_ ? |
157 last_active_shell_window_ : shell_windows_.front(); | 157 last_active_shell_window_ : shell_windows_.front(); |
158 ShowAndActivate(window_to_show); | 158 ShowAndActivateOrMinimize(window_to_show); |
159 } else { | 159 } else { |
160 // TODO(stevenjb): Deprecate | 160 // TODO(stevenjb): Deprecate |
161 if (!last_active_shell_window_ || | 161 if (!last_active_shell_window_ || |
162 last_active_shell_window_->GetBaseWindow()->IsActive()) { | 162 last_active_shell_window_->GetBaseWindow()->IsActive()) { |
163 // Restore all windows since there is no other way to restore them. | 163 // Restore all windows since there is no other way to restore them. |
164 for (ShellWindowList::iterator iter = shell_windows_.begin(); | 164 for (ShellWindowList::iterator iter = shell_windows_.begin(); |
165 iter != shell_windows_.end(); ++iter) { | 165 iter != shell_windows_.end(); ++iter) { |
166 ShellWindow* shell_window = *iter; | 166 ShellWindow* shell_window = *iter; |
167 if (shell_window->GetBaseWindow()->IsMinimized()) | 167 if (shell_window->GetBaseWindow()->IsMinimized()) |
168 shell_window->GetBaseWindow()->Restore(); | 168 shell_window->GetBaseWindow()->Restore(); |
169 } | 169 } |
170 } | 170 } |
171 if (last_active_shell_window_) | 171 if (last_active_shell_window_) |
172 ShowAndActivate(last_active_shell_window_); | 172 ShowAndActivateOrMinimize(last_active_shell_window_); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 176 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { |
177 if (index >= shell_windows_.size()) | 177 if (index >= shell_windows_.size()) |
178 return; | 178 return; |
179 ShellWindowList::iterator it = shell_windows_.begin(); | 179 ShellWindowList::iterator it = shell_windows_.begin(); |
180 std::advance(it, index); | 180 std::advance(it, index); |
181 ShowAndActivate(*it); | 181 ShowAndActivateOrMinimize(*it); |
182 } | 182 } |
183 | 183 |
184 ChromeLauncherAppMenuItems | 184 ChromeLauncherAppMenuItems |
185 ShellWindowLauncherItemController::GetApplicationList() { | 185 ShellWindowLauncherItemController::GetApplicationList() { |
186 ChromeLauncherAppMenuItems items; | 186 ChromeLauncherAppMenuItems items; |
187 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); | 187 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); |
188 int index = 0; | 188 int index = 0; |
189 for (ShellWindowList::iterator iter = shell_windows_.begin(); | 189 for (ShellWindowList::iterator iter = shell_windows_.begin(); |
190 iter != shell_windows_.end(); ++iter) { | 190 iter != shell_windows_.end(); ++iter) { |
191 ShellWindow* shell_window = *iter; | 191 ShellWindow* shell_window = *iter; |
(...skipping 20 matching lines...) Expand all Loading... |
212 status = ash::STATUS_ACTIVE; | 212 status = ash::STATUS_ACTIVE; |
213 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { | 213 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { |
214 status = ash::STATUS_ATTENTION; | 214 status = ash::STATUS_ATTENTION; |
215 } else { | 215 } else { |
216 status = ash::STATUS_RUNNING; | 216 status = ash::STATUS_RUNNING; |
217 } | 217 } |
218 launcher_controller()->SetItemStatus(launcher_id(), status); | 218 launcher_controller()->SetItemStatus(launcher_id(), status); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 void ShellWindowLauncherItemController::ShowAndActivate( | 222 void ShellWindowLauncherItemController::ShowAndActivateOrMinimize( |
223 ShellWindow* shell_window) { | 223 ShellWindow* shell_window) { |
224 // Always activate windows when shown from the launcher. | 224 // Either show or minimize windows when shown from the launcher. |
225 shell_window->GetBaseWindow()->Show(); | 225 launcher_controller()->ActivateWindowOrMinimizeIfActive( |
226 shell_window->GetBaseWindow()->Activate(); | 226 shell_window->GetBaseWindow(), |
| 227 GetApplicationList().size() == 2); |
227 } | 228 } |
OLD | NEW |