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 ash::ShelfItemDelegate::PerformedAction | |
73 AppWindowLauncherItemController::Activate(ash::LaunchSource source) { | |
74 DCHECK(!windows_.empty()); | |
75 ui::BaseWindow* window_to_activate = | |
76 last_active_window_ ? last_active_window_ : windows_.back(); | |
77 window_to_activate->Activate(); | |
78 return kExistingWindowActivated; | |
79 } | |
James Cook
2017/02/15 00:44:40
I'm a little lost. Where did the functionality pro
msw
2017/02/15 19:59:18
It's nearly equivalent to ItemSelected; and I can'
| |
80 | |
81 AppWindowLauncherItemController* | 72 AppWindowLauncherItemController* |
82 AppWindowLauncherItemController::AsAppWindowLauncherItemController() { | 73 AppWindowLauncherItemController::AsAppWindowLauncherItemController() { |
83 return this; | 74 return this; |
84 } | 75 } |
85 | 76 |
86 ash::ShelfItemDelegate::PerformedAction | 77 ash::ShelfAction AppWindowLauncherItemController::ItemSelected( |
87 AppWindowLauncherItemController::ItemSelected(const ui::Event& event) { | 78 ui::EventType event_type, |
79 int event_flags, | |
80 int64_t display_id, | |
81 ash::ShelfLaunchSource source) { | |
88 if (windows_.empty()) | 82 if (windows_.empty()) |
89 return kNoAction; | 83 return ash::kNoAction; |
90 | 84 |
91 ui::BaseWindow* window_to_show = | 85 ui::BaseWindow* window_to_show = |
92 last_active_window_ ? last_active_window_ : windows_.front(); | 86 last_active_window_ ? last_active_window_ : windows_.front(); |
93 // 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 |
94 // 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. |
95 if (windows_.size() >= 1 && window_to_show->IsActive() && | 89 if (windows_.size() >= 1 && window_to_show->IsActive() && |
96 event.type() == ui::ET_KEY_RELEASED) { | 90 event_type == ui::ET_KEY_RELEASED) { |
97 return ActivateOrAdvanceToNextAppWindow(window_to_show); | 91 return ActivateOrAdvanceToNextAppWindow(window_to_show); |
98 } | 92 } |
99 | 93 |
100 return ShowAndActivateOrMinimize(window_to_show); | 94 return ShowAndActivateOrMinimize(window_to_show); |
101 } | 95 } |
102 | 96 |
103 ash::ShelfAppMenuItemList AppWindowLauncherItemController::GetAppMenuItems( | 97 ash::ShelfAppMenuItemList AppWindowLauncherItemController::GetAppMenuItems( |
104 int event_flags) { | 98 int event_flags) { |
105 return ash::ShelfAppMenuItemList(); | 99 return ash::ShelfAppMenuItemList(); |
106 } | 100 } |
(...skipping 23 matching lines...) Expand all Loading... | |
130 status = ash::STATUS_ACTIVE; | 124 status = ash::STATUS_ACTIVE; |
131 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { | 125 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { |
132 status = ash::STATUS_ATTENTION; | 126 status = ash::STATUS_ATTENTION; |
133 } else { | 127 } else { |
134 status = ash::STATUS_RUNNING; | 128 status = ash::STATUS_RUNNING; |
135 } | 129 } |
136 launcher_controller()->SetItemStatus(shelf_id(), status); | 130 launcher_controller()->SetItemStatus(shelf_id(), status); |
137 } | 131 } |
138 } | 132 } |
139 | 133 |
140 ash::ShelfItemDelegate::PerformedAction | 134 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize( |
141 AppWindowLauncherItemController::ShowAndActivateOrMinimize( | |
142 ui::BaseWindow* app_window) { | 135 ui::BaseWindow* app_window) { |
143 // Either show or minimize windows when shown from the launcher. | 136 // Either show or minimize windows when shown from the launcher. |
144 return launcher_controller()->ActivateWindowOrMinimizeIfActive( | 137 return launcher_controller()->ActivateWindowOrMinimizeIfActive( |
145 app_window, GetAppMenuItems(0).size() == 1); | 138 app_window, GetAppMenuItems(0).size() == 1); |
146 } | 139 } |
147 | 140 |
148 ash::ShelfItemDelegate::PerformedAction | 141 ash::ShelfAction |
149 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow( | 142 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow( |
150 ui::BaseWindow* window_to_show) { | 143 ui::BaseWindow* window_to_show) { |
151 WindowList::iterator i( | 144 WindowList::iterator i( |
152 std::find(windows_.begin(), windows_.end(), window_to_show)); | 145 std::find(windows_.begin(), windows_.end(), window_to_show)); |
153 if (i != windows_.end()) { | 146 if (i != windows_.end()) { |
154 if (++i != windows_.end()) | 147 if (++i != windows_.end()) |
155 window_to_show = *i; | 148 window_to_show = *i; |
156 else | 149 else |
157 window_to_show = windows_.front(); | 150 window_to_show = windows_.front(); |
158 } | 151 } |
159 if (window_to_show->IsActive()) { | 152 if (window_to_show->IsActive()) { |
160 // Coming here, only a single window is active. For keyboard activations | 153 // Coming here, only a single window is active. For keyboard activations |
161 // the window gets animated. | 154 // the window gets animated. |
162 AnimateWindow(window_to_show->GetNativeWindow(), | 155 AnimateWindow(window_to_show->GetNativeWindow(), |
163 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 156 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
164 } else { | 157 } else { |
165 return ShowAndActivateOrMinimize(window_to_show); | 158 return ShowAndActivateOrMinimize(window_to_show); |
166 } | 159 } |
167 return kNoAction; | 160 return ash::kNoAction; |
168 } | 161 } |
OLD | NEW |