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

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

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Cleanup; fix ash_shell compile and a couple tests. Created 3 years, 9 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
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 AppWindowLauncherItemController* 72 AppWindowLauncherItemController*
73 AppWindowLauncherItemController::AsAppWindowLauncherItemController() { 73 AppWindowLauncherItemController::AsAppWindowLauncherItemController() {
74 return this; 74 return this;
75 } 75 }
76 76
77 ash::ShelfAction AppWindowLauncherItemController::ItemSelected( 77 void AppWindowLauncherItemController::ItemSelected(
78 ui::EventType event_type, 78 std::unique_ptr<ui::Event> event,
79 int event_flags,
80 int64_t display_id, 79 int64_t display_id,
81 ash::ShelfLaunchSource source) { 80 ash::ShelfLaunchSource source,
82 if (windows_.empty()) 81 const ItemSelectedCallback& callback) {
83 return ash::SHELF_ACTION_NONE; 82 if (windows_.empty()) {
83 callback.Run(ash::SHELF_ACTION_NONE, MenuItemList());
84 return;
85 }
84 86
85 ui::BaseWindow* window_to_show = 87 ui::BaseWindow* window_to_show =
86 last_active_window_ ? last_active_window_ : windows_.front(); 88 last_active_window_ ? last_active_window_ : windows_.front();
87 // If the event was triggered by a keystroke, we try to advance to the next 89 // If the event was triggered by a keystroke, we try to advance to the next
88 // item if the window we are trying to activate is already active. 90 // item if the window we are trying to activate is already active.
89 if (windows_.size() >= 1 && window_to_show->IsActive() && 91 ash::ShelfAction action = ash::SHELF_ACTION_NONE;
90 event_type == ui::ET_KEY_RELEASED) { 92 if (windows_.size() >= 1 && window_to_show->IsActive() && event &&
91 return ActivateOrAdvanceToNextAppWindow(window_to_show); 93 event->type() == ui::ET_KEY_RELEASED) {
94 action = ActivateOrAdvanceToNextAppWindow(window_to_show);
95 } else {
96 action = ShowAndActivateOrMinimize(window_to_show);
92 } 97 }
93 98
94 return ShowAndActivateOrMinimize(window_to_show); 99 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
95 }
96
97 ash::ShelfAppMenuItemList AppWindowLauncherItemController::GetAppMenuItems(
98 int event_flags) {
99 // Return an empty item list to avoid showing an application menu.
100 return ash::ShelfAppMenuItemList();
101 } 100 }
102 101
103 void AppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, 102 void AppWindowLauncherItemController::ExecuteCommand(uint32_t command_id,
104 int event_flags) { 103 int32_t event_flags) {
105 // This delegate does not support showing an application menu. 104 // This delegate does not support showing an application menu.
106 NOTIMPLEMENTED(); 105 NOTIMPLEMENTED();
107 } 106 }
108 107
109 void AppWindowLauncherItemController::Close() { 108 void AppWindowLauncherItemController::Close() {
110 // Note: Closing windows may affect the contents of app_windows_. 109 // Note: Closing windows may affect the contents of app_windows_.
111 WindowList windows_to_close = windows_; 110 WindowList windows_to_close = windows_;
112 for (auto* window : windows_) 111 for (auto* window : windows_)
113 window->Close(); 112 window->Close();
114 } 113 }
(...skipping 20 matching lines...) Expand all
135 status = ash::STATUS_RUNNING; 134 status = ash::STATUS_RUNNING;
136 } 135 }
137 launcher_controller()->SetItemStatus(shelf_id(), status); 136 launcher_controller()->SetItemStatus(shelf_id(), status);
138 } 137 }
139 } 138 }
140 139
141 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize( 140 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize(
142 ui::BaseWindow* app_window) { 141 ui::BaseWindow* app_window) {
143 // Either show or minimize windows when shown from the launcher. 142 // Either show or minimize windows when shown from the launcher.
144 return launcher_controller()->ActivateWindowOrMinimizeIfActive( 143 return launcher_controller()->ActivateWindowOrMinimizeIfActive(
145 app_window, GetAppMenuItems(0).size() == 1); 144 app_window, GetAppMenuItems(ui::EF_NONE).size() == 1);
146 } 145 }
147 146
148 ash::ShelfAction 147 ash::ShelfAction
149 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow( 148 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow(
150 ui::BaseWindow* window_to_show) { 149 ui::BaseWindow* window_to_show) {
151 WindowList::iterator i( 150 WindowList::iterator i(
152 std::find(windows_.begin(), windows_.end(), window_to_show)); 151 std::find(windows_.begin(), windows_.end(), window_to_show));
153 if (i != windows_.end()) { 152 if (i != windows_.end()) {
154 if (++i != windows_.end()) 153 if (++i != windows_.end())
155 window_to_show = *i; 154 window_to_show = *i;
156 else 155 else
157 window_to_show = windows_.front(); 156 window_to_show = windows_.front();
158 } 157 }
159 if (window_to_show->IsActive()) { 158 if (window_to_show->IsActive()) {
160 // Coming here, only a single window is active. For keyboard activations 159 // Coming here, only a single window is active. For keyboard activations
161 // the window gets animated. 160 // the window gets animated.
162 AnimateWindow(window_to_show->GetNativeWindow(), 161 AnimateWindow(window_to_show->GetNativeWindow(),
163 wm::WINDOW_ANIMATION_TYPE_BOUNCE); 162 wm::WINDOW_ANIMATION_TYPE_BOUNCE);
164 } else { 163 } else {
165 return ShowAndActivateOrMinimize(window_to_show); 164 return ShowAndActivateOrMinimize(window_to_show);
166 } 165 }
167 return ash::SHELF_ACTION_NONE; 166 return ash::SHELF_ACTION_NONE;
168 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698