| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_window_launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return *iter; | 62 return *iter; |
| 63 return nullptr; | 63 return nullptr; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void AppWindowLauncherItemController::SetActiveWindow(aura::Window* window) { | 66 void AppWindowLauncherItemController::SetActiveWindow(aura::Window* window) { |
| 67 ui::BaseWindow* app_window = GetAppWindow(window); | 67 ui::BaseWindow* app_window = GetAppWindow(window); |
| 68 if (app_window) | 68 if (app_window) |
| 69 last_active_window_ = app_window; | 69 last_active_window_ = app_window; |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool AppWindowLauncherItemController::IsVisible() const { | |
| 73 // Return true if any windows are visible. | |
| 74 for (const auto* window : windows_) { | |
| 75 if (window->GetNativeWindow()->IsVisible()) | |
| 76 return true; | |
| 77 } | |
| 78 return false; | |
| 79 } | |
| 80 | |
| 81 void AppWindowLauncherItemController::Launch(ash::LaunchSource source, | 72 void AppWindowLauncherItemController::Launch(ash::LaunchSource source, |
| 82 int event_flags) { | 73 int event_flags) { |
| 83 launcher_controller()->LaunchApp(app_id(), source, ui::EF_NONE); | 74 launcher_controller()->LaunchApp(app_id(), source, ui::EF_NONE); |
| 84 } | 75 } |
| 85 | 76 |
| 86 ash::ShelfItemDelegate::PerformedAction | 77 ash::ShelfItemDelegate::PerformedAction |
| 87 AppWindowLauncherItemController::Activate(ash::LaunchSource source) { | 78 AppWindowLauncherItemController::Activate(ash::LaunchSource source) { |
| 88 DCHECK(!windows_.empty()); | 79 DCHECK(!windows_.empty()); |
| 89 ui::BaseWindow* window_to_activate = | 80 ui::BaseWindow* window_to_activate = |
| 90 last_active_window_ ? last_active_window_ : windows_.back(); | 81 last_active_window_ ? last_active_window_ : windows_.back(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if (window_to_show->IsActive()) { | 165 if (window_to_show->IsActive()) { |
| 175 // Coming here, only a single window is active. For keyboard activations | 166 // Coming here, only a single window is active. For keyboard activations |
| 176 // the window gets animated. | 167 // the window gets animated. |
| 177 AnimateWindow(window_to_show->GetNativeWindow(), | 168 AnimateWindow(window_to_show->GetNativeWindow(), |
| 178 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 169 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 179 } else { | 170 } else { |
| 180 return ShowAndActivateOrMinimize(window_to_show); | 171 return ShowAndActivateOrMinimize(window_to_show); |
| 181 } | 172 } |
| 182 return kNoAction; | 173 return kNoAction; |
| 183 } | 174 } |
| OLD | NEW |