| 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/launcher/launcher_util.h" | 7 #include "ash/launcher/launcher_util.h" |
| 8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
| 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { | 138 void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { |
| 139 if (shell_windows_.empty()) | 139 if (shell_windows_.empty()) |
| 140 return; | 140 return; |
| 141 if (launcher_controller()->GetPerAppInterface() || | 141 if (launcher_controller()->GetPerAppInterface() || |
| 142 shell_windows_.size() == 1) { | 142 shell_windows_.size() == 1) { |
| 143 ShellWindow* window_to_show = last_active_shell_window_ ? | 143 ShellWindow* window_to_show = last_active_shell_window_ ? |
| 144 last_active_shell_window_ : shell_windows_.front(); | 144 last_active_shell_window_ : shell_windows_.front(); |
| 145 RestoreOrShow(window_to_show); | 145 ShowAndActivate(window_to_show); |
| 146 } else { | 146 } else { |
| 147 // TODO(stevenjb): Deprecate | 147 // TODO(stevenjb): Deprecate |
| 148 if (!last_active_shell_window_ || | 148 if (!last_active_shell_window_ || |
| 149 last_active_shell_window_->GetBaseWindow()->IsActive()) { | 149 last_active_shell_window_->GetBaseWindow()->IsActive()) { |
| 150 // Restore all windows since there is no other way to restore them. | 150 // Restore all windows since there is no other way to restore them. |
| 151 for (ShellWindowList::iterator iter = shell_windows_.begin(); | 151 for (ShellWindowList::iterator iter = shell_windows_.begin(); |
| 152 iter != shell_windows_.end(); ++iter) { | 152 iter != shell_windows_.end(); ++iter) { |
| 153 ShellWindow* shell_window = *iter; | 153 ShellWindow* shell_window = *iter; |
| 154 if (shell_window->GetBaseWindow()->IsMinimized()) | 154 if (shell_window->GetBaseWindow()->IsMinimized()) |
| 155 shell_window->GetBaseWindow()->Restore(); | 155 shell_window->GetBaseWindow()->Restore(); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 if (last_active_shell_window_) | 158 if (last_active_shell_window_) |
| 159 RestoreOrShow(last_active_shell_window_); | 159 ShowAndActivate(last_active_shell_window_); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 163 void ShellWindowLauncherItemController::ActivateIndexedApp(size_t index) { |
| 164 if (index >= shell_windows_.size()) | 164 if (index >= shell_windows_.size()) |
| 165 return; | 165 return; |
| 166 ShellWindowList::iterator it = shell_windows_.begin(); | 166 ShellWindowList::iterator it = shell_windows_.begin(); |
| 167 std::advance(it, index); | 167 std::advance(it, index); |
| 168 RestoreOrShow(*it); | 168 ShowAndActivate(*it); |
| 169 } | 169 } |
| 170 | 170 |
| 171 ChromeLauncherAppMenuItems | 171 ChromeLauncherAppMenuItems |
| 172 ShellWindowLauncherItemController::GetApplicationList() { | 172 ShellWindowLauncherItemController::GetApplicationList() { |
| 173 ChromeLauncherAppMenuItems items; | 173 ChromeLauncherAppMenuItems items; |
| 174 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); | 174 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); |
| 175 int index = 0; | 175 int index = 0; |
| 176 for (ShellWindowList::iterator iter = shell_windows_.begin(); | 176 for (ShellWindowList::iterator iter = shell_windows_.begin(); |
| 177 iter != shell_windows_.end(); ++iter) { | 177 iter != shell_windows_.end(); ++iter) { |
| 178 ShellWindow* shell_window = *iter; | 178 ShellWindow* shell_window = *iter; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 199 status = ash::STATUS_ACTIVE; | 199 status = ash::STATUS_ACTIVE; |
| 200 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { | 200 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { |
| 201 status = ash::STATUS_ATTENTION; | 201 status = ash::STATUS_ATTENTION; |
| 202 } else { | 202 } else { |
| 203 status = ash::STATUS_RUNNING; | 203 status = ash::STATUS_RUNNING; |
| 204 } | 204 } |
| 205 launcher_controller()->SetItemStatus(launcher_id(), status); | 205 launcher_controller()->SetItemStatus(launcher_id(), status); |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 void ShellWindowLauncherItemController::RestoreOrShow( | 209 void ShellWindowLauncherItemController::ShowAndActivate( |
| 210 ShellWindow* shell_window) { | 210 ShellWindow* shell_window) { |
| 211 if (shell_window->GetBaseWindow()->IsMinimized()) | |
| 212 shell_window->GetBaseWindow()->Restore(); | |
| 213 else | |
| 214 shell_window->GetBaseWindow()->Show(); | |
| 215 // Always activate windows when shown from the launcher. | 211 // Always activate windows when shown from the launcher. |
| 212 shell_window->GetBaseWindow()->Show(); |
| 216 shell_window->GetBaseWindow()->Activate(); | 213 shell_window->GetBaseWindow()->Activate(); |
| 217 } | 214 } |
| OLD | NEW |