Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.cc

Issue 23068021: Remove PerBrowser launcher, reland step 1 of 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h"
13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h"
15 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 14 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "ui/aura/client/aura_constants.h" 16 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
19 #include "ui/base/events/event.h" 18 #include "ui/base/events/event.h"
20 #include "ui/views/corewm/window_animations.h" 19 #include "ui/views/corewm/window_animations.h"
21 20
22 using apps::ShellWindow; 21 using apps::ShellWindow;
23 22
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 aura::Window* panel_window = panel->GetNativeWindow(); 147 aura::Window* panel_window = panel->GetNativeWindow();
149 // If the panel is attached on another display, move it to the current 148 // If the panel is attached on another display, move it to the current
150 // display and activate it. 149 // display and activate it.
151 if (panel_window->GetProperty(ash::internal::kPanelAttachedKey) && 150 if (panel_window->GetProperty(ash::internal::kPanelAttachedKey) &&
152 ash::wm::MoveWindowToEventRoot(panel_window, event)) { 151 ash::wm::MoveWindowToEventRoot(panel_window, event)) {
153 if (!panel->GetBaseWindow()->IsActive()) 152 if (!panel->GetBaseWindow()->IsActive())
154 ShowAndActivateOrMinimize(panel); 153 ShowAndActivateOrMinimize(panel);
155 } else { 154 } else {
156 ShowAndActivateOrMinimize(panel); 155 ShowAndActivateOrMinimize(panel);
157 } 156 }
158 } else if (launcher_controller()->GetPerAppInterface() || 157 } else {
159 shell_windows_.size() == 1) {
160 ShellWindow* window_to_show = last_active_shell_window_ ? 158 ShellWindow* window_to_show = last_active_shell_window_ ?
161 last_active_shell_window_ : shell_windows_.front(); 159 last_active_shell_window_ : shell_windows_.front();
162 // If the event was triggered by a keystroke, we try to advance to the next 160 // 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. 161 // item if the window we are trying to activate is already active.
164 if (shell_windows_.size() >= 1 && 162 if (shell_windows_.size() >= 1 &&
165 window_to_show->GetBaseWindow()->IsActive() && 163 window_to_show->GetBaseWindow()->IsActive() &&
166 event.type() == ui::ET_KEY_RELEASED) { 164 event.type() == ui::ET_KEY_RELEASED) {
167 ActivateOrAdvanceToNextShellWindow(window_to_show); 165 ActivateOrAdvanceToNextShellWindow(window_to_show);
168 } else { 166 } else {
169 ShowAndActivateOrMinimize(window_to_show); 167 ShowAndActivateOrMinimize(window_to_show);
170 } 168 }
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 } 169 }
186 } 170 }
187 171
188 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { 172 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) {
189 if (index >= shell_windows_.size()) 173 if (index >= shell_windows_.size())
190 return; 174 return;
191 ShellWindowList::iterator it = shell_windows_.begin(); 175 ShellWindowList::iterator it = shell_windows_.begin();
192 std::advance(it, index); 176 std::advance(it, index);
193 ShowAndActivateOrMinimize(*it); 177 ShowAndActivateOrMinimize(*it);
194 } 178 }
195 179
196 ChromeLauncherAppMenuItems 180 ChromeLauncherAppMenuItems
197 ShellWindowLauncherItemController::GetApplicationList(int event_flags) { 181 ShellWindowLauncherItemController::GetApplicationList(int event_flags) {
198 ChromeLauncherAppMenuItems items; 182 ChromeLauncherAppMenuItems items;
199 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); 183 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false));
200 int index = 0; 184 int index = 0;
201 for (ShellWindowList::iterator iter = shell_windows_.begin(); 185 for (ShellWindowList::iterator iter = shell_windows_.begin();
202 iter != shell_windows_.end(); ++iter) { 186 iter != shell_windows_.end(); ++iter) {
203 ShellWindow* shell_window = *iter; 187 ShellWindow* shell_window = *iter;
204 scoped_ptr<gfx::Image> image(shell_window->GetAppListIcon()); 188 scoped_ptr<gfx::Image> image(shell_window->GetAppListIcon());
205 items.push_back(new ChromeLauncherAppMenuItemV2App( 189 items.push_back(new ChromeLauncherAppMenuItemV2App(
206 shell_window->GetTitle(), 190 shell_window->GetTitle(),
207 image.get(), // Will be copied 191 image.get(), // Will be copied
208 app_id(), 192 app_id(),
209 launcher_controller()->GetPerAppInterface(), 193 launcher_controller(),
210 index, 194 index,
211 index == 0 /* has_leading_separator */)); 195 index == 0 /* has_leading_separator */));
212 ++index; 196 ++index;
213 } 197 }
214 return items.Pass(); 198 return items.Pass();
215 } 199 }
216 200
217 void ShellWindowLauncherItemController::OnWindowPropertyChanged( 201 void ShellWindowLauncherItemController::OnWindowPropertyChanged(
218 aura::Window* window, 202 aura::Window* window,
219 const void* key, 203 const void* key,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 237 }
254 if (window_to_show->GetBaseWindow()->IsActive()) { 238 if (window_to_show->GetBaseWindow()->IsActive()) {
255 // Coming here, only a single window is active. For keyboard activations 239 // Coming here, only a single window is active. For keyboard activations
256 // the window gets animated. 240 // the window gets animated.
257 AnimateWindow(window_to_show->GetNativeWindow(), 241 AnimateWindow(window_to_show->GetNativeWindow(),
258 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE); 242 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE);
259 } else { 243 } else {
260 ShowAndActivateOrMinimize(window_to_show); 244 ShowAndActivateOrMinimize(window_to_show);
261 } 245 }
262 } 246 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698