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 #include <utility> |
8 | 9 |
9 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 #include "ui/base/base_window.h" | 16 #include "ui/base/base_window.h" |
16 #include "ui/wm/core/window_animations.h" | 17 #include "ui/wm/core/window_animations.h" |
17 | 18 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 AppWindowLauncherItemController* | 70 AppWindowLauncherItemController* |
70 AppWindowLauncherItemController::AsAppWindowLauncherItemController() { | 71 AppWindowLauncherItemController::AsAppWindowLauncherItemController() { |
71 return this; | 72 return this; |
72 } | 73 } |
73 | 74 |
74 void AppWindowLauncherItemController::ItemSelected( | 75 void AppWindowLauncherItemController::ItemSelected( |
75 std::unique_ptr<ui::Event> event, | 76 std::unique_ptr<ui::Event> event, |
76 int64_t display_id, | 77 int64_t display_id, |
77 ash::ShelfLaunchSource source, | 78 ash::ShelfLaunchSource source, |
78 const ItemSelectedCallback& callback) { | 79 ItemSelectedCallback callback) { |
79 if (windows_.empty()) { | 80 if (windows_.empty()) { |
80 callback.Run(ash::SHELF_ACTION_NONE, base::nullopt); | 81 std::move(callback).Run(ash::SHELF_ACTION_NONE, base::nullopt); |
81 return; | 82 return; |
82 } | 83 } |
83 | 84 |
84 ui::BaseWindow* window_to_show = | 85 ui::BaseWindow* window_to_show = |
85 last_active_window_ ? last_active_window_ : windows_.front(); | 86 last_active_window_ ? last_active_window_ : windows_.front(); |
86 // If the event was triggered by a keystroke, we try to advance to the next | 87 // If the event was triggered by a keystroke, we try to advance to the next |
87 // item if the window we are trying to activate is already active. | 88 // item if the window we are trying to activate is already active. |
88 ash::ShelfAction action = ash::SHELF_ACTION_NONE; | 89 ash::ShelfAction action = ash::SHELF_ACTION_NONE; |
89 if (windows_.size() >= 1 && window_to_show->IsActive() && event && | 90 if (windows_.size() >= 1 && window_to_show->IsActive() && event && |
90 event->type() == ui::ET_KEY_RELEASED) { | 91 event->type() == ui::ET_KEY_RELEASED) { |
91 action = ActivateOrAdvanceToNextAppWindow(window_to_show); | 92 action = ActivateOrAdvanceToNextAppWindow(window_to_show); |
92 } else { | 93 } else { |
93 action = ShowAndActivateOrMinimize(window_to_show); | 94 action = ShowAndActivateOrMinimize(window_to_show); |
94 } | 95 } |
95 | 96 |
96 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); | 97 std::move(callback).Run( |
| 98 action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); |
97 } | 99 } |
98 | 100 |
99 void AppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, | 101 void AppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, |
100 int32_t event_flags) { | 102 int32_t event_flags) { |
101 // This delegate does not support showing an application menu. | 103 // This delegate does not support showing an application menu. |
102 NOTIMPLEMENTED(); | 104 NOTIMPLEMENTED(); |
103 } | 105 } |
104 | 106 |
105 void AppWindowLauncherItemController::Close() { | 107 void AppWindowLauncherItemController::Close() { |
106 // Note: Closing windows may affect the contents of app_windows_. | 108 // Note: Closing windows may affect the contents of app_windows_. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 if (window_to_show->IsActive()) { | 157 if (window_to_show->IsActive()) { |
156 // Coming here, only a single window is active. For keyboard activations | 158 // Coming here, only a single window is active. For keyboard activations |
157 // the window gets animated. | 159 // the window gets animated. |
158 AnimateWindow(window_to_show->GetNativeWindow(), | 160 AnimateWindow(window_to_show->GetNativeWindow(), |
159 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 161 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
160 } else { | 162 } else { |
161 return ShowAndActivateOrMinimize(window_to_show); | 163 return ShowAndActivateOrMinimize(window_to_show); |
162 } | 164 } |
163 return ash::SHELF_ACTION_NONE; | 165 return ash::SHELF_ACTION_NONE; |
164 } | 166 } |
OLD | NEW |