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 "apps/native_app_window.h" | 7 #include "apps/native_app_window.h" |
8 #include "apps/shell_window.h" | 8 #include "apps/shell_window.h" |
9 #include "ash/wm/window_properties.h" | 9 #include "ash/wm/window_properties.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 aura::Window* panel_window = panel->GetNativeWindow(); | 148 aura::Window* panel_window = panel->GetNativeWindow(); |
149 // If the panel is attached on another display, move it to the current | 149 // If the panel is attached on another display, move it to the current |
150 // display and activate it. | 150 // display and activate it. |
151 if (panel_window->GetProperty(ash::internal::kPanelAttachedKey) && | 151 if (panel_window->GetProperty(ash::internal::kPanelAttachedKey) && |
152 ash::wm::MoveWindowToEventRoot(panel_window, event)) { | 152 ash::wm::MoveWindowToEventRoot(panel_window, event)) { |
153 if (!panel->GetBaseWindow()->IsActive()) | 153 if (!panel->GetBaseWindow()->IsActive()) |
154 ShowAndActivateOrMinimize(panel); | 154 ShowAndActivateOrMinimize(panel); |
155 } else { | 155 } else { |
156 ShowAndActivateOrMinimize(panel); | 156 ShowAndActivateOrMinimize(panel); |
157 } | 157 } |
158 } else if (launcher_controller()->GetPerAppInterface() || | 158 } else { |
159 shell_windows_.size() == 1) { | |
160 ShellWindow* window_to_show = last_active_shell_window_ ? | 159 ShellWindow* window_to_show = last_active_shell_window_ ? |
161 last_active_shell_window_ : shell_windows_.front(); | 160 last_active_shell_window_ : shell_windows_.front(); |
162 // If the event was triggered by a keystroke, we try to advance to the next | 161 // If the event was triggered by a keystroke, we try to advance to the next |
163 // item if the window we are trying to activate is already active. | 162 // item if the window we are trying to activate is already active. |
164 if (shell_windows_.size() >= 1 && | 163 if (shell_windows_.size() >= 1 && |
165 window_to_show->GetBaseWindow()->IsActive() && | 164 window_to_show->GetBaseWindow()->IsActive() && |
166 event.type() == ui::ET_KEY_RELEASED) { | 165 event.type() == ui::ET_KEY_RELEASED) { |
167 ActivateOrAdvanceToNextShellWindow(window_to_show); | 166 ActivateOrAdvanceToNextShellWindow(window_to_show); |
168 } else { | 167 } else { |
169 ShowAndActivateOrMinimize(window_to_show); | 168 ShowAndActivateOrMinimize(window_to_show); |
170 } | 169 } |
171 } else { | |
172 // TODO(stevenjb): Deprecate | |
173 if (!last_active_shell_window_ || | |
174 last_active_shell_window_->GetBaseWindow()->IsActive()) { | |
175 // Restore all windows since there is no other way to restore them. | |
176 for (ShellWindowList::iterator iter = shell_windows_.begin(); | |
177 iter != shell_windows_.end(); ++iter) { | |
178 ShellWindow* shell_window = *iter; | |
179 if (shell_window->GetBaseWindow()->IsMinimized()) | |
180 shell_window->GetBaseWindow()->Restore(); | |
181 } | |
182 } | |
183 if (last_active_shell_window_) | |
184 ShowAndActivateOrMinimize(last_active_shell_window_); | |
185 } | 170 } |
186 } | 171 } |
187 | 172 |
188 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 173 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { |
189 if (index >= shell_windows_.size()) | 174 if (index >= shell_windows_.size()) |
190 return; | 175 return; |
191 ShellWindowList::iterator it = shell_windows_.begin(); | 176 ShellWindowList::iterator it = shell_windows_.begin(); |
192 std::advance(it, index); | 177 std::advance(it, index); |
193 ShowAndActivateOrMinimize(*it); | 178 ShowAndActivateOrMinimize(*it); |
194 } | 179 } |
195 | 180 |
196 ChromeLauncherAppMenuItems | 181 ChromeLauncherAppMenuItems |
197 ShellWindowLauncherItemController::GetApplicationList(int event_flags) { | 182 ShellWindowLauncherItemController::GetApplicationList(int event_flags) { |
198 ChromeLauncherAppMenuItems items; | 183 ChromeLauncherAppMenuItems items; |
199 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); | 184 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); |
200 int index = 0; | 185 int index = 0; |
201 for (ShellWindowList::iterator iter = shell_windows_.begin(); | 186 for (ShellWindowList::iterator iter = shell_windows_.begin(); |
202 iter != shell_windows_.end(); ++iter) { | 187 iter != shell_windows_.end(); ++iter) { |
203 ShellWindow* shell_window = *iter; | 188 ShellWindow* shell_window = *iter; |
204 scoped_ptr<gfx::Image> image(shell_window->GetAppListIcon()); | 189 scoped_ptr<gfx::Image> image(shell_window->GetAppListIcon()); |
205 items.push_back(new ChromeLauncherAppMenuItemV2App( | 190 items.push_back(new ChromeLauncherAppMenuItemV2App( |
206 shell_window->GetTitle(), | 191 shell_window->GetTitle(), |
207 image.get(), // Will be copied | 192 image.get(), // Will be copied |
208 app_id(), | 193 app_id(), |
209 launcher_controller()->GetPerAppInterface(), | 194 static_cast<ChromeLauncherControllerPerApp*>(launcher_controller()), |
Mr4D (OOO till 08-26)
2013/08/16 22:43:22
This static_cast should not be needed anymore with
simonhong_
2013/08/19 05:26:11
Done.
| |
210 index, | 195 index, |
211 index == 0 /* has_leading_separator */)); | 196 index == 0 /* has_leading_separator */)); |
212 ++index; | 197 ++index; |
213 } | 198 } |
214 return items.Pass(); | 199 return items.Pass(); |
215 } | 200 } |
216 | 201 |
217 void ShellWindowLauncherItemController::OnWindowPropertyChanged( | 202 void ShellWindowLauncherItemController::OnWindowPropertyChanged( |
218 aura::Window* window, | 203 aura::Window* window, |
219 const void* key, | 204 const void* key, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 } | 238 } |
254 if (window_to_show->GetBaseWindow()->IsActive()) { | 239 if (window_to_show->GetBaseWindow()->IsActive()) { |
255 // Coming here, only a single window is active. For keyboard activations | 240 // Coming here, only a single window is active. For keyboard activations |
256 // the window gets animated. | 241 // the window gets animated. |
257 AnimateWindow(window_to_show->GetNativeWindow(), | 242 AnimateWindow(window_to_show->GetNativeWindow(), |
258 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE); | 243 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE); |
259 } else { | 244 } else { |
260 ShowAndActivateOrMinimize(window_to_show); | 245 ShowAndActivateOrMinimize(window_to_show); |
261 } | 246 } |
262 } | 247 } |
OLD | NEW |